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:
2026-11-14 20:25:34 +02:00
co-authored by Claude Opus 5.5
parent 77e0adbe9c
commit 6b237fd169
17 changed files with 384 additions and 29 deletions
+5
View File
@@ -110,6 +110,10 @@ class OrderItem(Base):
# KDS decline tracking
decline_note = Column(Text, nullable=True) # reason set by kitchen when declining
# KDS claim (plan step 3.2c): the cook working on this item; cleared when it moves on
claimed_by = Column(Integer, ForeignKey("users.id"), nullable=True)
claimed_at = Column(UTCDateTime, nullable=True)
# Courses — optional course assignment for sequenced firing
course_id = Column(Integer, nullable=True)
@@ -121,6 +125,7 @@ class OrderItem(Base):
product = relationship("Product", back_populates="order_items")
added_by_user = relationship("User", foreign_keys=[added_by], back_populates="order_items")
paid_by_user = relationship("User", foreign_keys=[paid_by], back_populates="items_paid")
claimed_by_user = relationship("User", foreign_keys=[claimed_by])
@property
def unit_type(self) -> str: