diff --git a/README.md b/README.md index b37da3a..ffb8498 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Pricing Calculator -[![Tests](https://github.com/sterlingspares/calc/actions/workflows/tests.yml/badge.svg)](https://github.com/sterlingspares/calc/actions/workflows/tests.yml) ![Tests](https://img.shields.io/badge/tests-1489%20passing-brightgreen?style=flat-square) ![Coverage](https://img.shields.io/badge/coverage-80%25-green?style=flat-square) ![Lighthouse Performance](https://img.shields.io/badge/Lighthouse%20Perf-97-brightgreen?style=flat-square&logo=lighthouse) ![Lighthouse Accessibility](https://img.shields.io/badge/Lighthouse%20A11y-100-brightgreen?style=flat-square&logo=lighthouse) ![Lighthouse Best Practices](https://img.shields.io/badge/Best%20Practices-100-brightgreen?style=flat-square&logo=lighthouse) ![a11y](https://img.shields.io/badge/WCAG%202.1-AA-brightgreen?style=flat-square) ![PWA](https://img.shields.io/badge/PWA-offline--ready-brightgreen?style=flat-square&logo=pwa) ![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square) ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg) +[![Tests](https://github.com/sterlingspares/calc/actions/workflows/tests.yml/badge.svg)](https://github.com/sterlingspares/calc/actions/workflows/tests.yml) ![Tests](https://img.shields.io/badge/tests-1543%20passing-brightgreen?style=flat-square) ![Coverage](https://img.shields.io/badge/coverage-80%25-green?style=flat-square) ![Lighthouse Performance](https://img.shields.io/badge/Lighthouse%20Perf-97-brightgreen?style=flat-square&logo=lighthouse) ![Lighthouse Accessibility](https://img.shields.io/badge/Lighthouse%20A11y-100-brightgreen?style=flat-square&logo=lighthouse) ![Lighthouse Best Practices](https://img.shields.io/badge/Best%20Practices-100-brightgreen?style=flat-square&logo=lighthouse) ![a11y](https://img.shields.io/badge/WCAG%202.1-AA-brightgreen?style=flat-square) ![PWA](https://img.shields.io/badge/PWA-offline--ready-brightgreen?style=flat-square&logo=pwa) ![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square) ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg) **Live app:** [calc.sterlingspares.com](https://calc.sterlingspares.com) @@ -75,7 +75,7 @@ rebate from the supplier: | SP excl GST | ₹750.00 | 25% off — ₹885.00 incl GST, the quoted price | | **Profit** | **₹168.00** | ₹750.00 − ₹582.00 | | GP % | 22.40% | 168 ÷ 750 | -| Margin % | 28.87% | 168 ÷ 582 | +| Markup % | 28.87% | 168 ÷ 582 | | Break-even SP (incl GST) | ₹686.76 | incl GST — below this you lose money | Without the two incentives the same deal shows ₹150.00 profit and 20.00% GP. @@ -94,12 +94,12 @@ easy to forget. | **Effective CP / SP** | The price after incentives and landed costs. Profit is computed from these, not from the invoice figures | | **Landed cost** | Per-unit freight, insurance or handling — added to CP inbound, deducted from SP outbound | | **GP %** | Profit as a share of **selling** price | -| **Margin %** | Profit as a share of **cost** | +| **Markup %** | Profit as a share of **cost** | -> Note the last two, which the trade uses in a specific way. **GP %** is -> profit ÷ SP; **Margin %** is profit ÷ CP. If you come from a finance -> background, "Margin %" here is what you would call *markup* — it is always the -> larger of the two, as in the example above. +> Note the last two. **GP %** is profit ÷ SP; **Markup %** is profit ÷ CP — +> always the larger of the two, as in the example above. Parts of the trade say +> "margin" when they mean markup, which is exactly why it is worth being sure +> which one a supplier is quoting. --- @@ -138,7 +138,7 @@ Opening `index.html` from disk works too — the app runs, but the browser block index.html markup only assets/styles.css all styling assets/app.js core behaviour -assets/app-extra.js what-if, compare, quote, CSV export — on demand +assets/app-extra.js what-if, compare, quote, converters, exports — on demand assets/fonts.css self-hosted @font-face rules assets/fonts/ three woff2 files sw.js service worker @@ -195,7 +195,7 @@ Choose what the calculator computes and what you supply: | Mode | You enter | It computes | Key | |---|---|---|---| -| **Profit** (default) | MRP · CP · SP | Profit ₹, GP %, Margin % | `P` | +| **Profit** (default) | MRP · CP · SP | Profit ₹, GP %, Markup % | `P` | | **Selling Price** | MRP · CP · target profit | Selling Price | `L` | | **Cost Price** | MRP · SP · target profit | Cost Price | `K` | @@ -205,7 +205,7 @@ Choose what the calculator computes and what you supply: |---|---| | **₹ Value** | Eff. SP excl GST − Eff. CP excl GST | | **GP %** | Profit ÷ Eff. SP excl GST × 100 | -| **Margin %** | Profit ÷ Eff. CP excl GST × 100 | +| **Markup %** | Profit ÷ Eff. CP excl GST × 100 | ### Quantity and order value @@ -398,7 +398,7 @@ hand-edited entry is dropped rather than trusted. ### Summary A sticky bar below the cards. It carries only what the cards do not — effective -CP and SP, the incentive totals, profit, GP %, Margin %, break-even and the +CP and SP, the incentive totals, profit, GP %, Markup %, break-even and the order block — rather than repeating the prices shown directly above it. Values below your floor limits are flagged. @@ -418,7 +418,7 @@ so the quotable price is grossed back up accordingly. ### Target-margin solver -In the summary, beside Margin %, enter a **Target GP %** and it answers the question +In the summary, beside Markup %, enter a **Target GP %** and it answers the question directly rather than making you converge on it by trial and error. What it says depends on which side of the target you are on: @@ -446,14 +446,20 @@ printing a nonsense figure. Landed costs are accounted for throughout. Three side-by-side SP scenarios (A · B · C) to compare before committing. Each takes its own SP input (discount % or manual ₹) and shows SP, Profit ₹, GP % and -Margin %. The highest-GP scenario is highlighted automatically, and everything +Markup %. The highest-GP scenario is highlighted automatically, and everything updates live. +### Tools + +Three things that are useful beside a calculation but are not part of one live +under **Tools** in the header — the quote builder and the two converters. On a +phone they are in the hamburger menu instead. Press `T` to open it. + ### GP % / markup % converter Two ways of quoting the same profit, over different denominators — which is why a supplier offering "25%" and a customer expecting "25%" can mean different -money. **GP ⇄ Markup** in the header takes either and returns the other: +money. **Tools → GP ⇄ Markup** takes either and returns the other: | GP % | Markup % | |---:|---:| @@ -467,11 +473,23 @@ percentage on its own is easy to nod along to. **Use this calculation** seeds it from whatever is on screen, and the two ends with no finite answer (100% GP, −100% markup) say so rather than blanking. -Markup % is what this app calls **Margin %** elsewhere. +### Currency converter + +**Tools → Currency converter** converts an amount between any two of the twenty +currencies, at the same rates the rest of the app uses. Type into either side +and the other follows; **⇄** reverses the pair, carrying the converted amount +back as the new input. + +It is deliberately separate from the **Show** setting in Settings → Pricing. +That one restates the whole calculation in another currency; this is a scratch +pad, and leaves the calculation alone. Every rate is quoted per rupee, so a +cross-pair like USD → EUR goes through the rupee — exact, rather than a second +lookup. When a rate is not known it says so, with a route to fixing it, instead +of showing a blank box. ### Quote builder -A multi-line quoting tool — press `M`, or use **Quote** in the header / menu. +A multi-line quoting tool — press `M`, or use **Tools → Quote builder**. Each line takes a description, MRP, quantity and net CP/SP discounts, and computes SP incl GST, line value, line profit and GP %. Lines below your GP floor @@ -508,7 +526,7 @@ Calculations auto-save after 900 ms of inactivity once both CP and SP are filled (toggleable in Settings). Up to **50 entries** are kept, across page reloads. Each card shows time (relative, absolute on hover), tag, quantity if above 1, -MRP, CP excl, SP excl, CP incentives ₹, Profit ₹, GP %, Margin % and GST rate. +MRP, CP excl, SP excl, CP incentives ₹, Profit ₹, GP %, Markup % and GST rate. **Search, filter, tag** @@ -520,7 +538,7 @@ MRP, CP excl, SP excl, CP incentives ₹, Profit ₹, GP %, Margin % and GST rat The panel header shows `N of M` while a search or filter is active. **Actions** — Save current · Compare (side-by-side against the current state with -↑↓ deltas for CP, SP, Profit, GP %, Margin %) · delete one entry (**×**) · Export +↑↓ deltas for CP, SP, Profit, GP %, Markup %) · delete one entry (**×**) · Export CSV · Clear all. ### Undo / redo @@ -565,14 +583,14 @@ switched off hides rather than leading nowhere. A six-step tour opens on a first visit, written for someone who arrived without reading any of this. It starts with the problem rather than the features, offers to **fill the example in** so the screen is working rather than empty, warns that -GP % and Margin % are not the same figure, and says plainly that the tax rate and +GP % and Markup % are not the same figure, and says plainly that the tax rate and the currency are yours to set. Restart it any time from Settings → Help. | Setting | Description | |---|---| | **Dark mode** | Full dark colour scheme | | **Minimum GP %** | Flags values red below this threshold | -| **Minimum Margin %** | Flags values red below this threshold | +| **Minimum Markup %** | Flags values red below this threshold | | **Auto-save** | Toggle automatic history logging | | **Rounding** | ₹1, ₹5, a custom step, or off | | **Features** | Switch off anything you do not use | @@ -593,8 +611,9 @@ and it disappears from the screen: | | | |---|---| | **Presets** | the header button, menu entry and the manager | -| **GP / markup converter** | the header button | -| **Quote builder** | the header button, menu item and bottom-nav tab | +| **GP / markup converter** | its entry in Tools | +| **Currency converter** | its entry in Tools | +| **Quote builder** | its entry in Tools, the menu item and the bottom-nav tab | | **What-if scenarios** | the button on the summary | | **Landed costs** | both fields in the MRP bar | | **Target GP solver** | the row under break-even | @@ -620,7 +639,7 @@ A mobile-oriented 4-step card interface — `Q` toggles it. 1. **MRP** — MRP, GST rate, solve-for mode 2. **CP** — cost price (discount % or manual ₹) 3. **SP** — selling price (or profit, when solving for SP/CP) -4. **Result** — profit, GP %, Margin %, effective prices +4. **Result** — profit, GP %, Markup %, effective prices Swipe left/right or use `→` / `Enter` and `←` to move between cards. Quick mode remembers its own last inputs and restores them when you return. @@ -633,7 +652,7 @@ remembers its own last inputs and restores them when you return. The layout adapts below 800 px. -- **Sticky result bar** — Profit, GP % and Margin % stay pinned above the bottom +- **Sticky result bar** — Profit, GP % and Markup % stay pinned above the bottom nav in Default mode, so you can watch them move while editing discounts instead of scrolling to the summary and back. Values below your floors turn amber; losses turn red. @@ -661,11 +680,11 @@ The layout adapts below 800 px. | `?` | Keyboard shortcuts | `1` | GST 18% | | `S` | Settings | `2` | GST 5% | | `E` | Saved presets | `P` | Solve for Profit | -| `M` | Quote builder | `L` | Solve for Selling Price | -| `R` | Reset all inputs | `K` | Solve for Cost Price | -| `Q` | Default / Quick mode | `⌘/Ctrl + Z` | Undo | -| `⌘/Ctrl + S` | Save to history | `⌘/Ctrl + ⇧ + Z` | Redo | -| `⌘/Ctrl + C` | Copy summary | | | +| `T` | Tools menu | `L` | Solve for Selling Price | +| `M` | Quote builder | `K` | Solve for Cost Price | +| `R` | Reset all inputs | `⌘/Ctrl + Z` | Undo | +| `Q` | Default / Quick mode | `⌘/Ctrl + ⇧ + Z` | Redo | +| `⌘/Ctrl + S` | Save to history | `⌘/Ctrl + C` | Copy summary | Any GST rate other than 18% or 5% goes in the **Other %** box. `P` and `S` were taken by Solve-for-Profit and Settings, so presets use `E`. @@ -775,7 +794,7 @@ Every number here is reproducible from the repo — none is hand-written. | Metric | Value | Reproduce with | |---|---|---| -| Tests | 1489 passing, 7 suites | `npm test` | +| Tests | 1543 passing, 7 suites | `npm test` | | Statement coverage | **82.7%** (app.js 86.3%, app-extra.js 72.3%) | `npm run coverage` | | Lighthouse Performance | **97** | `npm i -D lighthouse && npm run lighthouse` | | Lighthouse Accessibility | **100** | ” | @@ -812,7 +831,7 @@ commands after significant changes. ## Tests -1489 assertions across seven suites. They load the real `index.html`, +1543 assertions across seven suites. They load the real `index.html`, `assets/styles.css` and both script bundles, and drive the actual application functions — no application code is mocked. **Node 22 or newer.** @@ -823,13 +842,13 @@ npm test | Suite | Assertions | Covers | |---|---|---| -| `features` | 1049 | GST, incentives, quantity, landed costs, rounding, undo/redo of typed values and controls, quote maths, history | +| `features` | 1087 | GST, incentives, quantity, landed costs, rounding, undo/redo of typed values and controls, quote maths, history | | `errors` | 33 | every failure path logs; a clean run stays silent; storage and payload recovery | | `mobile` | 78 | modal layering, touch targets, sticky result bar, responsive quote layouts | | `fab` | 50 | floating action button behaviour and z-index ordering | | `modes` | 85 | solve modes, price input modes, what-if, comparison, Quick mode, wizard, share-link round trip, theming, auto-save | -| `a11y` | 104 | contrast ratios, structure, names, keyboard operability, focus trap, live regions, reduced motion, axe-core | -| `browser` | 90 | real Chromium over HTTP: asset loading, CSS cascade, `defer` timing, clicks, dialogs, control-bar spacing, mobile viewport, axe with layout | +| `a11y` | 108 | contrast ratios, structure, names, keyboard operability, focus trap, live regions, reduced motion, axe-core | +| `browser` | 102 | real Chromium over HTTP: asset loading, CSS cascade, `defer` timing, clicks, dialogs, control-bar spacing, mobile viewport, axe with layout | Individual suites: `npm run test:features`, `test:errors`, `test:mobile`, `test:fab`, `test:modes`, `test:a11y`, `test:browser`. Full assertion output: @@ -863,9 +882,17 @@ repo is what the browser runs. `script-src 'self'`. - **`assets/app.js`** is the core: calculation, incentives, history, settings, persistence. Loaded with `defer`, so the DOM is parsed before it initialises. -- **`assets/app-extra.js`** holds what-if, comparison, the quote builder and - onboarding. It is fetched on first use and warmed up during idle time, keeping - it off the critical path. +- **`assets/app-extra.js`** holds what-if, comparison, the quote builder, Quick + mode, the wizard, CSV export, both converters, the preset manager, the + text-entry dialog and the share/copy/PDF exports. It is fetched on first use + and warmed up during idle time, keeping it off the critical path. + + The rule for what may live here: **nothing that runs before a user asks for + it**. The target-GP solver was moved out once and had to come back — it is + called from `fillSummary` on every calculation, including the first, so its + shim pulled the bundle straight onto the critical path. A browser test now + blocks the bundle outright and checks a first calculation still comes out + complete. - Plain ES5-compatible browser JavaScript throughout — no framework, no polyfills. - **Fonts are self-hosted**: Syne (headings), DM Sans (UI), JetBrains Mono (numbers), latin subset, one variable woff2 per family. diff --git a/assets/app-extra.js b/assets/app-extra.js index 031a980..c80b7c3 100644 --- a/assets/app-extra.js +++ b/assets/app-extra.js @@ -419,7 +419,7 @@ function fcBuildProfitCard(solveFor){ var card=el('fcc-2');if(!card)return; card.innerHTML='';card.className='fc-card behind-2'; - var titleText=solveFor==='sp'?'Profit / GP% / Margin%':'Profit / GP% / Margin%'; + var titleText=solveFor==='sp'?'Profit / GP% / Markup%':'Profit / GP% / Markup%'; var subText=solveFor==='sp' ?'Enter your target profit to calculate the Selling Price.' :'Enter your target profit to calculate the Cost Price.'; @@ -435,7 +435,7 @@ function fcBuildProfitCard(solveFor){ // mode tabs var modes=document.createElement('div');modes.className='fc-mode-tabs'; - [{k:'val',l:'₹ Value'},{k:'gp',l:'GP %'},{k:'margin',l:'Margin %'}].forEach(function(m){ + [{k:'val',l:'₹ Value'},{k:'gp',l:'GP %'},{k:'margin',l:'Markup %'}].forEach(function(m){ var b=document.createElement('button');b.className='fc-tab'+(FC_PM===m.k?' on':''); b.id='fc-pm-'+m.k;b.textContent=m.l;b.onclick=function(){fcSetPM(m.k)};modes.appendChild(b); }); @@ -511,7 +511,7 @@ function fcRenderResult(){ html+=fcRItem('SP incl GST', sp?SINR(sp.i):'—', spOver?'warn':'', ''); html+=fcRItem('Profit', pr!==null?SINR(pr):'—', pr!==null?(pr>=0?'pos':'neg'):'', pr!==null&&pr<0?'profit-neg':pr!==null&&pr>=0?'profit-pos':''); html+=fcRItem('GP %', gp!==null?fcPCT(gp):'—', gp!==null?(gp>=0?'pos':'neg'):'', ''); - html+=fcRItem('Margin %', mg!==null?fcPCT(mg):'—', mg!==null?(mg>=0?'pos':'neg'):'', ''); + html+=fcRItem('Markup %', mg!==null?fcPCT(mg):'—', mg!==null?(mg>=0?'pos':'neg'):'', ''); html+=''; if(cpOver)html+='
⚠ CP incl GST exceeds MRP
'; @@ -1512,7 +1512,7 @@ function _renderWhatIfImpl(cp){ // result rows with stable IDs var rows=document.createElement('div');rows.className='wi-rows'; - var LBLS=['SP excl GST','SP incl GST','Profit ₹','GP %','Margin %']; + var LBLS=['SP excl GST','SP incl GST','Profit ₹','GP %','Markup %']; var KEYS=['spe','spi','pr','gp','mg']; var sp=resolveWiSP(sc); LBLS.forEach(function(lbl,k){ @@ -1541,7 +1541,7 @@ function _exportHistoryCSVImpl(){ toast('No history entries to export.'); return; } - var headers=['Time','Tag','MRP (incl GST)','CP excl GST','CP incl GST','SP excl GST','SP incl GST','Eff CP excl GST','CP Incentives INR','Eff SP excl GST','SP Incentives INR','Profit INR','GP %','Margin %','GST Rate %','Qty','Total Profit INR']; + var headers=['Time','Tag','MRP (incl GST)','CP excl GST','CP incl GST','SP excl GST','SP incl GST','Eff CP excl GST','CP Incentives INR','Eff SP excl GST','SP Incentives INR','Profit INR','GP %','Markup %','GST Rate %','Qty','Total Profit INR']; var rows=[headers.join(',')]; HISTORY.forEach(function(h){ rows.push([ @@ -1661,7 +1661,7 @@ function _renderCompareImpl(){ {label:'Incentives', cur:cur?cur.incInr:null,hist:hist.incInr,fmt:'inr', higher:true, side:'cost'}, {label:'Profit', cur:cur?cur.pr:null, hist:hist.pr, fmt:'inr', higher:true, posNeg:true, side:'sale'}, {label:'GP %', cur:cur?cur.gp:null, hist:hist.gp, fmt:'pct', higher:true, isGP:true}, - {label:'Margin %', cur:cur?cur.mg:null, hist:hist.mg, fmt:'pct', higher:true, isMG:true}, + {label:'Markup %', cur:cur?cur.mg:null, hist:hist.mg, fmt:'pct', higher:true, isMG:true}, {label:'GST Rate', cur:cur?cur.gst:null, hist:hist.gst, fmt:'gst', higher:null} ]; @@ -1691,3 +1691,387 @@ function _renderCompareImpl(){ + +/* ── Moved off the critical path ──────────────────────────────────────────── + None of these runs before a user opens the thing it draws: the target-GP + solver, the two converters, the preset manager and the factory reset. Each + keeps a shim in the core bundle that fetches this file on first use. + ─────────────────────────────────────────────────────────────────────────── */ + +function _factoryResetImpl(){ + var held=[]; + if(HISTORY.length)held.push(HISTORY.length+' history entr'+(HISTORY.length===1?'y':'ies')); + var np=Object.keys(PRESETS).length; + if(np)held.push(np+' preset'+(np===1?'':'s')); + if(QUOTE.length)held.push(QUOTE.length+' quote line'+(QUOTE.length===1?'':'s')); + var off=FEATURE_DEFS.filter(function(f){return !featOn(f.k)}).length; + if(off)held.push(off+' switched-off feature'+(off===1?'':'s')); + askConfirm('Reset the app', + held.length?('This will clear '+held.join(', ')+', along with every setting.') + :'This will clear every saved setting and start fresh.', + 'It cannot be undone — undo history goes too.','Reset everything',function(){ + STORAGE_KEYS.forEach(function(k){ + try{ localStorage.removeItem(k) }catch(e){ logError('could not clear '+k,e) } + }); + // Reload rather than unpick the state by hand: every module reads its own + // storage on boot, so a fresh load is the one path guaranteed to agree + // with what a new visitor sees. + try{ location.replace(location.pathname) } + catch(e){ logError('could not reload after reset',e); location.reload() } + }); +} + +/** + * Recompute the other field and the worked line beneath. + * @param {'gp'|'mk'} from which field the user is typing in + */ +function _renderConvertImpl(from){ + var gpEl=el('cv-gp'), mkEl=el('cv-mk'), out=el('cv-out'); + if(!gpEl||!mkEl||!out)return; + var raw=(from==='gp'?gpEl:mkEl).value; + if(String(raw).trim()===''){ + (from==='gp'?mkEl:gpEl).value=''; + out.textContent='';out.className='cv-out'; + return; + } + var v=parseFloat(raw); + var other=(from==='gp')?gpToMarkup(v):markupToGp(v); + if(other===null){ + (from==='gp'?mkEl:gpEl).value=''; + out.textContent=(from==='gp') + ? 'A GP of 100% or more would mean the goods cost nothing — there is no markup that matches.' + : 'A markup of −100% or less would mean selling for nothing — there is no GP that matches.'; + out.className='cv-out bad'; + return; + } + (from==='gp'?mkEl:gpEl).value=String(+other.toFixed(4)); + // Ground it in money: percentages either way are easy to nod along to. + var gp=(from==='gp')?v:other; + var cost=100, sale=(gp>=100)?null:(cost/(1-gp/100)); + if(sale===null||!isFinite(sale)){ out.textContent='';out.className='cv-out'; return } + out.textContent='Buy at '+INR_RS(cost)+', sell at '+INR_RS(sale)+' — profit '+ + INR_RS(sale-cost)+', which is '+PCT(gp)+' of the sale and '+ + PCT((from==='gp')?other:v)+' of the cost.'; + out.className='cv-out'; +} + +/** Pull the GP the calculator is currently showing into the converter. */ +function _convertUseCurrentImpl(){ + if(!LAST_CP||!LAST_SP)return; + var effSP=effectiveSP(LAST_SP), effCP=effectiveCP(LAST_CP); + if(!effSP||effSP<=0)return; + var gp=((effSP-effCP)/effSP)*100; + var f=el('cv-gp'); + if(f){ f.value=String(+gp.toFixed(4)); renderConvert('gp'); } +} + +/** + * Convert an amount between two currencies. + * + * Every rate in FX is quoted per rupee, so the rupee is the pivot even when + * neither side is INR — going through it is exact rather than a second lookup. + * @param {number} amt + * @param {string} from currency code + * @param {string} to currency code + * @returns {number|null} null when either rate is unknown + */ +function ccyConvert(amt,from,to){ + if(amt===null||amt===undefined||isNaN(amt))return null; + var rf=fxRate(from),rt=fxRate(to); + if(rf===null||rt===null||rf<=0)return null; + return (amt/rf)*rt; +} + +/** + * Format an amount in a named currency — money() follows the display scope, + * which is exactly what this dialog must not do. + * @param {number} n + * @param {string} c currency code + */ +function ccyAmt(n,c){ + if(n===null||n===undefined||isNaN(n))return'—'; + return ccyInfo(c).s+_getFmt(c).format(parseFloat(n.toFixed(2))); +} + + +/** + * Recompute the other side and the rate line. + * @param {'from'|'to'} side which box was typed in + */ +function _renderCcyConvImpl(side){ + var fa=el('cc-from-amt'),ta=el('cc-to-amt'),out=el('cc-out'); + if(!fa||!ta||!out)return; + var src=(side==='to')?ta:fa, dst=(side==='to')?fa:ta; + var a=(side==='to')?CC_TO:CC_FROM, b=(side==='to')?CC_FROM:CC_TO; + + var per=ccyConvert(1,CC_FROM,CC_TO); + if(per===null){ + dst.value=''; + var missing=(fxRate(CC_FROM)===null)?CC_FROM:CC_TO; + out.textContent='No rate for '+missing+' yet. Update rates, or set one by hand in '+ + 'Settings \u2192 Currency.'; + out.className='cv-out bad'; + return; + } + if(String(src.value).trim()===''){ + dst.value=''; + out.textContent='1 '+CC_FROM+' = '+ccyAmt(per,CC_TO)+ccyConvSource(); + out.className='cv-out'; + return; + } + var v=parseFloat(src.value); + var conv=ccyConvert(v,a,b); + if(conv===null){ dst.value=''; return } + // Money to the paisa; anything under a unit needs more places or a small + // conversion (1 INR into dollars) rounds away to nothing. + dst.value=String(+conv.toFixed(Math.abs(conv)>=1?2:6)); + var fromAmt=(side==='to')?conv:v, toAmt=(side==='to')?v:conv; + out.textContent=ccyAmt(fromAmt,CC_FROM)+' = '+ccyAmt(toAmt,CC_TO)+ + ' · 1 '+CC_FROM+' = '+ccyAmt(per,CC_TO)+ccyConvSource(); + out.className='cv-out'; +} + +/** Where the rate being used came from, so a stale one is not read as today's. */ +function ccyConvSource(){ + var manual=FX.manual&&(FX.manual[CC_FROM]>0||FX.manual[CC_TO]>0); + if(manual)return ' · using a rate you set'; + if(CC_FROM==='INR'&&CC_TO==='INR')return ''; + return FX.fetched?(' · rates '+fxAgeText(fxAge())):' · rates not fetched yet'; +} + +/** Reverse the two currencies, carrying the converted amount back as the input. */ +function _ccyConvSwapImpl(){ + var t=CC_FROM; CC_FROM=CC_TO; CC_TO=t; + var fa=el('cc-from-amt'),ta=el('cc-to-amt'); + if(fa&&ta){ var v=ta.value; ta.value=fa.value; fa.value=v; } + if(el('cc-from'))el('cc-from').value=CC_FROM; + if(el('cc-to'))el('cc-to').value=CC_TO; + renderCcyConv('from'); +} + +/** + * Ask for a single line of text. + * + * @param {Object} o + * @param {string} o.title dialog heading + * @param {string} [o.message] explanatory line above the field + * @param {string} [o.label] visible label for the input + * @param {string} [o.value] initial value, selected on open + * @param {string} [o.placeholder] + * @param {string} [o.okLabel] confirm button text + * @param {Function} [o.validate] receives the current value; return null to + * accept, {error:'…'} to block, or {note:'…'} to warn but allow + * @param {boolean} [o.multiline] show a textarea instead of a single line + * @param {boolean} [o.readOnly] present a value to copy rather than to edit + * @param {Function} o.onOk receives the trimmed value + */ +function _askPromptImpl(o){ + o=o||{}; + _promptFn=o.onOk||null; + _promptValidate=o.validate||null; + R('prompt-title',o.title||'Name'); + R('prompt-msg',o.message||''); + var msgEl=el('prompt-msg');if(msgEl)msgEl.style.display=o.message?'':'none'; + var lbl=el('prompt-label');if(lbl)lbl.textContent=o.label||'Name'; + _promptMulti=!!o.multiline; + var single=el('prompt-input'),area=el('prompt-textarea'); + if(single)single.style.display=_promptMulti?'none':''; + if(area)area.style.display=_promptMulti?'':'none'; + var inp=_promptField(); + if(inp){ + inp.value=o.value||''; + if(!_promptMulti){ + inp.placeholder=o.placeholder||''; + inp.setAttribute('maxlength',String(o.maxLength||40)); + inp.readOnly=!!o.readOnly; + } + } + var cancel=el('overlay-prompt')?el('overlay-prompt').querySelector('.confirm-btn:not(.primary)'):null; + if(cancel)cancel.style.display=o.readOnly||o.multiline?'none':''; + var ok=el('prompt-ok');if(ok)ok.textContent=o.okLabel||'Save'; + var ov=el('overlay-prompt'); + if(ov){ + _lastFocused=document.activeElement; + ov.classList.add('open'); + document.body.style.overflow='hidden'; + pushOverlay(ov); + // Select the text so typing replaces it, which is what prompt() did. + setTimeout(function(){if(inp){inp.focus();if(inp.select)inp.select()}},30); + } + validatePrompt(); +} + +/** + * Re-run the validator and reflect it in the hint line and the OK button. + * @returns {boolean} whether the current value may be submitted + */ +function _validatePromptImpl(){ + var inp=_promptField(),ok=el('prompt-ok'),hint=el('prompt-hint'); + if(!inp||!ok)return true; + var v=_promptValidate?_promptValidate(inp.value):null; + var err=v&&v.error,note=v&&v.note; + if(hint){ + hint.textContent=err||note||''; + hint.className='confirm-sub'+(err?' prompt-err':(note?' prompt-note':'')); + } + ok.disabled=!!err; + return !err; +} + +/** Submit the dialog, if the value passes validation. */ +function _runPromptImpl(){ + if(!validatePrompt())return; + var inp=_promptField(); + var val=inp?String(inp.value).trim():''; + var fn=_promptFn; + closePrompt(); + if(fn)guard('prompt callback',function(){fn(val)}); +} + +/** + * Apply a saved preset. Keys are re-validated, since presets live in storage. + * @param {Object} p snapshot from capturePreset + */ +function _applyPresetImpl(p){ + if(!p)return; + INC_KEYS=(p.cpKeys||[]).filter(isValidIncKey); + SP_INC_KEYS=(p.spKeys||[]).filter(isValidIncKey); + if(!INC_KEYS.length)INC_KEYS=['cd','eb','qt','an','sc']; + if(!SP_INC_KEYS.length)SP_INC_KEYS=['cd','eb','qt','an','sc']; + Object.keys(p.labels||{}).forEach(function(k){ + if(isValidIncKey(k))INC_LABELS[k]=String(p.labels[k]); + }); + INC_MODE={};SP_INC_MODE={}; + Object.keys(p.cpModes||{}).forEach(function(k){ if(isValidIncKey(k))INC_MODE[k]=p.cpModes[k]==='abs'?'abs':'pct'; }); + Object.keys(p.spModes||{}).forEach(function(k){ if(isValidIncKey(k))SP_INC_MODE[k]=p.spModes[k]==='abs'?'abs':'pct'; }); + + renderCPIncRows();renderSPIncRows(); + function restore(keys,src,pfx,sync){ + keys.forEach(function(k){ + var e=(src||{})[k]; if(!e)return; + var cb=document.getElementById(pfx.cb+k), iv=document.getElementById(pfx.iv+k); + if(cb)cb.checked=!!e.on; + if(iv&&e.v!=='')iv.value=e.v; + sync(k); + }); + } + restore(INC_KEYS,p.cp,{cb:'it-',iv:'iv-'},syncToggle); + restore(SP_INC_KEYS,p.sp,{cb:'sit-',iv:'siv-'},syncSpToggle); + if(INC_KEYS.indexOf('cd')!==-1)setCDMode(p.cdm==='after'?'after':'before'); + if(INC_KEYS.indexOf('sc')!==-1)setSchemeMode(p.scm==='abs'?'abs':'pct'); + if(SP_INC_KEYS.indexOf('cd')!==-1)setSCDMode(p.scdm==='after'?'after':'before'); + if(SP_INC_KEYS.indexOf('sc')!==-1)setSpSchemeMode(p.sscm==='abs'?'abs':'pct'); + saveLabels();calc(); +} + +/** Draw the rows inside the preset manager. */ +function _renderPresetManagerImpl(){ + var c=el('pm-list'); + if(!c)return; + var names=Object.keys(PRESETS).sort(); + if(!names.length){ + c.innerHTML='

No presets yet. Set the incentives up the way you want them, '+ + 'then use the button above.

'; + return; + } + c.innerHTML=names.map(function(n){ + var e=escHtml(n); + return '
'+ + ''+e+''+ + ''+ + ''+ + ''+ + ''+ + ''+ + '
'; + }).join(''); +} + +/** + * Build the plain-text summary used by copy, WhatsApp and email. + * @returns {string|null} null when CP or SP is missing + */ +function getSummaryText(){ + if(!LAST_CP||!LAST_SP)return null; + var inc=getIncentiveInr(LAST_CP),eff=effectiveCP(LAST_CP); + var spInc=getSPIncentiveInr(LAST_SP),effSP=effectiveSP(LAST_SP); + var pr=effSP-eff; + var gp=(effSP>0)?(pr/effSP)*100:null,mg=(eff>0)?(pr/eff)*100:null; + var lines=['PRICING SUMMARY — '+now(),'─────────────────────────','MRP (incl GST): '+INR(MI),'GST Rate: '+(G*100)+'%','','CP excl GST: '+INR(LAST_CP.e),'CP incl GST: '+INR(LAST_CP.i)]; + if(inc>0){lines.push('CP Incentives: '+CINR(inc));lines.push('Eff. CP excl GST: '+CINR(eff))} + lines.push('','SP excl GST: '+SINR(LAST_SP.e),'SP incl GST: '+SINR(LAST_SP.i)); + if(spInc>0){lines.push('SP Incentives: '+SINR(spInc));lines.push('Eff. SP excl GST: '+SINR(effSP))} + lines.push('','Profit: '+SINR(pr),'GP %: '+PCT(gp),'Markup %: '+PCT(mg),'─────────────────────────'); + return lines.join('\n'); +} + +/** + * Copy the summary, falling back to a dialog when the clipboard is unavailable. + */ +function _copyToClipboardImpl(){ + var text=getSummaryText(); + if(!text){toast('Enter CP and SP first.');return} + navigator.clipboard.writeText(text).then(function(){ + var btn=el('copy-btn');if(!btn)return; + var orig=btn.innerHTML;btn.textContent='✓ Copied!'; + setTimeout(function(){btn.innerHTML=orig},1800); + }).catch(function(e){ + logWarn('clipboard unavailable, falling back to a dialog',e); + askPrompt({title:'Copy summary',message:'The clipboard is unavailable here — select this and copy it.', + label:'Summary',value:text,multiline:true,okLabel:'Done',onOk:function(){}}); + }); +} + +/** + * Open WhatsApp with the summary pre-filled. + */ +function _sendWhatsAppImpl(){ + var text=getSummaryText(); + if(!text){toast('Enter CP and SP first.');return} + window.open('https://wa.me/?text='+encodeURIComponent(text),'_blank'); +} + +/** + * Open the mail client with the summary pre-filled. + */ +function _sendEmailImpl(){ + var text=getSummaryText(); + if(!text){toast('Enter CP and SP first.');return} + window.location.href='mailto:?subject='+encodeURIComponent('Pricing Summary — Sterling Spares')+'&body='+encodeURIComponent(text); +} + +/** + * Print the page using the print stylesheet. + */ +function _exportPDFImpl(){ + if(!LAST_CP||!LAST_SP){toast('Enter CP and SP first.');return} + window.print(); +} + +/** + * Share the current calculation as a URL, via the native share sheet on mobile + * or the clipboard elsewhere. + */ +function _shareLinkImpl(){ + var state=getShareState(); + var encoded; + try{encoded=btoa(unescape(encodeURIComponent(JSON.stringify(state))))} + catch(e){ + // Unicode in a description can break btoa's Latin-1 assumption; retry raw. + logWarn('unicode-safe share encoding failed, retrying plain',e); + encoded=btoa(JSON.stringify(state)); + } + var url=location.href.split('?')[0].split('#')[0]+'?s='+encoded; + + // Use Web Share API on mobile if available + if(navigator.share&&window.innerWidth<=800){ + navigator.share({title:'Pricing Calculation — Sterling Spares',url:url}) + .catch(function(e){ + // Includes the user simply dismissing the sheet, hence warn not error. + logWarn('Web Share dismissed or unavailable, copying instead',e); + copyUrl(url); + }); + return; + } + copyUrl(url); +} diff --git a/assets/app.js b/assets/app.js index 1a33d14..56dd68b 100644 --- a/assets/app.js +++ b/assets/app.js @@ -1202,7 +1202,7 @@ function closeModal(id){ * @param {string} id overlay suffix */ function overlayClick(e,id){if(e.target===el('overlay-'+id))closeModal(id)} -document.addEventListener('keydown',function(e){if(e.key==='Escape'){closeModal('settings');closeModal('whatif');closeModal('quote');closeModal('presets');closeConfirm();closePrompt();closeConvert();closeFab()}}); +document.addEventListener('keydown',function(e){if(e.key==='Escape'){closeModal('settings');closeModal('whatif');closeModal('quote');closeModal('presets');closeConfirm();closePrompt();closeConvert();closeCcyConv();closeTools(true);closeFab()}}); /** * Handler for the custom GST box. Rejects anything outside 0–100 and says so, @@ -1249,12 +1249,17 @@ var FEATURE_DEFS=[ clear:function(){ PRESETS={}; savePresets(); renderPresetList(); renderPresetManager(); }}, {k:'convert',name:'GP / markup converter',hint:'Translate between the two ways of quoting a margin.', - els:['hbtn-convert'], + els:['tool-convert','hmenu-convert'], values:function(){ return [] }, clear:function(){ closeConvert(); }}, + {k:'ccyconv',name:'Currency converter',hint:'Convert an amount between any two currencies.', + els:['tool-ccy','hmenu-ccy'], + values:function(){ return [] }, + clear:function(){ closeCcyConv(); }}, + {k:'quote',name:'Quote builder',hint:'Multi-line quotes with blended GP.', - els:['hbtn-quote','hmenu-quote','bnav-quote'], + els:['tool-quote','hmenu-quote','bnav-quote'], values:function(){ return QUOTE.length?[QUOTE.length+' quote line'+(QUOTE.length===1?'':'s')]:[] }, clear:function(){ QUOTE.length=0; saveQuote(); if(typeof qtRender==='function')qtRender(); closeModal('quote'); }}, @@ -1338,7 +1343,15 @@ function applyFeatureVisibility(){ }); var nInc=el('bnav-inc'); if(nInc)nInc.style.display=(featOn('inccp')||featOn('incsp'))?'':'none'; + // A menu whose every item is switched off is just a dead button. + var tw=el('hbtn-tools-wrap'); + if(tw){ + tw.style.display=anyToolOn()?'':'none'; + if(!anyToolOn())closeTools(); + } } +/** Whether anything is left in the Tools menu. */ +function anyToolOn(){ return featOn('quote')||featOn('convert')||featOn('ccyconv') } /** * Put the app back to how it ships. @@ -1349,27 +1362,10 @@ function applyFeatureVisibility(){ */ var STORAGE_KEYS=['pc-state','pc-history','pc-labels','pc-presets','pc-qstate', 'pc-quote','pc-theme','pc-fx','pc-features','ob-done']; +/** Deferred: the implementation lives in assets/app-extra.js. */ function factoryReset(){ - var held=[]; - if(HISTORY.length)held.push(HISTORY.length+' history entr'+(HISTORY.length===1?'y':'ies')); - var np=Object.keys(PRESETS).length; - if(np)held.push(np+' preset'+(np===1?'':'s')); - if(QUOTE.length)held.push(QUOTE.length+' quote line'+(QUOTE.length===1?'':'s')); - var off=FEATURE_DEFS.filter(function(f){return !featOn(f.k)}).length; - if(off)held.push(off+' switched-off feature'+(off===1?'':'s')); - askConfirm('Reset the app', - held.length?('This will clear '+held.join(', ')+', along with every setting.') - :'This will clear every saved setting and start fresh.', - 'It cannot be undone — undo history goes too.','Reset everything',function(){ - STORAGE_KEYS.forEach(function(k){ - try{ localStorage.removeItem(k) }catch(e){ logError('could not clear '+k,e) } - }); - // Reload rather than unpick the state by hand: every module reads its own - // storage on boot, so a fresh load is the one path guaranteed to agree - // with what a new visitor sees. - try{ location.replace(location.pathname) } - catch(e){ logError('could not reload after reset',e); location.reload() } - }); + if(typeof _factoryResetImpl==='function')return _factoryResetImpl(); + withExtras(function(){ _factoryResetImpl() }); } ACT.factoryReset = function(){ factoryReset() }; @@ -1377,7 +1373,7 @@ ACT.factoryReset = function(){ factoryReset() }; The same profit over two different denominators, which is why a supplier offering "25%" and a customer expecting "25%" can mean different money. GP = profit / selling price - markup = profit / cost price (what this app calls Margin %) + markup = profit / cost price (shown as Markup % on the calculator) so markup = GP / (100 - GP) and GP = markup / (100 + markup). ─────────────────────────────────────────────────────────────────────────── */ /** @@ -1396,38 +1392,10 @@ function markupToGp(mk){ if(isNaN(mk)||mk<=-100)return null; // at -100% markup the sale is zero return (mk/(100+mk))*100; } -/** - * Recompute the other field and the worked line beneath. - * @param {'gp'|'mk'} from which field the user is typing in - */ +/** Deferred: the implementation lives in assets/app-extra.js. */ function renderConvert(from){ - var gpEl=el('cv-gp'), mkEl=el('cv-mk'), out=el('cv-out'); - if(!gpEl||!mkEl||!out)return; - var raw=(from==='gp'?gpEl:mkEl).value; - if(String(raw).trim()===''){ - (from==='gp'?mkEl:gpEl).value=''; - out.textContent='';out.className='cv-out'; - return; - } - var v=parseFloat(raw); - var other=(from==='gp')?gpToMarkup(v):markupToGp(v); - if(other===null){ - (from==='gp'?mkEl:gpEl).value=''; - out.textContent=(from==='gp') - ? 'A GP of 100% or more would mean the goods cost nothing — there is no markup that matches.' - : 'A markup of −100% or less would mean selling for nothing — there is no GP that matches.'; - out.className='cv-out bad'; - return; - } - (from==='gp'?mkEl:gpEl).value=String(+other.toFixed(4)); - // Ground it in money: percentages either way are easy to nod along to. - var gp=(from==='gp')?v:other; - var cost=100, sale=(gp>=100)?null:(cost/(1-gp/100)); - if(sale===null||!isFinite(sale)){ out.textContent='';out.className='cv-out'; return } - out.textContent='Buy at '+INR_RS(cost)+', sell at '+INR_RS(sale)+' — profit '+ - INR_RS(sale-cost)+', which is '+PCT(gp)+' of the sale and '+ - PCT((from==='gp')?other:v)+' of the cost.'; - out.className='cv-out'; + if(typeof _renderConvertImpl==='function')return _renderConvertImpl(from); + withExtras(function(){ _renderConvertImpl(from) }); } /** Open the converter, seeded from the calculation on screen when there is one. */ function openConvert(){ @@ -1451,14 +1419,10 @@ function closeConvert(){ if(_lastFocused&&_lastFocused.focus)_lastFocused.focus(); } } -/** Pull the GP the calculator is currently showing into the converter. */ +/** Deferred: the implementation lives in assets/app-extra.js. */ function convertUseCurrent(){ - if(!LAST_CP||!LAST_SP)return; - var effSP=effectiveSP(LAST_SP), effCP=effectiveCP(LAST_CP); - if(!effSP||effSP<=0)return; - var gp=((effSP-effCP)/effSP)*100; - var f=el('cv-gp'); - if(f){ f.value=String(+gp.toFixed(4)); renderConvert('gp'); } + if(typeof _convertUseCurrentImpl==='function')return _convertUseCurrentImpl(); + withExtras(function(){ _convertUseCurrentImpl() }); } ACT.openConvert = function(){ openConvert() }; ACT.convertClose = function(){ closeConvert() }; @@ -1467,6 +1431,118 @@ ACT.convertFromGp = function(){ renderConvert('gp') }; ACT.convertFromMk = function(){ renderConvert('mk') }; ACT.convertUseCurrent = function(){ convertUseCurrent() }; +/* ── Tools menu ───────────────────────────────────────────────────────────── + The quote builder and the two converters were three separate header buttons + competing with Share, Save, Copy, PDF and Presets for the same row. They are + one menu now. It is a disclosure, not an ARIA menu: the items are ordinary + buttons that Tab reaches while the panel is open, which needs no roving + tabindex and behaves the way the hamburger already does. + ─────────────────────────────────────────────────────────────────────────── */ +/** Open or close the Tools menu. */ +function toggleTools(){ + var m=el('tools-menu'); + if(!m)return; + m.classList.contains('open')?closeTools():openTools(); +} +/** Open it, and point the button's aria-expanded at the truth. */ +function openTools(){ + var m=el('tools-menu'),b=el('hbtn-tools'); + if(!m)return; + m.classList.add('open'); + if(b)b.setAttribute('aria-expanded','true'); +} +/** + * Close it. + * @param {boolean} [restoreFocus] send focus back to the button — right after + * Escape, wrong after a click that opened a dialog. + */ +function closeTools(restoreFocus){ + var m=el('tools-menu'),b=el('hbtn-tools'); + if(!m||!m.classList.contains('open'))return; + m.classList.remove('open'); + if(b){ + b.setAttribute('aria-expanded','false'); + if(restoreFocus&&b.focus)b.focus(); + } +} +// Clicking anywhere else, or pressing Escape, dismisses it. +document.addEventListener('click',function(e){ + var w=el('hbtn-tools-wrap'); + if(w&&!w.contains(e.target))closeTools(); +}); +ACT.toolsToggle = function(){ toggleTools() }; +ACT.toolQuote = function(){ closeTools(); closeHMenu(); openModal('quote') }; +ACT.toolConvert = function(){ closeTools(); closeHMenu(); openConvert() }; +ACT.toolCcy = function(){ closeTools(); closeHMenu(); openCcyConv() }; + +/* ── Currency converter ───────────────────────────────────────────────────── + Separate from the display-currency setting on purpose: that one restates the + whole calculation, and people kept wanting to check one number without + disturbing it. Both read the same rates. + ─────────────────────────────────────────────────────────────────────────── */ +var CC_FROM='USD',CC_TO='INR'; + + + +/** Fill both pickers with every currency the app knows. */ +function fillCcyConvSelects(){ + ['cc-from','cc-to'].forEach(function(id){ + var sel=el(id); + if(!sel||sel.options.length)return; + var html=''; + CURRENCIES.forEach(function(x){ html+='' }); + sel.innerHTML=html; + }); + // Assigning .value before the options exist is a silent no-op, so this has to + // come after the fill. + if(el('cc-from'))el('cc-from').value=CC_FROM; + if(el('cc-to'))el('cc-to').value=CC_TO; +} +/** Deferred: the implementation lives in assets/app-extra.js. */ +function renderCcyConv(side){ + if(typeof _renderCcyConvImpl==='function')return _renderCcyConvImpl(side); + withExtras(function(){ _renderCcyConvImpl(side) }); +} + +/** Deferred: the implementation lives in assets/app-extra.js. */ +function ccyConvSwap(){ + if(typeof _ccyConvSwapImpl==='function')return _ccyConvSwapImpl(); + withExtras(function(){ _ccyConvSwapImpl() }); +} +/** Open the currency converter. */ +function openCcyConv(){ + if(!featOn('ccyconv'))return; + var o=el('overlay-ccyconv'); + if(!o)return; + _lastFocused=document.activeElement; + fillCcyConvSelects(); + o.classList.add('open'); + document.body.style.overflow='hidden'; + pushOverlay(o); + renderCcyConv('from'); + // Rates are only fetched when a foreign currency is first needed, and picking + // one here counts. + if(fxRate(CC_FROM)===null||fxRate(CC_TO)===null)fetchRates(true); + setTimeout(function(){ var f=el('cc-from-amt'); if(f){f.focus();if(f.select)f.select()} },30); +} +/** Close it. */ +function closeCcyConv(){ + var o=el('overlay-ccyconv'); + if(o&&o.classList.contains('open')){ + o.classList.remove('open'); + popOverlay(o); + if(_lastFocused&&_lastFocused.focus)_lastFocused.focus(); + } +} +ACT.ccyConvOverlay = function(self,event){ if(event.target===el('overlay-ccyconv'))closeCcyConv() }; +ACT.ccyConvClose = function(){ closeCcyConv() }; +ACT.ccyConvFromAmt = function(){ renderCcyConv('from') }; +ACT.ccyConvToAmt = function(){ renderCcyConv('to') }; +ACT.ccyConvFrom = function(self){ CC_FROM=self.value; renderCcyConv('from') }; +ACT.ccyConvTo = function(self){ CC_TO=self.value; renderCcyConv('from') }; +ACT.ccyConvSwap = function(){ ccyConvSwap() }; +ACT.ccyConvRefresh = function(){ fetchRates(false).then(function(){ renderCcyConv('from') }) }; + /* ── Settings tabs ────────────────────────────────────────────────────────── Eight stacked sections became a long scroll that was hard to find anything in. They are grouped into four panes behind a nav rail, which becomes a @@ -1780,81 +1856,20 @@ function askConfirm(title,msg,sub,btnLabel,fn){ var _promptFn=null,_promptValidate=null,_promptMulti=false; /** The field currently in use — single line or textarea. */ function _promptField(){return _promptMulti?el('prompt-textarea'):el('prompt-input')} -/** - * Ask for a single line of text. - * - * @param {Object} o - * @param {string} o.title dialog heading - * @param {string} [o.message] explanatory line above the field - * @param {string} [o.label] visible label for the input - * @param {string} [o.value] initial value, selected on open - * @param {string} [o.placeholder] - * @param {string} [o.okLabel] confirm button text - * @param {Function} [o.validate] receives the current value; return null to - * accept, {error:'…'} to block, or {note:'…'} to warn but allow - * @param {boolean} [o.multiline] show a textarea instead of a single line - * @param {boolean} [o.readOnly] present a value to copy rather than to edit - * @param {Function} o.onOk receives the trimmed value - */ +/** Deferred: the implementation lives in assets/app-extra.js. */ function askPrompt(o){ - o=o||{}; - _promptFn=o.onOk||null; - _promptValidate=o.validate||null; - R('prompt-title',o.title||'Name'); - R('prompt-msg',o.message||''); - var msgEl=el('prompt-msg');if(msgEl)msgEl.style.display=o.message?'':'none'; - var lbl=el('prompt-label');if(lbl)lbl.textContent=o.label||'Name'; - _promptMulti=!!o.multiline; - var single=el('prompt-input'),area=el('prompt-textarea'); - if(single)single.style.display=_promptMulti?'none':''; - if(area)area.style.display=_promptMulti?'':'none'; - var inp=_promptField(); - if(inp){ - inp.value=o.value||''; - if(!_promptMulti){ - inp.placeholder=o.placeholder||''; - inp.setAttribute('maxlength',String(o.maxLength||40)); - inp.readOnly=!!o.readOnly; - } - } - var cancel=el('overlay-prompt')?el('overlay-prompt').querySelector('.confirm-btn:not(.primary)'):null; - if(cancel)cancel.style.display=o.readOnly||o.multiline?'none':''; - var ok=el('prompt-ok');if(ok)ok.textContent=o.okLabel||'Save'; - var ov=el('overlay-prompt'); - if(ov){ - _lastFocused=document.activeElement; - ov.classList.add('open'); - document.body.style.overflow='hidden'; - pushOverlay(ov); - // Select the text so typing replaces it, which is what prompt() did. - setTimeout(function(){if(inp){inp.focus();if(inp.select)inp.select()}},30); - } - validatePrompt(); + if(typeof _askPromptImpl==='function')return _askPromptImpl(o); + withExtras(function(){ _askPromptImpl(o) }); } -/** - * Re-run the validator and reflect it in the hint line and the OK button. - * @returns {boolean} whether the current value may be submitted - */ +/** Deferred: the implementation lives in assets/app-extra.js. */ function validatePrompt(){ - var inp=_promptField(),ok=el('prompt-ok'),hint=el('prompt-hint'); - if(!inp||!ok)return true; - var v=_promptValidate?_promptValidate(inp.value):null; - var err=v&&v.error,note=v&&v.note; - if(hint){ - hint.textContent=err||note||''; - hint.className='confirm-sub'+(err?' prompt-err':(note?' prompt-note':'')); - } - ok.disabled=!!err; - return !err; + if(typeof _validatePromptImpl==='function')return _validatePromptImpl(); + withExtras(function(){ _validatePromptImpl() }); } -/** Submit the dialog, if the value passes validation. */ +/** Deferred: the implementation lives in assets/app-extra.js. */ function runPrompt(){ - if(!validatePrompt())return; - var inp=_promptField(); - var val=inp?String(inp.value).trim():''; - var fn=_promptFn; - closePrompt(); - if(fn)guard('prompt callback',function(){fn(val)}); + if(typeof _runPromptImpl==='function')return _runPromptImpl(); + withExtras(function(){ _runPromptImpl() }); } /** Dismiss without submitting. */ function closePrompt(){ @@ -2064,7 +2079,7 @@ var UNDO_FIELD_NAMES={ mrp:'MRP', cpd:'cost discount', cpv:'cost price', spd:'sale discount', spv:'selling price', pri:'target profit', qty:'quantity', landed:'inbound landed cost', 'sp-landed':'outbound landed cost', - 'floor-gp':'GP floor', 'floor-mg':'margin floor', 'gst-custom':'GST rate', + 'floor-gp':'GP floor', 'floor-mg':'markup floor', 'gst-custom':'GST rate', 'rnd-custom':'rounding step', 'fx-manual':'exchange rate', 'ccy-select':'display currency', 'fx-scope':'currency scope' }; @@ -2174,7 +2189,7 @@ function gpCls(gp,floor){ return gp>=0?'pos':'neg'; } /** - * CSS class for a Margin% figure. Mirrors gpCls against the margin floor. + * CSS class for a Markup% figure. Mirrors gpCls against the markup floor. * @param {number|null} mg * @param {{gp:number|null,mg:number|null}} floor * @returns {string} @@ -3090,40 +3105,10 @@ function capturePreset(){ }; } -/** - * Apply a saved preset. Keys are re-validated, since presets live in storage. - * @param {Object} p snapshot from capturePreset - */ +/** Deferred: the implementation lives in assets/app-extra.js. */ function applyPreset(p){ - if(!p)return; - INC_KEYS=(p.cpKeys||[]).filter(isValidIncKey); - SP_INC_KEYS=(p.spKeys||[]).filter(isValidIncKey); - if(!INC_KEYS.length)INC_KEYS=['cd','eb','qt','an','sc']; - if(!SP_INC_KEYS.length)SP_INC_KEYS=['cd','eb','qt','an','sc']; - Object.keys(p.labels||{}).forEach(function(k){ - if(isValidIncKey(k))INC_LABELS[k]=String(p.labels[k]); - }); - INC_MODE={};SP_INC_MODE={}; - Object.keys(p.cpModes||{}).forEach(function(k){ if(isValidIncKey(k))INC_MODE[k]=p.cpModes[k]==='abs'?'abs':'pct'; }); - Object.keys(p.spModes||{}).forEach(function(k){ if(isValidIncKey(k))SP_INC_MODE[k]=p.spModes[k]==='abs'?'abs':'pct'; }); - - renderCPIncRows();renderSPIncRows(); - function restore(keys,src,pfx,sync){ - keys.forEach(function(k){ - var e=(src||{})[k]; if(!e)return; - var cb=document.getElementById(pfx.cb+k), iv=document.getElementById(pfx.iv+k); - if(cb)cb.checked=!!e.on; - if(iv&&e.v!=='')iv.value=e.v; - sync(k); - }); - } - restore(INC_KEYS,p.cp,{cb:'it-',iv:'iv-'},syncToggle); - restore(SP_INC_KEYS,p.sp,{cb:'sit-',iv:'siv-'},syncSpToggle); - if(INC_KEYS.indexOf('cd')!==-1)setCDMode(p.cdm==='after'?'after':'before'); - if(INC_KEYS.indexOf('sc')!==-1)setSchemeMode(p.scm==='abs'?'abs':'pct'); - if(SP_INC_KEYS.indexOf('cd')!==-1)setSCDMode(p.scdm==='after'?'after':'before'); - if(SP_INC_KEYS.indexOf('sc')!==-1)setSpSchemeMode(p.sscm==='abs'?'abs':'pct'); - saveLabels();calc(); + if(typeof _applyPresetImpl==='function')return _applyPresetImpl(p); + withExtras(function(){ _applyPresetImpl(p) }); } /** Repaint the preset dropdown from PRESETS. */ @@ -3241,27 +3226,10 @@ function deletePreset(name){ }); } -/** Draw the rows inside the preset manager. */ +/** Deferred: the implementation lives in assets/app-extra.js. */ function renderPresetManager(){ - var c=el('pm-list'); - if(!c)return; - var names=Object.keys(PRESETS).sort(); - if(!names.length){ - c.innerHTML='

No presets yet. Set the incentives up the way you want them, '+ - 'then use the button above.

'; - return; - } - c.innerHTML=names.map(function(n){ - var e=escHtml(n); - return '
'+ - ''+e+''+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
'; - }).join(''); + if(typeof _renderPresetManagerImpl==='function')return _renderPresetManagerImpl(); + withExtras(function(){ _renderPresetManagerImpl() }); } /** Open the preset manager. */ @@ -3639,7 +3607,7 @@ function fillSP(sp){ } } /** - * Write profit, GP% and Margin% into the profit card with floor colouring. + * Write profit, GP% and Markup% into the profit card with floor colouring. * @param {number|null} effCPE effective CP excl GST * @param {number|null} spe effective SP excl GST */ @@ -3685,6 +3653,14 @@ function rowSet(id,val,cls){var e=el(id);if(!e)return;e.textContent=val;e.classN * @param {{e:number,i:number}|null} sp */ function fillSummary(cp,sp){ + /* Published here rather than only at the end of calc(). renderSolver runs + from this function and reads these two, so assigning them afterwards meant + the first calculation of a session solved against the previous (null) + prices — the solver answered "Enter MRP, CP and SP first" with every box + already filled, and only came right on the next keystroke. Every + fillSummary call site passes exactly what calc() assigns at the end, so + this is the same value, earlier. */ + LAST_CP=cp||null;LAST_SP=sp||null; // MRP, CP excl, SP excl and the two discount percentages used to be repeated // here; they sit in the cards directly above, so the summary now carries only // what the cards do not. @@ -3767,11 +3743,11 @@ function updateA11yStatus(pr,gp,mg){ msg=''; }else{ var floor=getFloor(); - msg='Profit '+SINR(pr)+', GP '+PCT(gp)+', Margin '+PCT(mg); + msg='Profit '+SINR(pr)+', GP '+PCT(gp)+', Markup '+PCT(mg); var q=getQty(); if(q>1)msg+='. Total for '+q+' units '+SINR(pr*q); if(belowFloor(gp,floor.gp))msg+='. Warning: GP is below your floor'; - if(belowFloor(mg,floor.mg))msg+='. Warning: Margin is below your floor'; + if(belowFloor(mg,floor.mg))msg+='. Warning: Markup is below your floor'; } if(msg!==_a11yLast){_a11yLast=msg;node.textContent=msg} },700); @@ -3980,7 +3956,7 @@ function renderHistory(){ +'SP excl'+SINR(h.spE)+'' +'Profit'+SINR(h.pr)+'' +'GP %'+PCT(h.gp)+'' - +'Margin %'+PCT(h.mg)+'' + +'Markup %'+PCT(h.mg)+'' +'' +(h.incInr>0?'
Inc'+CINR(h.incInr)+'
':'') +'' @@ -4010,61 +3986,26 @@ var COMPARE_IDX=null; * Draw the current-vs-saved comparison table with per-row deltas. */ -/** - * Build the plain-text summary used by copy, WhatsApp and email. - * @returns {string|null} null when CP or SP is missing - */ -function getSummaryText(){ - if(!LAST_CP||!LAST_SP)return null; - var inc=getIncentiveInr(LAST_CP),eff=effectiveCP(LAST_CP); - var spInc=getSPIncentiveInr(LAST_SP),effSP=effectiveSP(LAST_SP); - var pr=effSP-eff; - var gp=(effSP>0)?(pr/effSP)*100:null,mg=(eff>0)?(pr/eff)*100:null; - var lines=['PRICING SUMMARY — '+now(),'─────────────────────────','MRP (incl GST): '+INR(MI),'GST Rate: '+(G*100)+'%','','CP excl GST: '+INR(LAST_CP.e),'CP incl GST: '+INR(LAST_CP.i)]; - if(inc>0){lines.push('CP Incentives: '+CINR(inc));lines.push('Eff. CP excl GST: '+CINR(eff))} - lines.push('','SP excl GST: '+SINR(LAST_SP.e),'SP incl GST: '+SINR(LAST_SP.i)); - if(spInc>0){lines.push('SP Incentives: '+SINR(spInc));lines.push('Eff. SP excl GST: '+SINR(effSP))} - lines.push('','Profit: '+SINR(pr),'GP %: '+PCT(gp),'Margin %: '+PCT(mg),'─────────────────────────'); - return lines.join('\n'); -} -/** - * Copy the summary, falling back to a dialog when the clipboard is unavailable. - */ + +/** Deferred: the implementation lives in assets/app-extra.js. */ function copyToClipboard(){ - var text=getSummaryText(); - if(!text){toast('Enter CP and SP first.');return} - navigator.clipboard.writeText(text).then(function(){ - var btn=el('copy-btn');if(!btn)return; - var orig=btn.innerHTML;btn.textContent='✓ Copied!'; - setTimeout(function(){btn.innerHTML=orig},1800); - }).catch(function(e){ - logWarn('clipboard unavailable, falling back to a dialog',e); - askPrompt({title:'Copy summary',message:'The clipboard is unavailable here — select this and copy it.', - label:'Summary',value:text,multiline:true,okLabel:'Done',onOk:function(){}}); - }); + if(typeof _copyToClipboardImpl==='function')return _copyToClipboardImpl(); + withExtras(function(){ _copyToClipboardImpl() }); } -/** - * Open WhatsApp with the summary pre-filled. - */ +/** Deferred: the implementation lives in assets/app-extra.js. */ function sendWhatsApp(){ - var text=getSummaryText(); - if(!text){toast('Enter CP and SP first.');return} - window.open('https://wa.me/?text='+encodeURIComponent(text),'_blank'); + if(typeof _sendWhatsAppImpl==='function')return _sendWhatsAppImpl(); + withExtras(function(){ _sendWhatsAppImpl() }); } -/** - * Open the mail client with the summary pre-filled. - */ +/** Deferred: the implementation lives in assets/app-extra.js. */ function sendEmail(){ - var text=getSummaryText(); - if(!text){toast('Enter CP and SP first.');return} - window.location.href='mailto:?subject='+encodeURIComponent('Pricing Summary — Sterling Spares')+'&body='+encodeURIComponent(text); + if(typeof _sendEmailImpl==='function')return _sendEmailImpl(); + withExtras(function(){ _sendEmailImpl() }); } -/** - * Print the page using the print stylesheet. - */ +/** Deferred: the implementation lives in assets/app-extra.js. */ function exportPDF(){ - if(!LAST_CP||!LAST_SP){toast('Enter CP and SP first.');return} - window.print(); + if(typeof _exportPDFImpl==='function')return _exportPDFImpl(); + withExtras(function(){ _exportPDFImpl() }); } /* ── Main calc ── */ @@ -5082,32 +5023,10 @@ function applyShareState(raw){ }catch(e){ logError('could not apply shared/saved state — some fields may be unset',e) } } -/** - * Share the current calculation as a URL, via the native share sheet on mobile - * or the clipboard elsewhere. - */ +/** Deferred: the implementation lives in assets/app-extra.js. */ function shareLink(){ - var state=getShareState(); - var encoded; - try{encoded=btoa(unescape(encodeURIComponent(JSON.stringify(state))))} - catch(e){ - // Unicode in a description can break btoa's Latin-1 assumption; retry raw. - logWarn('unicode-safe share encoding failed, retrying plain',e); - encoded=btoa(JSON.stringify(state)); - } - var url=location.href.split('?')[0].split('#')[0]+'?s='+encoded; - - // Use Web Share API on mobile if available - if(navigator.share&&window.innerWidth<=800){ - navigator.share({title:'Pricing Calculation — Sterling Spares',url:url}) - .catch(function(e){ - // Includes the user simply dismissing the sheet, hence warn not error. - logWarn('Web Share dismissed or unavailable, copying instead',e); - copyUrl(url); - }); - return; - } - copyUrl(url); + if(typeof _shareLinkImpl==='function')return _shareLinkImpl(); + withExtras(function(){ _shareLinkImpl() }); } /** @@ -5232,6 +5151,9 @@ document.addEventListener('keydown',function(e){ case 'q': case 'Q': setMode(APP_MODE==='default'?'quick':'default'); break; case 'm': case 'M': if(featOn('quote'))openModal('quote'); break; case 'e': case 'E': if(featOn('presets'))openPresetManager(); break; + case 't': case 'T': if(anyToolOn()){openTools(); var ft=el('tool-quote'); + var f=el('tools-menu')?focusablesIn(el('tools-menu')):[]; + if(f.length)f[0].focus(); else if(ft)ft.focus()} break; case '1': setGST(18); break; case '2': setGST(5); break; case 'p': case 'P': setT('profit'); break; @@ -5261,9 +5183,9 @@ var OB_STEPS=[ body:'Your supplier also gives you money that never appears on the invoice — a cash discount for paying early, a quarterly or annual rebate, a scheme. Switch those on under Incentives on CP and your real cost drops. Anything you pass on to your own customer goes under Incentives on SP.', tip:'On the example, a 2% cash discount and 1% early-bird turn 150 of profit into 168.'}, - {icon:'⚖️',iconBg:'var(--green-bg)',title:'GP % and Margin % are not the same', - body:'GP % is profit as a share of what you sell for. Margin % is profit as a share of what it cost you. The same deal reads 20.00% GP and 25.00% margin — so it is worth being sure which one your supplier means.', - tip:'Margin % is what a finance textbook calls markup. It is always the larger number.'}, + {icon:'⚖️',iconBg:'var(--green-bg)',title:'GP % and Markup % are not the same', + body:'GP % is profit as a share of what you sell for. Markup % is profit as a share of what it cost you. The same deal reads 20.00% GP and 25.00% markup — so it is worth being sure which one your supplier means.', + tip:'Markup is always the larger of the two. Some trades say "margin" when they mean this one, so it is worth asking.'}, {icon:'🌍',iconBg:'var(--surface2)',title:'Your currency, your tax rate', body:'GST is one tap at 18% or 5%, but any rate from 0 to 100% works — VAT at 20% behaves identically. Under Show you can put the cost side, the sale side, or both into another currency, which is how an importer or exporter prices a deal.', diff --git a/assets/styles.css b/assets/styles.css index 6153ae1..2a8bde0 100644 --- a/assets/styles.css +++ b/assets/styles.css @@ -160,10 +160,7 @@ body{font-family:var(--font-body);background:var(--bg);color:var(--text);min-hei .field input{border:none;outline:none;background:transparent;padding:0 10px;height:38px;font-size:15px;font-family:var(--font-mono);font-weight:500;color:var(--text);width:100%;min-width:0} .field-next{display:none;flex-shrink:0;width:30px;height:30px;border-radius:50%;border:none;background:var(--accent);color:var(--accent-fg);cursor:pointer;margin-right:4px;align-items:center;justify-content:center;transition:opacity .15s;opacity:0.7} .field-next:hover{opacity:1} -/* "% on MRP + 18% GST" on one line would take a third of the field. Wrapped to - two it still clears the 38px row, and it balances the two-line mode tabs - directly above. */ -.field .field-suf{padding:0 10px;font-size:12px;font-weight:500;color:var(--text3);border-left:1px solid var(--border);height:38px;display:flex;align-items:center;text-align:right;line-height:1.2;max-width:86px;background:var(--surface2);flex-shrink:0} +.field .field-suf{padding:0 10px;font-size:12px;font-weight:500;color:var(--text3);border-left:1px solid var(--border);height:38px;display:flex;align-items:center;white-space:nowrap;background:var(--surface2);flex-shrink:0} /* The hint is not the data — at the input's own size it would not fit what is left of a narrow field. */ .field input::placeholder{font-family:var(--font-body);font-size:12.5px} @@ -497,6 +494,11 @@ html[data-theme="dark"] .hist-del-btn:hover{background:rgba(239,68,68,0.15);bord .ob-tip{font-size:11.5px;color:var(--text2);text-align:center;background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:10px 14px;line-height:1.5} .hmenu-dropdown{display:none;position:absolute;right:0;top:calc(100% + 8px);background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-modal);min-width:160px;overflow:hidden;z-index:400} +/* The Tools menu reuses the hamburger's dropdown, but hangs off a button that + sits mid-row rather than at the right edge of the header. */ +.tools-wrap{position:relative;display:inline-flex} +.tools-menu{left:0;right:auto;min-width:196px;text-align:left} +.hbtn-caret{margin-left:1px;opacity:.75} .hmenu-dropdown.open{display:block;animation:modalIn .15s ease} .hmenu-item{display:flex;align-items:center;gap:10px;padding:11px 16px;font-size:13px;font-weight:500;color:var(--text);cursor:pointer;font-family:var(--font-body);border:none;background:none;width:100%;text-align:left;transition:background .12s} .hmenu-item:hover{background:var(--surface2)} @@ -884,6 +886,22 @@ html[data-theme="dark"] .lbl-field:focus-within{box-shadow:0 0 0 3px rgba(240,23 .cv-input::after{content:'%';font-size:12px;color:var(--text3);margin-left:4px} .cv-hint{font-size:10.5px;color:var(--text3);line-height:1.4} .cv-swap{align-self:center;margin-top:14px;font-size:16px;color:var(--text3);flex-shrink:0} +/* Currency converter: same two-field shape, but each side carries a currency + picker instead of the fixed "%" the GP converter appends. */ +/* Amounts here run long — ₹20,833.33 against a GP figure's "25" — so the + currency converter's boxes take a smaller size than the GP one's. */ +.cv-input.cc-input::after{content:none} +.cc-input input{font-size:15px} +/* 400px is right for a confirmation. This one carries two currency pickers + and two amounts, and ₹20,833.33 was being cut off at the last digit. */ +.cc-modal{max-width:500px} +.cv-ccy{border:none;background:transparent;font-family:var(--font-body);font-size:12px;font-weight:600; + color:var(--text2);outline:none;cursor:pointer;padding:0 8px 0 0;margin-right:8px; + border-right:1px solid var(--border);align-self:stretch} +.cv-swap-btn{background:none;border:1px solid var(--border-ctrl);border-radius:50%;width:30px;height:30px; + display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:15px; + color:var(--text2);font-family:var(--font-body);transition:all .15s;padding:0} +.cv-swap-btn:hover{border-color:var(--text2);color:var(--text)} .cv-out{font-size:11.5px;line-height:1.55;color:var(--text2);min-height:34px;margin:14px 0 0} .cv-out.bad{color:var(--amber)} .feat-intro{font-size:12px;color:var(--text2);line-height:1.55;margin:0 0 12px} @@ -988,6 +1006,7 @@ html[data-theme="dark"] .qt-del:hover{background:rgba(239,68,68,0.15)} .control-bar .divider{display:none} .cv-pair{flex-direction:column;gap:14px} .cv-swap{align-self:flex-start;margin-top:0;transform:rotate(90deg)} + .cv-swap-btn{width:44px;height:44px} .cv-input input{min-height:44px} .solver{grid-column:1/-1;padding-top:10px;border-top:1px solid rgba(255,255,255,0.16)} .fx-note{white-space:normal;width:100%} @@ -1048,6 +1067,24 @@ html[data-theme="dark"] .qt-del:hover{background:rgba(239,68,68,0.15)} .sum-lbl{font-size:10.5px} } +/* ── NARROW PHONES (must come after the mobile block) ── + "% on MRP + 18% GST" stays on one line — the input beside it never holds + more than a couple of digits — but on a 320px screen the label and the + prefix together leave it nothing. Both step down to the 10.5px floor here, + and only here. */ +@media(max-width:380px){ + /* No amount of trimming fits an 18-character label, a prefix, a number and a + next button across 264px. The label drops to its own row underneath + instead — still one line, and the input gets the width back. */ + .field{flex-wrap:wrap} + /* width:100% would claim a whole row for the input alone; it has to share the + first one with the prefix and the next button. */ + .field input{width:auto;flex:1 1 60px} + .field .field-suf{order:9;flex:0 0 100%;height:auto;padding:5px 10px; + justify-content:flex-end;border-left:none;border-top:1px solid var(--border)} + .field .sym{padding:0 8px} +} + /* ── MOTION ── One easing scale so movement feels consistent. --ease-spring overshoots slightly, which reads as physical on elements that travel (modals, toast, diff --git a/docs/screenshot-mobile.png b/docs/screenshot-mobile.png index a62910f..7b53cca 100644 Binary files a/docs/screenshot-mobile.png and b/docs/screenshot-mobile.png differ diff --git a/docs/screenshot.png b/docs/screenshot.png index acd6a80..9d181fe 100644 Binary files a/docs/screenshot.png and b/docs/screenshot.png differ diff --git a/index.html b/index.html index d0e237c..5c16730 100644 --- a/index.html +++ b/index.html @@ -106,14 +106,28 @@

Price Calc

Presets - - +
+ +
+ + + +
+
+ +
- +
- Min Margin % + Min Markup %
- + %
@@ -976,6 +998,45 @@ + + +