feat(terminal): quick sale at the counter: cash/card/split, change, cash drawer, fiscal (platform-v2 3.3b)

- POST /api/pos/sales: all checks first (shift, lines, payment split, cash given,
  discount → ordering.prices.modify or manager approval, fiscal VAT groups), then the
  existing open_order / add_items / pay_items functions, so tickets, KDS, price events,
  shift totals and the fiscal receipt work as for any order.
- Cash drawer: printer_service.open_cash_drawer (ESC @ + ESC p 0 25 250) to the screen's
  receipt printer on cash, logged and audited (DRAWER_OPENED / DRAWER_FAILED).
- orders._can_access_order: the people assigned to an order may act on it (a cashier's
  own takeaway order); pos_cart prices a batch with the lines before it, as add_items does.
- Terminal: Charge → payment dialog (exact cash pre-selected, quick amounts, change,
  card, split by line), per-line discounts, sale summary and "Same again".
- Tests: backend +6 (socket printer receives the drawer kick, fiscal file in the bridge
  folder), terminal unit +1, terminal.mjs +9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 00:28:33 +02:00
co-authored by Claude Opus 5.5
parent 17bee66df1
commit bff82a332a
15 changed files with 632 additions and 14 deletions
+11
View File
@@ -87,3 +87,14 @@ test('cart: the same choices add up, different choices are separate lines; 0 rem
assert.deepEqual(setLineQty(cart, 0, 0).map(l => l.product_id), [1, 1])
assert.equal(setLineQty(cart, 0, 0.30000000000000004)[0].quantity, 0.3)
})
test('paying: quick amounts, change, split parts (3.3b)', async () => {
const { changeFor, quickAmounts, splitPayments } = await import('../src/apps/pos/logic/cart.js')
assert.deepEqual(quickAmounts(12.2), [12.2, 15, 20, 50, 100])
assert.deepEqual(quickAmounts(20), [20, 25, 30, 40, 50])
assert.equal(changeFor(20, 16), 4)
assert.equal(changeFor(15, 16), null)
assert.equal(changeFor(16, 16), 0)
assert.deepEqual(splitPayments(['card', 'cash', 'cash'], [10, 3, 2.5]),
{ cash: 5.5, card: 10, payments: [{ method: 'card', lines: [0] }, { method: 'cash', lines: [1, 2] }] })
})