Short write‑ups of problems we hit running a real commerce operation and what we changed in the code because of them. No product announcements; just the reasoning.
Trade discounts are not "10% off with code". They are forty trigger types — quantity of a family, amount across a department, every nth order, first order, cartons, gifts, vouchers, customer‑exclusive deals — stacked, metered, re‑evaluated on every basket change, and written to every invoice line as an allowance you can audit. How aiku's discount engine works, why buy‑X‑get‑cheapest‑free counts the way it does, and the penny that float arithmetic tried to steal.
Selling through a wholesale marketplace means the order is not yours: the buyer edits it after you have picked it, the marketplace sets the discount and the commission, the items can change after dispatch, and the only truth is their payload. The shops we run on such a marketplace taught us more about ownership than any other integration — six rules, each with the afternoon behind it.
A million invoices and fifty thousand credit notes, and the rule that governs all of them: an invoice is a frozen picture of an order at the moment it was billed, and nothing that happens later — a price change, a tax change, a product rename — can move it. How invoices are minted from orders, how credit notes reference the lines they return, how a paid status is derived rather than set, how invoices are categorised for the accountants, and how a PDF, an e‑invoice and an export all read from the same rows.
Selling across Europe and the UK means every order has to answer one question before a price is final — and the answer depends on two addresses, a postcode, and whether a VAT number is real. How aiku validates tax numbers against VIES and HMRC (with retries, rate limits and an audit trail), and the decision tree that turns a shipping address into a tax category, Canaries and Madeira included.
For years every line we sold carried the same VAT rate, so one rate per order was simply true. Then the range grew to include tea — zero‑rated in one market, reduced in another — and "which rate" became a question per line. The answer was not "read the product's tax code": it was presets instead of codes for staff, tax versioned like price on the historic line, frozen once sold, and a migration that re‑rated the open baskets to the penny.