Appearance
Sales Case Matrix
One row per behavioral case for the use cases of SALES_USE_CASES.md. Each case names the test that proves it as a spec file path, the separator "›" and the exact test title, like the other case matrices; npm run lint:case-matrix verifies every citation and every count on this page.
Totals
| Use cases | 3 |
| Per-case scenario rows | 40 |
| Per-case scenario rows proven | 40 |
| Cross-cutting invariants | 5 (5 proven) |
| Gaps | 0 |
Take an order
SL1 — Take an order
| Case | Expected answer | Proving test |
|---|---|---|
| Happy path: a stocked item | 201 with the lean order, money as six-decimal strings | test/e2e/sales-take-order.e2e-spec.ts › sells a stocked item: 201 with the lean order, money as six decimals |
Missing or non-UUID Idempotency-Key | 400, nothing sold | test/e2e/sales-take-order-refusals.e2e-spec.ts › answers 400 without an Idempotency-Key and with one that is not a UUID |
| Empty body, unknown field, or a price sent by the client | 400 | test/e2e/sales-take-order-refusals.e2e-spec.ts › answers 400 for an empty body, an unknown field and a price sent by the client |
| Quantity with more than six decimals | 422 sales.order_refused, nothing sold | test/e2e/sales-take-order-refusals.e2e-spec.ts › refuses a quantity with more than six decimals: 422, nothing sold |
| Quantity of zero | 422 | test/e2e/sales-take-order-refusals.e2e-spec.ts › refuses a quantity of zero: 422 |
| Variant the outlet does not sell | 422 sales.lines_not_sellable without its snapshot | test/e2e/sales-take-order-refusals.e2e-spec.ts › refuses a variant the outlet does not sell, without showing its snapshot |
| Variant of another organization | Same answer as an unknown variant | test/e2e/sales-take-order-refusals.e2e-spec.ts › refuses a variant of another organization the same way as an unknown one |
| The same variant twice | Two lines | test/e2e/sales-take-order-refusals.e2e-spec.ts › sells the same variant twice as two lines |
| Tax-inclusive default price book | 422, nothing sold | test/e2e/sales-take-order-refusals.e2e-spec.ts › refuses a tax-inclusive default price book: 422 |
| Six-decimal money | 0.5 x 0.99 sells for 0.495000; the lines sum exactly | test/e2e/sales-take-order-supply.e2e-spec.ts › keeps six decimals: 0.5 x 0.99 sells for 0.495000 and the lines sum exactly |
| Any client price, price book entry or unknown field on a line or on the order | 400, nothing sold | test/e2e/sales-take-order-priced.e2e-spec.ts › rejects a client price, a price book entry and unknown fields with 400 and sells nothing |
| Options and a combo choice | Priced on the server, frozen on the order and read back unchanged | test/e2e/sales-take-order-priced.e2e-spec.ts › prices options and a combo choice on the server and freezes them on the order |
| Combo sent without its required choice | 422 sales.order_refused when a default component hides the gap, 422 sales.lines_not_sellable otherwise; a choice that is not a component is 422 sales.price_unresolvable, a malformed id 400; nothing sold | test/e2e/unlock-sale-combo-choices.e2e-spec.ts › refuses a combo whose default component fills a required group when no choice is sent with 422 sales.order_refused and sells nothing |
| Options and combo choices echoed per line | The sale, the read and the replay answer the same options and bundleChoices with names, quantities and amounts; a plain line answers empty lists | test/e2e/unlock-sale-line-choices.e2e-spec.ts › returns the chosen options and combo choices per line in the sale, in the read and in the replay, and empty lists for a plain line |
| Happy hour rule | Applies inside its schedule and not outside it | test/e2e/sales-take-order-priced.e2e-spec.ts › applies a happy hour rule inside its schedule and not outside it |
| Unknown option, combo component, channel, menu or service mode | 422 sales.price_unresolvable, nothing sold | test/e2e/sales-take-order-priced.e2e-spec.ts › refuses unknown references with 422 sales.price_unresolvable and an unknown service mode with 400, and sells nothing |
| Service mode of the order | Stored on the order, returned by the sale and the read, null when not sent; a replay with another service mode is 409 idempotency.key_reused | test/e2e/sales-take-order-service-mode.e2e-spec.ts › stores the service mode on the order, returns it on the sale, the replay and the read, and refuses a replay that changes it |
| A variant, option or combo component blocked at the outlet | 409 sales.item_unavailable, nothing sold, sells again once the block ends | test/e2e/unlock-sale-review.e2e-spec.ts › refuses a blocked variant with 409 sales.item_unavailable, sells nothing and sells again once the block ends |
| A replay that changes the menu, channel, service mode or overrides | 409 idempotency.key_reused | test/e2e/unlock-sale-review.e2e-spec.ts › refuses a replay that changes the menu, the channel, the service mode or the overrides with 409 idempotency.key_reused |
| Exhausted blocking quota, warning quota and replay | 409 sales.capacity_exceeded without pool ids; a warning quota sells with warnings; the replay answers the original | test/e2e/sales-take-order-priced.e2e-spec.ts › blocks an exhausted quota with 409, warns on a warning quota and replays the original |
| Quota override | Needs a valid approval per pool; a body without the approval id is 400 | test/e2e/sales-take-order-priced.e2e-spec.ts › lets a holder of the override permission sell past a block with an approval id and refuses a bad body |
| Audit | One sales.order.taken record, none for the replay | test/e2e/sales-take-order.e2e-spec.ts › records one audit event for the order taken and none for its replay |
| Currency of the outlet and business date of its site | Each outlet sells at the price list of its own currency and dates the order by its own time zone | test/e2e/sales-regional-profile.e2e-spec.ts › sells the same variant at the price list of the currency of each outlet and dates each order by its own time zone |
| Currency without a price list | 422 sales.price_unresolvable, nothing sold | test/e2e/sales-regional-profile.e2e-spec.ts › refuses the sale as unpriced in a currency that has no price list and refuses an unknown currency |
| Currency mismatch between order and outlet | The database refuses with 23514 and the constraint sales_order_currency_mismatch | database/tests/contracts/sales-regional-profile-contracts.ts › the outlet currency refusal carries the constraint sales_order_currency_mismatch so the application can tell it from any other refusal |
| Currency mismatch to the client | 409 sales.currency_mismatch | src/modules/sales/presentation/failures/to-public-sales-failure.spec.ts › answers a currency mismatch as a conflict with its own code |
SL3 — Replay, stock and permission of an order
| Case | Expected answer | Proving test |
|---|---|---|
| Same key and request | 200, replayed: true, one order | test/e2e/sales-take-order.e2e-spec.ts › replays the same key and request: 200, replayed true, one order |
| Same key after the item was delisted | Replays; a new key is refused | test/e2e/sales-take-order.e2e-spec.ts › replays the same key after the item was delisted: 200, replayed true, a new key is refused |
| Same key, another request | 409 idempotency.key_reused | test/e2e/sales-take-order.e2e-spec.ts › refuses the same key with another request: 409 idempotency.key_reused |
| Stock deducted once, also on replay | One deduction | test/e2e/sales-take-order-supply.e2e-spec.ts › deducts the stock of a stocked item once, also when the sale is replayed |
| Not enough stock | 409 sales.insufficient_stock, nothing sold, no inventory id in the answer | test/e2e/sales-take-order-supply.e2e-spec.ts › refuses a sale without enough stock: 409, nothing sold, no inventory id in the answer |
| Two concurrent sales of the last unit | Exactly one passes | test/e2e/sales-take-order-supply.e2e-spec.ts › lets only one of two concurrent sales of the last unit through |
| Replay after a reprice | Answers the original order and price | database/tests/contracts/sales-take-order-priced-contracts.ts › a replay after a reprice returns the original order with its original price and sells nothing again |
| Two sessions selling the last unit of quota and of stock | One sale wins; a refused sale leaves no quota draw behind | database/tests/contracts/sales-take-order-last-unit-race-contracts.ts › two sessions selling the last stock unit with plenty of quota: one sale wins, the other is refused for stock (23514) and its quota draw rolls back with it |
| Member without the permission | 403 sales.action_forbidden | test/e2e/sales-take-order-refusals.e2e-spec.ts › refuses a member without the permission: 403 |
Read an order
SL2 — Read an order
| Case | Expected answer | Proving test |
|---|---|---|
| Happy path | 200, no replayed, never cached | test/e2e/sales-order-detail.e2e-spec.ts › reads the order as it was sold: 200, no replayed flag, never cached |
| Unknown order or order of another organization | 404 sales.order_not_found | test/e2e/sales-order-detail.e2e-spec.ts › answers 404 for an order that does not exist and for one of another organization |
Member without sales.orders.read | 403 sales.action_forbidden | test/e2e/sales-order-detail.e2e-spec.ts › refuses a member without sales.orders.read at the outlet: 403 |
| Order id not a UUID | 400 | test/e2e/sales-order-detail.e2e-spec.ts › answers 400 when the order id is not a UUID |
| Member who may take but not read | Replays the original order after a reprice | test/e2e/sales-take-order-replay.e2e-spec.ts › answers the original order to a member who may take but not read, after a reprice |
Cross-cutting invariants
| Invariant | Expected answer | Proving test |
|---|---|---|
| An outlet outside the scope, an unknown one and one of another organization | The same 403 | test/e2e/sales-take-order-refusals.e2e-spec.ts › answers the same 403 for an outlet outside the scope, an unknown one and one of another organization |
| One organization never sells into the outlet of another | Refused | test/e2e/sales-take-order-refusals.e2e-spec.ts › never lets one organization sell into the outlet of another |
| A member who may read but not take, and a seller of another outlet | Refused | test/e2e/sales-take-order-replay.e2e-spec.ts › refuses a member who may read but not take, and a seller of another outlet |
| With a zero cutoff the business date is the local date of the site | Not the server date | database/tests/contracts/sales-business-day-contracts.ts › with the default cutoff of zero the business date is the local date of the site, not the date of the server |
| A 23:59 cutoff puts a sale of today in the previous business day | The order number carries that date | database/tests/contracts/sales-business-day-contracts.ts › a cutoff of 23:59 makes a sale of today belong to the previous business day and the order number carries that date |