feat(backend): KDS item claims across screens; zone screens only touch their own items (platform-v2 3.2c)
- order_items.claimed_by / claimed_at (Alembic 0015). POST/DELETE
/api/kds/orders/{id}/items/{item}/claim (kds.bump): someone else's claim is refused
(kds.item_claimed), letting go works for anyone with kds.bump; live kds_item_claimed.
In progress claims for whoever did it; done/served/pending/declined clear the claim.
- Fix: order-level status and decline from a zone screen changed every zone's items;
now only the screen's zone, and a zone screen sees the order status of its own items.
- Terminal: "I'm on it" / "Let go" on the selected card, the cook's name on claimed items.
- Tests: backend +6, terminal unit +1, terminal.mjs +6 with a second screen and cook.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -180,3 +180,21 @@ test('device config → board settings; zoom overrides the size for the session'
|
||||
assert.equal(senderName({ zone: { name: 'Grill', notification_name: 'Grill station' }, device: { name: 'Screen' } }), 'Grill station')
|
||||
assert.equal(senderName({ zone: null, device: { name: 'Screen' } }), 'Screen')
|
||||
})
|
||||
|
||||
test('claims: take what nobody has, let go of mine, nothing when others have it all (3.2c)', async () => {
|
||||
const { claimState, claimTargets } = await import('../src/apps/kds/logic/board.js')
|
||||
const items = [
|
||||
{ id: 1, kds_status: 'pending', claimed_by: null },
|
||||
{ id: 2, kds_status: 'preparing', claimed_by: 7 },
|
||||
{ id: 3, kds_status: 'done', claimed_by: null },
|
||||
{ id: 4, kds_status: 'pending', claimed_by: 9 },
|
||||
]
|
||||
assert.equal(claimState(items, 7), 'take')
|
||||
assert.deepEqual(claimTargets(items, 7, 'take').map(i => i.id), [1])
|
||||
const mine = items.map(i => (i.id === 1 ? { ...i, claimed_by: 7 } : i))
|
||||
assert.equal(claimState(mine, 7), 'mine')
|
||||
assert.deepEqual(claimTargets(mine, 7, 'release').map(i => i.id), [1, 2])
|
||||
assert.equal(claimState(mine.map(i => ({ ...i, claimed_by: i.claimed_by && 9 })), 7), 'none')
|
||||
assert.equal(claimState([{ id: 1, kds_status: 'done' }], 7), 'none')
|
||||
assert.equal(claimState(items, null), 'none')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user