Bubble tea fresh-fruit ordering calculator (single-file tool) - demand derived from sales via per-cup recipe amounts, waste rate from this store's own history only, output as a range with both price tags
You are a coding agent building an internal tool for a
bubble tea shop. Build a single-file HTML tool (HTML/
CSS/JS all inline, no external dependencies, no network
requests, opens by double-click) that calculates
fresh-fruit order quantities for the buyer.
Business logic (build this in):
- Demand = projected cups x per-cup fruit amount x
(1 + waste rate)
- Projected cups extrapolate from the last 14 days of
per-drink sales, adjustable by coefficients:
weather (cooling/warming), promotions, weekday vs
weekend
- Waste rate recognizes only this store's history:
entering the last few counts' fruit waste figures
computes it automatically; with no history the field
stays empty for the buyer to fill with a number
they accept ownership of - the tool must not ship
a preset "industry waste rate"
- Output a range, never a single value: a
conservative column (low coefficients) and an
aggressive column (high coefficients) side by side,
each carrying its own cost - stockout-risk days and
estimated scrap value
Input section:
- Fruit-tea menu: drink name / per-cup amount of each
fruit in grams (from the recipe card)
- Last 14 days of sales per drink (manual entry, or
paste a column of text and parse it)
- Per fruit: current stock, inbound quantity (ordered,
not arrived), supplier lead time in days (including
the worst historical one)
- Next-3-day factors: one slider per factor (-30% to
+30%), default 0, labeled beside the slider
- Waste rate: auto-computed from this store's history,
or entered manually
Output section:
- One row per fruit: projected demand range /
suggested order range / days of coverage after
arrival / stockout-risk days / estimated scrap
value (conservative and aggressive side by side)
- The combined effect of all coefficients shown above
the results: what was adjusted and how much the
output moved, checkable at a glance
- "Export order sheet" button: plain text, converted
into the supplier's usual case/pack units, with the
conversion rule (kg per case) entered by the user
in settings
Constraints:
- No network calls, no accounts - data in
localStorage, with plain-text export/import for
backup
- No built-in default sales, default waste rate, or
default pack sizes - first open shows empty inputs;
do not decorate with sample data
- The calculation must be visible on the page
(collapsible is fine): every number traceable to
its source - nobody dares order from a black box
Why it is written this way
"Range plus two price tags" is the core design. Ordering is fundamentally choosing a side between stockout loss and scrap loss, and the right answer differs completely between two shops (a mature location fears stockouts, a new one fears waste). A tool that outputs one number has hidden that decision inside its algorithm; two columns with prices attached let the buyer choose while seeing "the aggressive column scraps roughly this much more, the conservative column risks two more stockout days" - and if the choice turns out wrong, at least they know which lever was wrong.
The waste rate accepts only this store's history because fruit waste is driven mostly by this store's own cutting skill and shelf-life discipline; an industry average is meaningless for a single shop and grants false confidence. The spread between shops can reach "industry 10%, this store 25%" - ordering by the industry number means daily stockouts; ordering by your own number is the only thing that deserves to be called a calculation. When history is absent, the empty field forces the buyer to own the number they type.
Showing every coefficient's effect beside the result addresses the first question of every post-mortem: "how did we calculate it that day?" Sliders get dragged and forgotten - the classic trap of manual estimation. Pinning the combined effect of each adjustment next to the output keeps the reasoning behind the order explainable three days later.
A visible calculation (collapsible is fine) is a matter of trust: these numbers convert directly into a purchase order for real money, and nobody dares order from a black box. Being able to open "lemon demand = ~620 cups x 35 g x 1.15" is what gets the tool actually used.
Variables
| Variable | Notes |
|---|---|
| Per-cup fruit amounts | Recipe-card grams per cup (lemon by slice weight, mango by flesh grams) - the conversion basis of the whole calculation; update when the recipe changes |
| Store waste rate | Auto-computed from recent counts, or a number the buyer owns - responsible only to this store's history, never copied from any industry source |
| Pack conversion | The supplier's usual case/pack sizes (kg per case) used when exporting the order sheet; one wrong conversion invalidates the entire sheet |