feat: tabs in the books (platform-v2 step 6.13c, KI-018; owner 2026-11-19: every movement recorded)
- a line on a customer's tab is sold, not paid: services/sales.py counts tabbed lines as sold (on_tab apart) - TabEntry / TabPayment record the business day and the shift of whoever did it (Alembic 0037, rows backfilled with their day); services/tab_books.py: per shift and per day, on tabs and tab money received (cash / card / other, who, in a shift or not) - shift: tab cash goes in the drawer (net_to_deliver, the counted difference, total_collected), tab card in the card total; items paid other ways (transfer, on the house) are recorded apart and no longer counted as drawer cash; 'activity': orders, items made / paid / put on a tab with values - day summary: per person put on tabs and tab money received, every tab payment with who took it, the part taken outside shifts (in no drawer); the day's money: paid, on tabs, sold, paid on tabs, money taken (it used to subtract tabs from paid sales) - Today: on tabs, paid on tabs; Staff -> Cash handover: paid on tabs; the shift dialog: made / paid / on a tab / paid on tabs - fix: a line put on a tab was charged without its price change (a discount) - tests: test_tab_books.py (the done-when), overview unit, e2e manager.mjs (the day records the tab payments; Today shows them) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,12 +20,13 @@ from models.user import User
|
||||
from schemas.tabs import TabOut, TabEntryOut, TabPaymentOut, TabPayRequest, TabForgiveRequest, TabCloseRequest
|
||||
from core.access.deps import require, require_any
|
||||
from core.errors import XeniaError
|
||||
from services import tab_books
|
||||
from services.ws_bus import broadcast_sync
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
MANAGE = Depends(require("tabs.manage"))
|
||||
METHODS = ("cash", "card", "other")
|
||||
METHODS = tab_books.METHODS
|
||||
|
||||
|
||||
def changed():
|
||||
@@ -150,6 +151,7 @@ def add_tab_entry(
|
||||
tab_id=tab_id, order_id=order_id, order_item_id=order_item_id,
|
||||
amount=amount, description=description, created_by_id=user.id,
|
||||
)
|
||||
tab_books.stamp(db, entry, user.id)
|
||||
db.add(entry)
|
||||
db.commit()
|
||||
db.refresh(tab)
|
||||
@@ -182,6 +184,7 @@ def pay_tab(
|
||||
payment_method=method, notes=body.notes,
|
||||
received_by_id=user.id,
|
||||
)
|
||||
tab_books.stamp(db, payment, user.id) # 6.13c: the day and the receiver's shift (their drawer)
|
||||
db.add(payment)
|
||||
db.commit()
|
||||
db.refresh(tab)
|
||||
|
||||
Reference in New Issue
Block a user