feat(backend,terminal): online orders on the counter POS (platform-v2 step 3.3d)
- Counter POS gets an "Online" mode (module on + connect_orders.manage): New / In
progress / Finished, a chime on arrival (and every 30 s while one waits), badge,
toast in any mode; the order panel offers only the next step: accept / reject with
a reason, preparing, ready or out for delivery, then take the payment (shared
PaymentDialog, drawer, shift) and mark delivered/served.
- connect_orders router on v2 conventions: require(connect_orders.manage), error
codes online.not_found / online.status_changed, the cloud's step order enforced,
audit rows, GET /api/connect/orders/board. POS device scope gains connect_orders.*;
barista and barman get the key by default.
- Fixes: the KDS showed online orders before acceptance; accepting printed no
kitchen tickets; a pull whose synced mark failed stored the order twice
(store_online_orders skips known cloud ids); pulled orders lacked the business day
and delivery type; rejected orders kept active items; delivered sets closed_at/by.
- Online orders belong to holders of connect_orders.manage (_can_access_order), so
the counter pays them with POST /api/pos/orders/{id}/pay.
- Tests: test_pos_online.py (5), terminal unit +1, terminal.mjs +17 with a fake
cloud (pull, synced, status mirror); fixed a timing race in a 3.3c check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -128,3 +128,23 @@ test('tables at the counter: state, zones, order lines, what Pay takes (3.3c)',
|
||||
assert.equal(qtyLabel(2, 'piece'), '2×')
|
||||
assert.equal(qtyLabel(0.5, 'liter'), '0.5 L')
|
||||
})
|
||||
|
||||
test('online orders: the next step and finding an order (3.3d)', async () => {
|
||||
const { findOnline, minutesSince, nextStep } = await import('../src/apps/pos/logic/online.js')
|
||||
assert.deepEqual(nextStep({ status: 'pending_acceptance' }), { kind: 'answer' })
|
||||
assert.deepEqual(nextStep({ status: 'accepted' }), { kind: 'status', to: 'preparing' })
|
||||
assert.deepEqual(nextStep({ status: 'preparing', type: 'delivery' }), { kind: 'status', to: 'out_for_delivery' })
|
||||
assert.deepEqual(nextStep({ status: 'preparing', type: 'dine_in' }), { kind: 'status', to: 'ready' })
|
||||
assert.deepEqual(nextStep({ status: 'out_for_delivery', unpaid: 22 }), { kind: 'finish', pay: true })
|
||||
assert.deepEqual(nextStep({ status: 'ready', unpaid: 0 }), { kind: 'finish', pay: false })
|
||||
assert.equal(nextStep({ status: 'delivered' }), null)
|
||||
assert.equal(nextStep({ status: 'rejected' }), null)
|
||||
const board = { incoming: [{ id: 1 }], in_progress: [{ id: 2 }], finished: [{ id: 3 }] }
|
||||
assert.equal(findOnline(board, 2).id, 2)
|
||||
assert.equal(findOnline(board, 3).id, 3)
|
||||
assert.equal(findOnline(board, 9), null)
|
||||
assert.equal(findOnline(null, 1), null)
|
||||
const at = Date.parse('2026-11-15T10:00:00Z')
|
||||
assert.equal(minutesSince('2026-11-15T09:57:30Z', at), 2)
|
||||
assert.equal(minutesSince('2026-11-15T10:01:00Z', at), 0)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user