Small tool
Candied fruit quote calculator
A small quoting tool for selling candied fruit and osmanthus jam. Paste in a customer's message and it works out which products they want, how much, and which province it ships to, adds up the goods and shipping, then writes two texts — a quote for the customer and an order for the supplier. The whole tool is one web page that runs offline in the browser.
Overview
- Understands how customers actually write — "2 jin", "half a jin", "one and a half jin", "two jars", "x2" — and when someone only says "plum", it lists the kinds to choose from instead of guessing
- Shipping by destination province (first kilo, each extra kilo, free over a set amount), with a warning for regions it doesn't ship to; anything misread can be fixed in the table
- 177 focused test cases plus 1,000 ordinary and 2,000 "hard" random messages (typos, a category first and the flavour later, chatty filler and full-width digits), all recognised correctly
- Promotional discounts apply to the goods subtotal, with shipping listed separately. The same product data generates an illustrated menu and price list as PDFs
- Type
- Small tool
- My role
- Design · development
- Date
- 2026.11
- Status
- Done
Why I built it
Customers’ messages come in every shape: some write “2 jin salted plums, 1 jin liquorice hawthorn, to Hangzhou”, some cram products, address and phone number into one line, and some just say “some plums, please”. Every order used to mean adding it up by hand against the price list, looking up shipping by province, and retyping the address for the supplier: slow and easy to get wrong.
So I made this: paste the message, glance at what it found, copy two texts, and the order is done.
How it works
- Paste the customer’s message as it is.
- It lists the products, sizes and quantities it found, plus the province, address, name and phone number.
- Fix anything wrong right in the table: swap a product, change a quantity, add one it missed, or pick the province by hand.
- Two texts are written below, each with a Copy button:
- Quote: the price of each item, the goods total, shipping (or free shipping) and the grand total, for the customer.
- Order: address, name, phone and the item list, without prices, for the supplier.
A promotion can apply a discount to the goods subtotal. Free-shipping eligibility uses the discounted subtotal, and the quote lists shipping separately.
What it understands
- Amounts: jin, grams, bags, jars and tins, in Chinese or Arabic numerals, plus “one jin each”, “x2” and “×3”; candied fruit comes in 250 g or 500 g.
- Products: each can have a few other names (王中王 means the 王中王 plum), and a bare category lists the candidates, highlighted for you to choose.
- Province: read from the province, city or even county in the address (昆山市 means Jiangsu).
- Recipient: name, mobile number and address, including the Taobao-style “name, phone, address” all run together.
Privacy
- It’s a single web page that works the moment you open it, with no network at all: no server, and nothing stored in the browser.
- Customers’ addresses and phone numbers are only handled in the open page and are gone when it’s closed; nothing is saved or uploaded.
- Prices and shipping rules sit in one small block of data at the top of the file, so changing a price doesn’t touch any other code.
Tech
- Plain HTML, CSS and JavaScript in one file, no dependencies, following the system’s light or dark mode.
- Recognition is a set of small functions: normalise full-width characters and spellings, scan for product names, parse quantities, find the province, then pull out the recipient details.
- The tests load the script straight out of the page with Node.js: 177 focused cases covering message parsing, delivery details, shipping and discounts; 1,000 ordinary random messages (random products, quantity styles, separators and address formats) and 2,000 hard ones (typos, a category first and the flavour later, filler words, full-width digits, more address and contact formats); and 6,000 randomly checked order texts, all passing. The random messages use a fixed seed, so every run produces the same ones and any failure can be reproduced.
- Node.js scripts lay out the illustrated menu and price list from the calculator’s product data and local photos, then print them to PDF with Chrome. Prices live in one place.
Progress
- Product, amount and province recognition, quote and order texts
- Shipping rules and no-ship warnings
- Test cases and random message tests
- Hard random messages, order text checks, and a product menu PDF with photos
- Promotional discounts, free shipping based on the discounted subtotal, and an illustrated price list PDF
- Not open source for now; I may tidy it up and open-source it later