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:
2026-11-19 16:32:25 +02:00
co-authored by Claude Opus 5.5
parent 93c0dd7d9c
commit 07c9a0aecf
20 changed files with 510 additions and 64 deletions
@@ -0,0 +1,47 @@
"""Tabs in the books (plan step 6.13c, KI-018): a line put on a tab and a payment on a tab
record the business day and the shift they happened in (the shift of whoever did it, if they
were on one), so a shift shows what it put on tabs and the tab money it received, and the
day shows both. Existing rows get their business day from when they happened.
Revision ID: 0037_tab_books
Revises: 0036_print_job_resolution
Create Date: 2026-11-19 12:00:00
"""
from alembic import op
import sqlalchemy as sa
revision = '0037_tab_books'
down_revision = '0036_print_job_resolution'
branch_labels = None
depends_on = None
TABLES = ('tab_entries', 'tab_payments')
def upgrade() -> None:
for t in TABLES:
with op.batch_alter_table(t, schema=None) as batch_op:
batch_op.add_column(sa.Column('business_day_id', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('shift_id', sa.Integer(), nullable=True))
batch_op.create_index(f'ix_{t}_business_day_id', ['business_day_id'])
batch_op.create_index(f'ix_{t}_shift_id', ['shift_id'])
batch_op.create_foreign_key(f'fk_{t}_business_day_id_business_days', 'business_days', ['business_day_id'], ['id'])
batch_op.create_foreign_key(f'fk_{t}_shift_id_waiter_shifts', 'waiter_shifts', ['shift_id'], ['id'])
# the day each existing row happened in (a closed day's window, or the open one)
op.execute(f"""
UPDATE {t} SET business_day_id = (
SELECT d.id FROM business_days d
WHERE d.opened_at <= {t}.created_at AND (d.closed_at IS NULL OR d.closed_at >= {t}.created_at)
ORDER BY d.opened_at DESC LIMIT 1)
""")
def downgrade() -> None:
for t in TABLES:
with op.batch_alter_table(t, schema=None) as batch_op:
batch_op.drop_constraint(f'fk_{t}_shift_id_waiter_shifts', type_='foreignkey')
batch_op.drop_constraint(f'fk_{t}_business_day_id_business_days', type_='foreignkey')
batch_op.drop_index(f'ix_{t}_shift_id')
batch_op.drop_index(f'ix_{t}_business_day_id')
batch_op.drop_column('shift_id')
batch_op.drop_column('business_day_id')
+6
View File
@@ -35,6 +35,9 @@ class TabEntry(Base):
description = Column(Text, nullable=True) # auto-generated summary
created_by_id = Column(Integer, ForeignKey("users.id"), nullable=False)
created_at = Column(UTCDateTime, default=utcnow)
# 6.13c: the business day and the shift (of whoever did it, if on one) it happened in
business_day_id = Column(Integer, ForeignKey("business_days.id"), nullable=True, index=True)
shift_id = Column(Integer, ForeignKey("waiter_shifts.id"), nullable=True, index=True)
tab = relationship("Tab", back_populates="entries")
created_by = relationship("User", foreign_keys=[created_by_id])
@@ -51,6 +54,9 @@ class TabPayment(Base):
received_by_id = Column(Integer, ForeignKey("users.id"), nullable=False)
notes = Column(Text, nullable=True)
created_at = Column(UTCDateTime, default=utcnow)
# 6.13c: the business day and the shift (of whoever did it, if on one) it happened in
business_day_id = Column(Integer, ForeignKey("business_days.id"), nullable=True, index=True)
shift_id = Column(Integer, ForeignKey("waiter_shifts.id"), nullable=True, index=True)
tab = relationship("Tab", back_populates="payments")
received_by = relationship("User", foreign_keys=[received_by_id])
+19 -1
View File
@@ -292,6 +292,12 @@ def business_day_summary(
"shift_pay": None,
# distinct tables served (not order count)
"tables_served": 0,
# 6.13c: lines this person put on customers' tabs, and tab money they received
"on_tab_items": 0.0,
"on_tab_value": 0.0,
"tab_cash": 0.0,
"tab_card": 0.0,
"tab_other": 0.0,
}
return waiter_stats[uid]
@@ -331,6 +337,15 @@ def business_day_summary(
else:
e["other"] += val
# 6.13c: tabs: what went on them and the money received on them, per person and for the day
from services import tab_books
tabs_day = tab_books.for_day(db, day.id, {uid: (u.full_name or u.nickname or u.username) for uid, u in users_map.items()})
for uid, x in tabs_day.pop("by_person").items():
e = _waiter_entry(uid)
e["on_tab_items"] = x["on_tab_items"]
e["on_tab_value"] = x["on_tab_value"]
e["tab_cash"], e["tab_card"], e["tab_other"] = x["received"]["cash"], x["received"]["card"], x["received"]["other"]
from routers.shifts import compute_shift_pay
for shift in shifts:
e = _waiter_entry(shift.waiter_id)
@@ -494,7 +509,7 @@ def business_day_summary(
expenses_paid_today = round(sum(e.paid_amount for e in expenses_today), 2)
expenses_due = round(expenses_total - expenses_paid_today, 2)
# TABBED REVENUE (items moved to tabs — not yet collected)
# Lines of today's orders on customers' tabs: sold, not paid (6.13c)
tabbed_items = [i for i in all_items if i.status == "tabbed"]
tabbed_revenue = round(sum(gross(i) for i in tabbed_items), 2)
@@ -545,6 +560,9 @@ def business_day_summary(
"expenses_paid_today": expenses_paid_today,
"expenses_due": expenses_due,
"tabbed_revenue": tabbed_revenue,
# 6.13c: put on tabs today (by anyone), tab money received today (by method; and the part
# received by people with no shift: in no drawer), every tab payment with who received it
"tabs": tabs_day,
"net_estimate": net_estimate,
"net_has_unknowns": net_has_unknowns,
}
+4 -1
View File
@@ -2023,6 +2023,7 @@ def put_item_on_tab(
user: User = Depends(require("tabs.manage")), # also needs the tabs module on (6.13a)
):
from models.tabs import Tab, TabEntry
from services.sales import gross
order = db.query(Order).filter(Order.id == order_id).first()
if not order:
@@ -2051,10 +2052,12 @@ def put_item_on_tab(
tab_id=tab.id,
order_id=order_id,
order_item_id=item_id,
amount=round(item.unit_price * item.quantity, 2),
amount=round(gross(item), 2), # with its price change (a discount), as services/sales.py values it (6.13c)
description=description,
created_by_id=user.id,
)
from services import tab_books
tab_books.stamp(db, entry, user.id) # 6.13c: sold, not paid: the day and the shift it happened in
db.add(entry)
# Mark item as tabbed — distinct from active/paid/cancelled
+2
View File
@@ -2,6 +2,7 @@ from core.access.queries import holders_filter
from core.errors import XeniaError
from core.modules.entitlements import clamp_start, history_floor, history_since, limit
from core.timeutil import business_date_of, business_date_window, parse_api_datetime, venue_strftime, to_venue, utcnow
from services import tab_books
import csv
import io
import json
@@ -1252,6 +1253,7 @@ def current_business_day(
"opened_at": _dt(day.opened_at),
**money,
"refunds": day_refunds(db, day.id),
"tab_received": tab_books.for_day(db, day.id)["received"], # 6.13c: money paid on tabs today
"orders_closed": len(closed_orders),
"orders_open": len(open_orders),
"active_waiters": len(active_shifts),
+49 -16
View File
@@ -32,33 +32,42 @@ def _get_setting(db: Session, key: str, default: str = "true") -> str:
def compute_shift_total(shift_id: int, db: Session) -> float:
"""What the shift took, net of its refunds (3.3e)."""
"""The money the shift took (cash + card: items paid and tab payments), net of its refunds."""
split = compute_shift_payment_split(shift_id, db)
return round(split["cash_sales"] + split["card_sales"] - split["cash_refunds"] - split["card_refunds"], 2)
return round(split["cash_sales"] + split["card_sales"] + split["tab_cash"] + split["tab_card"]
- split["cash_refunds"] - split["card_refunds"], 2)
def compute_shift_payment_split(shift_id: int, db: Session) -> dict:
"""cash_sales / card_sales (items paid in this shift, with their price adjustments, i.e.
discounts) and cash_refunds / card_refunds (money this shift gave back, 3.3e)."""
"""The shift's money by kind (6.13c: every movement apart).
cash_sales / card_sales: items paid in this shift (with their price changes) in cash / by card;
other_sales: items paid any other way (transfer, on the house…): recorded, in no drawer
(until 6.13c they were counted as cash). tab_cash / tab_card / tab_other: payments on
customers' tabs this shift received. cash_refunds / card_refunds: money it gave back (3.3e).
"""
from services import tab_books
from services.refunds import item_value, shift_refunds
items = db.query(OrderItem).filter(
OrderItem.paid_in_shift_id == shift_id,
OrderItem.status == "paid",
).all()
cash = 0.0
card = 0.0
out = {"cash": 0.0, "card": 0.0, "other": 0.0}
for i in items:
amount = item_value(i)
method = (i.payment_method or "cash").lower()
if method == "card":
card += amount
else:
cash += amount
out[method if method in ("cash", "card") else "other"] += item_value(i)
refunds = shift_refunds(db, shift_id)
return {"cash_sales": round(cash, 2), "card_sales": round(card, 2),
tab = tab_books.for_shift(db, shift_id)["received"]
return {"cash_sales": round(out["cash"], 2), "card_sales": round(out["card"], 2), "other_sales": round(out["other"], 2),
"tab_cash": tab["cash"], "tab_card": tab["card"], "tab_other": tab["other"],
"cash_refunds": refunds["cash"], "card_refunds": refunds["card"]}
def expected_cash(split: dict, starting_cash: float | None) -> float:
"""What should be in the drawer: starting cash + cash for items + cash on tabs − cash refunded."""
return round((starting_cash or 0.0) + split["cash_sales"] + split["tab_cash"] - split["cash_refunds"], 2)
def compute_shift_pay(shift: WaiterShift) -> dict:
"""Return duration_hours and shift_pay. shift_pay is None if no rate snapshot."""
now = utcnow()
@@ -94,6 +103,26 @@ def compute_shift_pay(shift: WaiterShift) -> dict:
return {"duration_hours": round(duration_hours, 2), "shift_pay": shift_pay}
def shift_activity(shift: WaiterShift, db: Session) -> dict:
"""What happened in the shift (6.13c): orders opened and items made by this person in it,
items paid in it (by anyone's lines) and items it put on customers' tabs, with their values."""
from models.order import Order
from services import tab_books
from services.sales import gross
end = shift.ended_at or utcnow()
made = db.query(OrderItem).filter(OrderItem.added_by == shift.waiter_id, OrderItem.added_at >= shift.started_at,
OrderItem.added_at <= end, OrderItem.status != "cancelled").all()
paid = db.query(OrderItem).filter(OrderItem.paid_in_shift_id == shift.id, OrderItem.status == "paid").all()
orders = db.query(Order).filter(Order.opened_by == shift.waiter_id, Order.opened_at >= shift.started_at,
Order.opened_at <= end, Order.status != "cancelled").count()
tab = tab_books.for_shift(db, shift.id)["on_tab"]
r = lambda v: round(v, 2) # noqa: E731
return {"orders": orders,
"made_items": sum(i.quantity for i in made), "made_value": r(sum(gross(i) for i in made)),
"paid_items": sum(i.quantity for i in paid), "paid_value": r(sum(gross(i) for i in paid)),
"tab_items": tab["items"], "tab_value": tab["value"]}
def _enrich_shift(shift: WaiterShift, db: Session) -> dict:
w = shift.waiter
wname = (w.full_name or w.username) if w else f"#{shift.waiter_id}"
@@ -125,7 +154,12 @@ def _enrich_shift(shift: WaiterShift, db: Session) -> dict:
"card_sales": split["card_sales"],
"cash_refunds": split["cash_refunds"],
"card_refunds": split["card_refunds"],
"net_to_deliver": round(split["cash_sales"] - split["cash_refunds"] + (shift.starting_cash or 0.0), 2),
"other_sales": split["other_sales"],
"tab_cash": split["tab_cash"],
"tab_card": split["tab_card"],
"tab_other": split["tab_other"],
"net_to_deliver": expected_cash(split, shift.starting_cash),
"activity": shift_activity(shift, db),
"is_active": shift.ended_at is None,
"notes": shift.notes,
"hourly_rate_snapshot": shift.hourly_rate_snapshot,
@@ -136,9 +170,8 @@ def _enrich_shift(shift: WaiterShift, db: Session) -> dict:
"cancellation_value": cancellation_value,
# Phase 2E — discrepancy computed live against cash-only expected (starting_cash + cash_sales)
"counted_cash_end": shift.counted_cash_end,
"cash_discrepancy": round(
shift.counted_cash_end - (split["cash_sales"] - split["cash_refunds"] + (shift.starting_cash or 0.0)), 2
) if shift.counted_cash_end is not None else None,
"cash_discrepancy": round(shift.counted_cash_end - expected_cash(split, shift.starting_cash), 2)
if shift.counted_cash_end is not None else None,
"breaks": [
{"id": b.id, "shift_id": b.shift_id, "started_at": _dt(b.started_at), "ended_at": _dt(b.ended_at)}
for b in shift.breaks
+4 -1
View File
@@ -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)
+9 -4
View File
@@ -1,8 +1,9 @@
"""How every report counts sales (plan step 6.12a). One set of rules, so a day adds up the same
in every report, on screen, printed and exported.
- **Sold** = order lines that are `active` (ordered, not paid yet) or `paid`. Cancelled lines,
lines written off at closing (`closed`) and lines on a customer's tab (`tabbed`) are not sales.
- **Sold** = order lines that are `active` (ordered, not paid yet), `paid`, or on a customer's tab
(`tabbed`: sold, not paid; owner 2026-11-19, plan step 6.13c). Cancelled lines and lines written
off at closing (`closed`) are not sales. `on_tab` says how much of the sales is on tabs.
- A line's **value** = (unit price + its price change) × quantity, then **minus what was refunded**
of it (services/refunds.py: refunds are per line and quantity, so they come off the line, the
product, the category, the table, the hour and the day they belong to).
@@ -16,7 +17,7 @@ from __future__ import annotations
from dataclasses import dataclass
SOLD = ("active", "paid")
SOLD = ("active", "paid", "tabbed")
def gross(item, quantity: float | None = None) -> float:
@@ -70,6 +71,7 @@ class Totals:
profit: float = 0.0
has_gap: bool = False
units: float = 0.0 # products' quantity
on_tab: float = 0.0 # the part of revenue + fees on customers' tabs (sold, not paid)
@property
def takings(self) -> float:
@@ -77,6 +79,8 @@ class Totals:
def add(self, line: Line) -> "Totals":
self.refunded += line.refunded
if line.item.status == "tabbed":
self.on_tab += line.value
if line.fee:
self.fees += line.value
return self
@@ -93,7 +97,8 @@ class Totals:
def out(self) -> dict:
r = lambda v: round(v + 0.0, 2) # noqa: E731 (-0.0 → 0.0)
return {"revenue": r(self.revenue), "fees": r(self.fees), "takings": r(self.takings), "refunded": r(self.refunded),
"total_cost": r(self.cost), "trackable_profit": r(self.profit), "has_gap": self.has_gap}
"total_cost": r(self.cost), "trackable_profit": r(self.profit), "has_gap": self.has_gap,
"on_tab": r(self.on_tab)}
def totals(ls) -> Totals:
+103
View File
@@ -0,0 +1,103 @@
"""Tabs in the books (plan step 6.13c, KI-018; owner 2026-11-19: every movement recorded).
- A line put on a customer's tab **was sold but not paid**: the line is `tabbed` (services/sales.py
counts it as sold), and its TabEntry records who, when, the business day and the shift of whoever
did it. It is no money in anyone's hand: it isn't in any drawer.
- A payment on a tab is money received: its TabPayment records when, how (cash / card / other),
who received it, the business day and that person's shift if they are on one. Cash goes in that
shift's drawer, card in its card total. Received by someone with no shift (a manager): it is
theirs in the day's money and in no drawer.
"""
from __future__ import annotations
from sqlalchemy.orm import Session
METHODS = ("cash", "card", "other")
def stamp(db: Session, row, user_id: int) -> None:
"""Set the open business day and the user's running shift on a TabEntry / TabPayment."""
from models.business_day import BusinessDay
from models.shift import WaiterShift
day = db.query(BusinessDay).filter(BusinessDay.status == "open").first()
shift = db.query(WaiterShift).filter(WaiterShift.waiter_id == user_id, WaiterShift.ended_at.is_(None)) \
.order_by(WaiterShift.started_at.desc()).first()
row.business_day_id = day.id if day else (shift.business_day_id if shift else None)
row.shift_id = shift.id if shift else None
def _money(rows) -> dict:
out = {m: 0.0 for m in METHODS}
for p in rows:
m = p.payment_method if p.payment_method in METHODS else "other"
out[m] += p.amount
out = {k: round(v, 2) for k, v in out.items()}
out["total"] = round(sum(out.values()), 2)
out["count"] = len(rows)
return out
def _on_tab(entries) -> dict:
items = 0.0
for e in entries:
it = getattr(e, "_item", None)
items += it.quantity if it is not None else 0
return {"value": round(sum(e.amount for e in entries), 2), "lines": len(entries), "items": items}
def _with_items(db: Session, entries):
from models.order import OrderItem
ids = [e.order_item_id for e in entries if e.order_item_id]
by_id = {i.id: i for i in db.query(OrderItem).filter(OrderItem.id.in_(ids)).all()} if ids else {}
for e in entries:
e._item = by_id.get(e.order_item_id)
return entries
def for_shift(db: Session, shift_id: int) -> dict:
"""{on_tab: {value, lines, items}, received: {cash, card, other, total, count}} of one shift."""
from models.tabs import TabEntry, TabPayment
entries = _with_items(db, db.query(TabEntry).filter(TabEntry.shift_id == shift_id).all())
pays = db.query(TabPayment).filter(TabPayment.shift_id == shift_id).all()
return {"on_tab": _on_tab(entries), "received": _money(pays)}
def for_day(db: Session, day_id: int, names: dict | None = None) -> dict:
"""The day's tabs: what went on them, the money received on them (by method), and every payment
(who received it, in a shift or not)."""
from models.tabs import TabEntry, TabPayment
entries = _with_items(db, db.query(TabEntry).filter(TabEntry.business_day_id == day_id).all())
pays = db.query(TabPayment).filter(TabPayment.business_day_id == day_id).order_by(TabPayment.created_at).all()
names = names or {}
def who(uid):
return names.get(uid) or f"#{uid}"
from core.timeutil import iso_z
return {
"on_tab": _on_tab(entries),
"received": _money(pays),
"received_outside_shifts": _money([p for p in pays if p.shift_id is None]),
"payments": [{
"id": p.id, "tab_id": p.tab_id, "customer_name": p.tab.customer.name if p.tab and p.tab.customer else None,
"amount": p.amount, "method": p.payment_method or "cash", "received_by_id": p.received_by_id,
"received_by_name": who(p.received_by_id), "shift_id": p.shift_id, "at": iso_z(p.created_at),
} for p in pays],
"by_person": _by_person(entries, pays),
}
def _by_person(entries, pays) -> dict:
"""{user_id: {on_tab_value, on_tab_items, received: {cash, card, other}}}."""
out: dict = {}
def e(uid):
return out.setdefault(uid, {"on_tab_value": 0.0, "on_tab_items": 0.0, "received": {m: 0.0 for m in METHODS}})
for t in entries:
x = e(t.created_by_id)
x["on_tab_value"] = round(x["on_tab_value"] + t.amount, 2)
x["on_tab_items"] += t._item.quantity if getattr(t, "_item", None) is not None else 0
for p in pays:
m = p.payment_method if p.payment_method in METHODS else "other"
x = e(p.received_by_id)
x["received"][m] = round(x["received"][m] + p.amount, 2)
return out
+1 -1
View File
@@ -82,7 +82,7 @@ def test_the_day_adds_up_the_same_in_every_report(client, the_day, login):
assert [(w["waiter_name"], w["total"], w["items"]) for w in staff] == [("Maria W", 13.0, 2)]
history = get("/api/reports/orders/history", business_day_id=day_id)
assert history[0]["totals"] == {"revenue": 13.0, "fees": 2.5, "takings": 15.5, "refunded": 3.0,
"total_cost": 4.0, "trackable_profit": 6.0, "has_gap": True}
"total_cost": 4.0, "trackable_profit": 6.0, "has_gap": True, "on_tab": 0.0}
# the products export says the same
import csv
+93
View File
@@ -0,0 +1,93 @@
"""Tabs in the books (plan step 6.13c, KI-018; owner 2026-11-19: every movement recorded).
A shift: 3 items made, 2 paid in cash, 1 put on a customer's tab → the drawer expects the 2 (the tab
line is sold, not paid). The tab is paid later: part in cash by someone in another shift (their
drawer expects it), the rest by card by the owner with no shift (recorded as theirs, in the day,
in no drawer). Every report counts the tab line as sold and the tab money as received."""
from datetime import timedelta
def _setup(db, make_user):
from core.timeutil import business_date_of, utcnow
from models.business_day import BusinessDay
from models.customers import Customer
from models.order import Order, OrderItem
from models.product import Category, Product
from models.shift import WaiterShift
now = utcnow()
owner = make_user(role="owner", full_name="Olga Owner")
maria = make_user(role="waiter", full_name="Maria W")
nikos = make_user(role="store_manager", full_name="Nikos M")
anna = make_user(role="store_manager", full_name="Anna M")
day = BusinessDay(status="open", opened_by_id=owner.id, opened_at=now - timedelta(hours=3), business_date=business_date_of(now))
cat = Category(name="Drinks")
cust = Customer(name="Kostas", created_by_id=owner.id)
db.add_all([day, cat, cust])
db.flush()
beer = Product(name="Beer", base_price=4.0, primary_category_id=cat.id)
db.add(beer)
db.flush()
shifts = {u.full_name: WaiterShift(waiter_id=u.id, business_day_id=day.id, started_at=now - timedelta(hours=2), starting_cash=10.0)
for u in (maria, nikos, anna)}
db.add_all(shifts.values())
db.flush()
order = Order(opened_by=maria.id, order_type="takeaway", business_day_id=day.id, customer_id=cust.id, opened_at=now - timedelta(hours=1))
db.add(order)
db.flush()
line = lambda **kw: OrderItem(order_id=order.id, product_id=beer.id, added_by=maria.id, quantity=1, unit_price=4.0, # noqa: E731
added_at=now - timedelta(minutes=50), **kw)
paid = [line(status="paid", paid_by=maria.id, paid_at=now, payment_method="cash", paid_in_shift_id=shifts["Maria W"].id) for _ in range(2)]
tabbed = line()
tabbed.quantity = 2 # the third line: 2 beers, 8.00, on the tab
db.add_all(paid + [tabbed])
db.commit()
return dict(owner=owner, maria=maria, nikos=nikos, anna=anna, day=day, shifts=shifts, order=order, tabbed=tabbed)
def test_a_shift_and_its_tab_in_the_books(client, db, make_user, login):
s = _setup(db, make_user)
nikos, anna, owner = login(s["nikos"]), login(s["anna"]), login(s["owner"])
# Nikos (on his shift) puts the line on Kostas's tab
r = client.post(f"/api/orders/{s['order'].id}/items/{s['tabbed'].id}/tab", headers=nikos)
assert r.status_code == 200, r.text
tab_id = r.json()["tab_id"]
shift = lambda name: client.get(f"/api/shifts/{s['shifts'][name].id}/summary", headers=owner).json() # noqa: E731
m = shift("Maria W")
assert m["activity"] == {"orders": 1, "made_items": 4, "made_value": 16.0, "paid_items": 2, "paid_value": 8.0, "tab_items": 0, "tab_value": 0.0}
assert (m["cash_sales"], m["tab_cash"], m["net_to_deliver"]) == (8.0, 0.0, 18.0) # 10 starting + the 2 paid; not the tab line
n = shift("Nikos M")
assert (n["activity"]["tab_items"], n["activity"]["tab_value"], n["net_to_deliver"]) == (2, 8.0, 10.0) # put on a tab: no money
# later: Anna (on her shift) takes 5 in cash; the owner, with no shift, takes the rest by card
assert client.post(f"/api/tabs/{tab_id}/pay", headers=anna, json={"amount": 5, "payment_method": "cash"}).status_code == 200
assert client.post(f"/api/tabs/{tab_id}/pay", headers=owner, json={"amount": 3, "payment_method": "card"}).status_code == 200
a = shift("Anna M")
assert (a["tab_cash"], a["tab_card"], a["net_to_deliver"], a["total_collected"]) == (5.0, 0.0, 15.0, 5.0)
day = client.get("/api/business-day/summary", headers=owner).json()
t = day["tabs"]
assert t["on_tab"] == {"value": 8.0, "lines": 1, "items": 2}
assert (t["received"]["cash"], t["received"]["card"], t["received"]["total"]) == (5.0, 3.0, 8.0)
assert (t["received_outside_shifts"]["card"], t["received_outside_shifts"]["total"]) == (3.0, 3.0)
assert [(p["received_by_name"], p["method"], p["amount"], p["shift_id"] is None) for p in t["payments"]] == \
[("Anna M", "cash", 5.0, False), ("Olga Owner", "card", 3.0, True)]
people = {w["waiter_name"]: w for w in day["waiters"]}
assert (people["Nikos M"]["on_tab_value"], people["Nikos M"]["on_tab_items"]) == (8.0, 2)
assert people["Anna M"]["tab_cash"] == 5.0 and people["Olga Owner"]["tab_card"] == 3.0
assert day["tabbed_revenue"] == 8.0
# the reports: the tab line is sold (16 = 8 paid + 8 on the tab), 8 of it on a tab
cur = client.get("/api/reports/business-days/current", headers=owner).json()["business_day"]
assert cur["revenue"] == 16.0 and cur["on_tab"] == 8.0, cur
assert (cur["tab_received"]["cash"], cur["tab_received"]["card"]) == (5.0, 3.0)
def test_other_payment_methods_are_not_drawer_cash(client, db, make_user, login):
"""Before 6.13c anything not paid by card counted as cash in the drawer (a line on the house too)."""
s = _setup(db, make_user)
db.query(type(s["tabbed"])).filter_by(id=s["tabbed"].id).update({"status": "paid", "payment_method": "treat",
"paid_in_shift_id": s["shifts"]["Maria W"].id})
db.commit()
m = client.get(f"/api/shifts/{s['shifts']['Maria W'].id}/summary", headers=login(s["owner"])).json()
assert (m["cash_sales"], m["other_sales"], m["net_to_deliver"]) == (8.0, 8.0, 18.0)
@@ -58,11 +58,24 @@ export function MoneyTab({ data }) {
<div className="rounded-card border border-line overflow-hidden">
<Section title={t('overview.day.sales')} shaded>
<Row label={t('overview.day.salesTotal')} value={formatMoney(data.total_revenue)} />
{data.tabbed_revenue > 0 && <Row indent label={t('overview.day.onTabs')} value={`− ${formatMoney(data.tabbed_revenue)}`} tone="text-warning-ink"
{/* 6.13c: sold = paid + on tabs; money taken = paid items + tab payments received */}
<Row label={t('overview.day.paidSales')} value={formatMoney(data.total_revenue)} />
{data.tabbed_revenue > 0 && <Row label={t('overview.day.onTabs')} value={formatMoney(data.tabbed_revenue)} tone="text-warning-ink"
info={<InfoTip>{t('overview.day.onTabsTip')}</InfoTip>} />}
<Row label={t('overview.day.taken')} value={formatMoney(data.total_revenue - (data.tabbed_revenue || 0))} tone="text-success-ink" />
<Row label={t('overview.day.salesTotal')} value={formatMoney(data.total_revenue + (data.tabbed_revenue || 0))} />
{data.tabs?.received?.total > 0 && <Row label={t('overview.day.tabReceived')} value={`+ ${formatMoney(data.tabs.received.total)}`}
sub={t('overview.day.tabReceivedSub', { cash: formatMoney(data.tabs.received.cash), card: formatMoney(data.tabs.received.card + data.tabs.received.other) })}
info={<InfoTip>{t('overview.day.tabReceivedTip')}</InfoTip>} />}
<Row label={t('overview.day.taken')} value={formatMoney(data.total_revenue + (data.tabs?.received?.total || 0))} tone="text-success-ink" />
</Section>
{data.tabs?.payments?.length > 0 && (
<Section title={t('overview.day.tabPayments')}>
{data.tabs.payments.map(p => (
<Row key={p.id} label={t('overview.day.tabPayment', { customer: p.customer_name ?? '', name: p.received_by_name, method: t(`overview.pay.${p.method}`, { defaultValue: p.method }) })}
sub={`${formatDateTime(p.at, 'time')}${p.shift_id ? '' : ` · ${t('overview.day.noShift')}`}`} value={formatMoney(p.amount)} tone="text-success-ink" />
))}
</Section>
)}
<Section title={t('overview.day.cogs')}>
<Row label={t('overview.day.cogsKnown')} value={formatMoney(data.cogs_trackable)} info={<InfoTip>{t('overview.day.cogsTip')}</InfoTip>} />
{data.cogs_has_gap && <Row indent warn label={t('overview.day.uncosted', { count: data.cogs_uncosted_count, revenue: formatMoney(data.cogs_uncosted_revenue) })} value="?" />}
@@ -137,6 +150,8 @@ export function StaffTab({ data }) {
<Figure label={t('overview.day.tablesServed')}>{w.tables_served ?? 0}</Figure>
<Figure label={t('overview.day.itemsPaid')}>{w.items_paid}</Figure>
<Figure label={t('overview.day.collected')}><Money value={w.total_collected} className="text-success-ink" /></Figure>
{w.on_tab_value > 0 && <Figure label={t('overview.day.putOnTab')}><Money value={w.on_tab_value} className="text-warning-ink" /></Figure>}
{w.tab_cash + w.tab_card + w.tab_other > 0 && <Figure label={t('overview.day.tabReceived')}><Money value={w.tab_cash + w.tab_card + w.tab_other} className="text-success-ink" /></Figure>}
<ChevronDown size={16} className={cx('text-ink-3 transition-transform duration-base', shown && 'rotate-180')} aria-hidden="true" />
</button>
{shown && (
@@ -235,6 +250,8 @@ export function CashTab({ data, counted, onCounted, value }) {
<div className="rounded-card border border-line bg-surface-2 px-4 py-3">
<div className="text-caption font-semibold uppercase tracking-wide text-ink-3 mb-1">{t('overview.day.takings')}</div>
<Row label={t('overview.day.staffTook')} value={formatMoney(data.total_waiter_collected)} />
{data.tabs?.received_outside_shifts?.total > 0 && <Row indent label={t('overview.day.tabOutsideShifts')} value={formatMoney(data.tabs.received_outside_shifts.total)}
info={<InfoTip>{t('overview.day.tabOutsideShiftsTip')}</InfoTip>} />}
{data.store_opening_cash != null && <Row label={t('overview.day.openingCash')} value={formatMoney(data.store_opening_cash)} />}
<div className="border-t border-line mt-1 pt-1">
<Row label={t('overview.day.drawerExpected')} value={formatMoney(expected)} info={<InfoTip>{t('overview.day.drawerExpectedTip')}</InfoTip>} />
@@ -31,7 +31,7 @@ export default function ShiftDialog({ shift, mode, onClose, onConfirm, busy }) {
const { data: summary, isPending } = useLiveQuery({
queryKey: ['shift-summary', shift.id],
queryFn: () => client.get(`/api/shifts/${shift.id}/summary`).then(r => r.data),
events: ['order_paid', 'order_updated'],
events: ['order_paid', 'order_updated', 'tabs.changed'],
})
const data = summary || shift
const money = shiftMoney(data)
@@ -88,6 +88,8 @@ export default function ShiftDialog({ shift, mode, onClose, onConfirm, busy }) {
<div className="text-label text-right">
{t('overview.shift.startCash')} <Money value={money.start} className="font-semibold text-ink" /><br />
+ {t('overview.shift.cashSales')} <Money value={money.cash} className="font-semibold text-ink" />
{money.tabCash > 0 && <><br />+ {t('overview.shift.tabCash')} <Money value={money.tabCash} className="font-semibold text-ink" /></>}
{money.refunded > 0 && <><br />− {t('overview.shift.refunded')} <Money value={money.refunded} className="font-semibold text-ink" /></>}
</div>
</div>
<div className="grid grid-cols-3 gap-3">
@@ -98,7 +100,10 @@ export default function ShiftDialog({ shift, mode, onClose, onConfirm, busy }) {
{money.total > 0 && <SplitBar parts={[
{ key: 'cash', tone: 'success', label: t('overview.pay.cash'), value: money.cash },
{ key: 'card', tone: 'info', label: t('overview.pay.card'), value: money.card },
]} />}
{ key: 'other', tone: 'neutral', label: t('overview.pay.other'), value: money.other },
{ key: 'tab', tone: 'accent', label: t('overview.shift.tabPayments'), value: money.tab },
].filter(p => p.value > 0)} />}
{data.activity && <ShiftActivity a={data.activity} money={money} />}
{summary && shiftPairs(summary).length > 0 && (
<div className="grid gap-2">
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('overview.shift.perHour')}</span>
@@ -204,3 +209,24 @@ function OrderLines({ order, waiterId, kind, payment }) {
</div>
)
}
/** What happened in the shift (6.13c): made, paid, put on a tab, and the tab money received. */
function ShiftActivity({ a, money }) {
const { t } = useTranslation('manager')
const { formatMoney } = useFormat()
const cell = (label, items, value, testId, tone) => (
<Figure label={label} sub={value != null ? formatMoney(value) : null}>
<span className={tone} data-testid={testId}>{items}</span>
</Figure>
)
return (
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3 rounded-card border border-line p-3" data-testid="shift-activity">
{cell(t('overview.shift.made', { count: a.orders }), a.made_items, a.made_value, 'shift-made')}
{cell(t('overview.shift.paidItems'), a.paid_items, a.paid_value, 'shift-paid', 'text-success-ink')}
{cell(t('overview.shift.onTab'), a.tab_items, a.tab_value, 'shift-on-tab', a.tab_items ? 'text-warning-ink' : undefined)}
<Figure label={t('overview.shift.tabPayments')} sub={money.tab ? t('overview.shift.tabPaymentsSub', { cash: formatMoney(money.tabCash), card: formatMoney(money.tabCard + money.tabOther) }) : null}>
<Money value={money.tab} data-testid="shift-tab-received" />
</Figure>
</div>
)
}
@@ -91,14 +91,29 @@ export function shiftCounts(summary) {
}
}
/** The shift's money: what it started with, took in cash / card, and what should be in the drawer. */
/**
* The shift's money (6.13c: every movement apart): what it started with, took for items in cash /
* by card / other ways (transfer, on the house: in no drawer), took on customers' tabs, gave
* back, and what should be in the drawer (the backend's `net_to_deliver` when given).
*/
export function shiftMoney(data = {}) {
const cash = data.cash_sales ?? data.total_collected ?? 0
const card = data.card_sales ?? 0
const other = data.other_sales ?? 0
const tabCash = data.tab_cash ?? 0
const tabCard = data.tab_card ?? 0
const tabOther = data.tab_other ?? 0
const refunded = data.cash_refunds ?? 0
const start = data.starting_cash ?? 0
const total = cash + card
const cashPct = total > 0 ? Math.round((cash / total) * 100) : 0
return { cash, card, start, total, expected: start + cash, cashPct, cardPct: total > 0 ? 100 - cashPct : 0 }
const tab = tabCash + tabCard + tabOther
const total = cash + card + other + tab
const drawer = cash + tabCash
const cashPct = total > 0 ? Math.round((drawer / total) * 100) : 0
return {
cash, card, other, tabCash, tabCard, tabOther, tab, refunded, start, total,
expected: data.net_to_deliver ?? start + cash + tabCash - refunded,
cashPct, cardPct: total > 0 ? 100 - cashPct : 0,
}
}
/**
@@ -19,6 +19,9 @@ import { ExportButton, Failed, Loading, Panel, ReportPage, Stat, Table } from '.
import { PeriodPicker } from '../kit/Period'
import { defaultPeriod, periodParams, periodSlug, ratio } from '../kit/reportLogic'
/** Money a shift received on customers' tabs (6.13c). */
const tabOf = s => (s.tab_cash ?? 0) + (s.tab_card ?? 0) + (s.tab_other ?? 0)
export default function StaffReport() {
const { t } = useTranslation('manager')
const tabs = [
@@ -118,6 +121,8 @@ function CashTab() {
{ key: 'starting_cash', label: t('reports.staff.starting'), align: 'right', render: s => fmt.formatMoney(s.starting_cash ?? 0) },
{ key: 'cash_sales', label: t('reports.staff.cash'), align: 'right', render: s => fmt.formatMoney(s.cash_sales ?? 0) },
{ key: 'card_sales', label: t('reports.staff.card'), align: 'right', render: s => fmt.formatMoney(s.card_sales ?? 0) },
{ key: 'tabs', label: t('reports.staff.tabMoney'), align: 'right', tip: t('reports.staff.tabMoneyTip'), sort: s => tabOf(s),
render: s => (tabOf(s) ? <span title={t('reports.staff.tabMoneySplit', { cash: fmt.formatMoney(s.tab_cash ?? 0), card: fmt.formatMoney((s.tab_card ?? 0) + (s.tab_other ?? 0)) })}>{fmt.formatMoney(tabOf(s))}</span> : '') },
{ key: 'refunds', label: t('reports.refunded'), align: 'right', sort: s => (s.cash_refunds ?? 0) + (s.card_refunds ?? 0),
render: s => { const r = (s.cash_refunds ?? 0) + (s.card_refunds ?? 0); return r ? <span className="text-danger-ink">{fmt.formatMoney(r)}</span> : '' } },
{ key: 'net_to_deliver', label: t('reports.staff.handOver'), align: 'right', render: s => <span className="font-semibold">{fmt.formatMoney(s.net_to_deliver)}</span> },
@@ -132,6 +137,7 @@ function CashTab() {
<Stat label={t('reports.staff.starting')} value={fmt.formatMoney(sum('starting_cash'))} sub={t('reports.staff.shiftsCount', { count: rows.length })} />
<Stat label={t('reports.staff.cash')} value={fmt.formatMoney(sum('cash_sales'))} />
<Stat label={t('reports.staff.card')} value={fmt.formatMoney(sum('card_sales'))} />
{rows.some(tabOf) && <Stat label={t('reports.staff.tabMoney')} tip={t('reports.staff.tabMoneyTip')} value={fmt.formatMoney(rows.reduce((n, r) => n + tabOf(r), 0))} />}
<Stat label={t('reports.staff.handOver')} tip={t('reports.staff.handOverTip')} tone="accent" value={fmt.formatMoney(sum('net_to_deliver'))} testId="staff-handover" />
</div>
<Panel padded={false} title={t('reports.staff.cashTitle')}>
@@ -69,6 +69,9 @@ function Today() {
<Stat big label={t('reports.revenue')} tip={t('reports.revenueTip')} testId="today-revenue"
value={<MoneyCell value={d.revenue} />}
sub={t('reports.today.finished', { count: finished, avg: fmt.formatMoney(finished ? d.revenue / finished : 0) })} />
{d.on_tab > 0 && <Stat label={t('reports.today.onTab')} tip={t('reports.today.onTabTip')} tone="warning" value={fmt.formatMoney(d.on_tab)} testId="today-on-tab" />}
{d.tab_received?.total > 0 && <Stat label={t('reports.today.tabReceived')} tip={t('reports.today.tabReceivedTip')} tone="success" value={fmt.formatMoney(d.tab_received.total)}
sub={t('reports.today.tabReceivedSub', { cash: fmt.formatMoney(d.tab_received.cash), card: fmt.formatMoney(d.tab_received.card + d.tab_received.other) })} testId="today-tab-received" />}
{d.fees > 0 && <Stat label={t('reports.fees')} tip={t('reports.feesTip')} value={fmt.formatMoney(d.fees)} testId="today-fees" />}
{d.refunded > 0 && <Stat label={t('reports.refunded')} tip={t('reports.refundedTip')} tone="danger" value={fmt.formatMoney(d.refunded)}
sub={t('reports.today.refunds', { count: d.refunds?.count ?? 0 })} testId="today-refunded" />}
+5 -1
View File
@@ -56,7 +56,11 @@ test('money per hour covers the usual hours and any hour with money', () => {
test('a shift\'s money, counts and its lines seen from the waiter', () => {
assert.deepEqual(shiftMoney({ starting_cash: 20, cash_sales: 30, card_sales: 10 }),
{ cash: 30, card: 10, start: 20, total: 40, expected: 50, cashPct: 75, cardPct: 25 })
{ cash: 30, card: 10, other: 0, tabCash: 0, tabCard: 0, tabOther: 0, tab: 0, refunded: 0, start: 20, total: 40, expected: 50, cashPct: 75, cardPct: 25 })
// 6.13c: tab cash is in the drawer, tab card isn't; "other" (on the house) in no drawer; the backend's figure wins
const m = shiftMoney({ starting_cash: 10, cash_sales: 8, other_sales: 4, tab_cash: 5, tab_card: 3, cash_refunds: 2 })
assert.deepEqual([m.expected, m.tab, m.total], [21, 8, 20])
assert.equal(shiftMoney({ starting_cash: 10, cash_sales: 8, net_to_deliver: 17 }).expected, 17)
assert.equal(shiftMoney({}).cardPct, 0)
const summary = { orders: [
{ table_id: 1, items: [{ status: 'paid', quantity: 2 }, { status: 'cancelled', quantity: 5 }] },
+41 -15
View File
@@ -1269,7 +1269,15 @@
"unpaid": "Ανοιχτό",
"cancelled": "Ακυρώθηκε",
"anomaly": "Πρόβλημα"
}
},
"tabCash": "μετρητά από καρτέλες",
"refunded": "μετρητά που επιστράφηκαν",
"tabPayments": "Πληρωμές καρτελών",
"tabPaymentsSub": "μετρητά {{cash}} · κάρτα {{card}}",
"made_one": "Έφτιαξε · {{count}} παραγγελία",
"made_other": "Έφτιαξε · {{count}} παραγγελίες",
"paidItems": "Πληρώθηκαν",
"onTab": "Σε καρτέλα"
},
"cash": {
"even": "Ισοσκελισμένο",
@@ -1431,10 +1439,10 @@
"closed": "Κλείσιμο",
"stillOpen": "Ημέρα ενεργή",
"sales": "Έσοδα",
"salesTotal": "Σύνολο πωλήσεων",
"onTabs": "Καρτέλες (μη εισπραχθέντα)",
"onTabsTip": "Πωλήσεις σε καρτέλες πελατών: μετράνε ως πωλήσεις, τα χρήματα έρχονται όταν εξοφληθεί η καρτέλα.",
"taken": "Καθαρά εισπραχθέντα",
"salesTotal": "Πωλήθηκαν (πληρωμένα + σε καρτέλες)",
"onTabs": "Σε καρτέλες πελατών (πωλήθηκαν, δεν πληρώθηκαν)",
"onTabsTip": "Γραμμές που μπήκαν σήμερα σε καρτέλες πελατών: πωλήθηκαν, τα χρήματα έρχονται όταν πληρωθεί η καρτέλα. Δεν είναι σε κανένα συρτάρι.",
"taken": "Χρήματα που εισπράχθηκαν (πληρωμένα + πληρωμές καρτελών)",
"cogs": "Κόστος πωληθέντων",
"cogsKnown": "Κόστος καταγεγραμμένων",
"cogsTip": "Πόσο κόστισαν στο κατάστημα τα είδη που πουλήθηκαν, από τα κόστη των προϊόντων (όπως ήταν τη στιγμή της πώλησης).",
@@ -1511,7 +1519,17 @@
"unpaidWarning": "Προσοχή: υπάρχουν απλήρωτα αντικείμενα. Αν κλείσετε αναγκαστικά, τα απλήρωτα ποσά δεν θα καταγραφούν στις αναφορές.",
"autoClose": "Υπάρχουν ανοιχτά τραπέζια χωρίς απλήρωτα αντικείμενα. Θα κλείσουν αυτόματα.",
"forceClose": "Αναγκαστικό κλείσιμο",
"closeNow": "Κλείσε ημέρα"
"closeNow": "Κλείσε ημέρα",
"paidSales": "Πληρώθηκαν",
"tabReceived": "Πληρωμές καρτελών",
"tabReceivedSub": "μετρητά {{cash}} · κάρτα {{card}}",
"tabReceivedTip": "Χρήματα που πλήρωσαν σήμερα πελάτες στις καρτέλες τους, για όσα πωλήθηκαν σήμερα ή παλιότερα. Τα μετρητά που πήρε κάποιος σε βάρδια είναι στο συρτάρι του.",
"tabPayments": "Πληρωμές σε καρτέλες",
"tabPayment": "{{customer}}: {{name}}, {{method}}",
"noShift": "χωρίς βάρδια: σε κανένα συρτάρι",
"putOnTab": "Σε καρτέλες",
"tabOutsideShifts": "Πληρωμές καρτελών σε κάποιον χωρίς βάρδια",
"tabOutsideShiftsTip": "Καταγράφονται ως εισπράξεις αυτού του ατόμου (π.χ. του ιδιοκτήτη)· δεν είναι στο συρτάρι καμίας βάρδιας, οπότε δεν μετρούν στο αναμενόμενο του συρταριού."
}
},
"products": {
@@ -2743,7 +2761,7 @@
"long": "Επιλέξτε έως έναν χρόνο."
},
"revenue": "Έσοδα",
"revenueTip": "Προϊόντα που πουλήθηκαν, μείον όσα επιστράφηκαν. Τα έξοδα αποστολής μετρώνται χωριστά.",
"revenueTip": "Τα προϊόντα που πωλήθηκαν (πληρωμένα, απλήρωτα ή σε καρτέλα πελάτη), μείον όσα επιστράφηκαν. Τα έξοδα αποστολής μετρούν χωριστά.",
"fees": "Έξοδα αποστολής",
"feesTip": "Χρήματα για την αποστολή: δεν είναι προϊόν, οπότε δεν μπαίνουν στα έσοδα.",
"refunded": "Επιστροφές",
@@ -2786,7 +2804,12 @@
"cancelSub": "{{orders}} παραγγελίες / {{items}} είδη",
"noCancels": "καμία",
"orders_one": "{{count}} παραγγελία σήμερα",
"orders_other": "{{count}} παραγγελίες σήμερα"
"orders_other": "{{count}} παραγγελίες σήμερα",
"onTab": "Σε καρτέλες πελατών",
"onTabTip": "Το μέρος των σημερινών πωλήσεων που μπήκε σε καρτέλες πελατών: πωλήθηκε, δεν πληρώθηκε ακόμα.",
"tabReceived": "Πληρωμές καρτελών",
"tabReceivedTip": "Χρήματα που πλήρωσαν σήμερα πελάτες στις καρτέλες τους (για όσα πωλήθηκαν σήμερα ή παλιότερα).",
"tabReceivedSub": "μετρητά {{cash}} · κάρτα {{card}}"
},
"back": "Πίσω",
"save": "Αποθήκευση",
@@ -2931,18 +2954,13 @@
},
"staff": {
"title": "Προσωπικό",
"tabs": {
"shifts": "Βάρδιες",
"cash": "Παράδοση ταμείου",
"people": "Πωλήσεις ανά άτομο"
},
"shiftsCount_one": "{{count}} βάρδια",
"shiftsCount_other": "{{count}} βάρδιες",
"payTotal": "Αμοιβή για αυτές τις βάρδιες: {{amount}}",
"pay": "Αμοιβή",
"payTip": "Ώρες × η ωριαία αμοιβή τη στιγμή της βάρδιας.",
"handOver": "Για παράδοση",
"handOverTip": "Αρχικά μετρητά + μετρητά που εισπράχθηκαν − μετρητά που επιστράφηκαν: όσα πρέπει να είναι στο συρτάρι.",
"handOverTip": "Αρχικά μετρητά + μετρητά που εισπράχθηκαν (για είδη και από καρτέλες) − μετρητά που επιστράφηκαν: όσα πρέπει να είναι στο συρτάρι.",
"difference": "Διαφορά",
"differenceTip": "Όσα μετρήθηκαν στο τέλος μείον όσα έπρεπε να υπάρχουν (− λείπουν, + περισσεύουν).",
"shift": "Βάρδια",
@@ -2959,7 +2977,15 @@
"perHour": "Ανά ώρα",
"ranking": "Ποιος πούλησε περισσότερο",
"people_one": "{{count}} άτομο",
"people_other": "{{count}} άτομα"
"people_other": "{{count}} άτομα",
"tabMoney": "Πληρωμές καρτελών",
"tabMoneyTip": "Χρήματα που εισέπραξε αυτή η βάρδια από καρτέλες πελατών. Τα μετρητά είναι στο συρτάρι.",
"tabMoneySplit": "μετρητά {{cash}} · κάρτα {{card}}",
"tabs": {
"shifts": "Βάρδιες",
"cash": "Παράδοση ταμείου",
"people": "Πωλήσεις ανά άτομο"
}
},
"misc": {
"title": "Ακυρώσεις και εκπτώσεις",
+41 -15
View File
@@ -1269,7 +1269,15 @@
"unpaid": "Open",
"cancelled": "Cancelled",
"anomaly": "Problem"
}
},
"tabCash": "cash paid on tabs",
"refunded": "cash refunded",
"tabPayments": "Paid on tabs",
"tabPaymentsSub": "cash {{cash}} · card {{card}}",
"made_one": "Made · {{count}} order",
"made_other": "Made · {{count}} orders",
"paidItems": "Paid",
"onTab": "Put on a tab"
},
"cash": {
"even": "Balanced",
@@ -1431,10 +1439,10 @@
"closed": "Closed",
"stillOpen": "Day running",
"sales": "Revenue",
"salesTotal": "Total sales",
"onTabs": "On tabs (not taken yet)",
"onTabsTip": "Sales put on customers' tabs: they count as sales, the money comes when the tab is paid.",
"taken": "Net taken",
"salesTotal": "Sold (paid + on tabs)",
"onTabs": "On customers' tabs (sold, not paid)",
"onTabsTip": "Lines put on customers' tabs today: they were sold, the money comes when the tab is paid. They are in no drawer.",
"taken": "Money taken (paid + paid on tabs)",
"cogs": "Cost of goods sold",
"cogsKnown": "Known cost",
"cogsTip": "What the sold items cost the venue, from the costs entered on the products (as they were at the sale).",
@@ -1511,7 +1519,17 @@
"unpaidWarning": "Some items are unpaid. If you force the close, the unpaid amounts won't be in the reports.",
"autoClose": "Some tables are open with nothing left to pay. They will be closed.",
"forceClose": "Force the close",
"closeNow": "Close the day"
"closeNow": "Close the day",
"paidSales": "Paid",
"tabReceived": "Paid on tabs",
"tabReceivedSub": "cash {{cash}} · card {{card}}",
"tabReceivedTip": "Money customers paid on their tabs today, for things sold today or before. Cash taken by someone on a shift is in their drawer.",
"tabPayments": "Payments on tabs",
"tabPayment": "{{customer}}: {{name}}, {{method}}",
"noShift": "no shift: in no drawer",
"putOnTab": "Put on tabs",
"tabOutsideShifts": "Paid on tabs to someone with no shift",
"tabOutsideShiftsTip": "Recorded as received by that person (e.g. the owner); it isn't in any shift's drawer, so it isn't in the drawer's expected amount."
}
},
"products": {
@@ -2743,7 +2761,7 @@
"long": "Pick at most a year."
},
"revenue": "Revenue",
"revenueTip": "Products sold, minus what was refunded. Delivery fees are counted apart.",
"revenueTip": "Products sold (paid, not paid yet or put on a customer's tab), minus what was refunded. Delivery fees are counted apart.",
"fees": "Delivery fees",
"feesTip": "Money taken for delivery: not a product, so it's not in the revenue.",
"refunded": "Refunded",
@@ -2786,7 +2804,12 @@
"cancelSub": "{{orders}} orders / {{items}} items",
"noCancels": "none",
"orders_one": "{{count}} order today",
"orders_other": "{{count}} orders today"
"orders_other": "{{count}} orders today",
"onTab": "On customers' tabs",
"onTabTip": "The part of today's sales put on customers' tabs: sold, not paid yet.",
"tabReceived": "Paid on tabs",
"tabReceivedTip": "Money customers paid on their tabs today (for things sold today or before).",
"tabReceivedSub": "cash {{cash}} · card {{card}}"
},
"back": "Back",
"save": "Save",
@@ -2931,18 +2954,13 @@
},
"staff": {
"title": "Staff",
"tabs": {
"shifts": "Shifts",
"cash": "Cash handover",
"people": "Sales by person"
},
"shiftsCount_one": "{{count}} shift",
"shiftsCount_other": "{{count}} shifts",
"payTotal": "Pay for these shifts: {{amount}}",
"pay": "Pay",
"payTip": "Hours × the hourly pay at the time of the shift.",
"handOver": "To hand over",
"handOverTip": "Starting cash + cash taken − cash refunded: what should be in the drawer.",
"handOverTip": "Starting cash + cash taken (for items and on tabs) − cash refunded: what should be in the drawer.",
"difference": "Difference",
"differenceTip": "What was counted at the end minus what should have been there (− short, + over).",
"shift": "Shift",
@@ -2959,7 +2977,15 @@
"perHour": "Per hour",
"ranking": "Who sold most",
"people_one": "{{count}} person",
"people_other": "{{count}} people"
"people_other": "{{count}} people",
"tabMoney": "Paid on tabs",
"tabMoneyTip": "Money this shift received on customers' tabs. The cash part is in the drawer.",
"tabMoneySplit": "cash {{cash}} · card {{card}}",
"tabs": {
"shifts": "Shifts",
"cash": "Cash handover",
"people": "Sales by person"
}
},
"misc": {
"title": "Cancellations and discounts",
+10
View File
@@ -1320,6 +1320,16 @@ try {
r.check(`${fi} closed: it leaves the open tabs; payments card + cash`, settled?.status === 'closed' && settled.payments.map(x => x.payment_method).join(',') === 'card,cash', JSON.stringify(settled?.payments))
await page.getByTestId('tabs-view-settled').click()
r.check(`${fi} it is listed with the settled tabs`, await page.locator('[data-testid="tab-card"]', { hasText: 'Tab E2E' }).waitFor({ timeout: 8000 }).then(() => true).catch(() => false))
// 6.13c: the tab line is sold, not paid; the tab money is recorded as received (the manager had no shift: in no drawer)
const daySum = await api('GET', '/api/business-day/summary', { token: boss })
const mine = (daySum.tabs?.payments ?? []).filter(x => x.tab_id === settled?.id)
const outside = mine.filter(x => x.shift_id === null).reduce((n, x) => n + x.amount, 0)
r.check(`${fi} the day records both tab payments with who took them (in their shift's drawer, or in none)`, mine.length === 2 && mine.every(x => x.received_by_name)
&& Math.round(mine.reduce((n, x) => n + x.amount, 0) * 100) === Math.round(owes * 100) && daySum.tabs.received_outside_shifts.total >= outside - 0.005, JSON.stringify(daySum.tabs).slice(0, 300))
await page.goto(`${APP}/reports/today`)
r.check(`${fi} Today shows what is on tabs and what was paid on them`, await page.getByTestId('today-on-tab').waitFor({ timeout: 10_000 }).then(() => true).catch(() => false)
&& await page.getByTestId('today-tab-received').count() === 1)
await page.goto(`${APP}/financials/tabs`)
await page.getByTestId('user-menu').click()
await page.getByRole('menuitemradio', { name: 'Ελληνικά' }).click()
await page.waitForFunction(() => document.querySelector('[data-testid="tabs-page"] h1')?.textContent === 'Καρτέλες', null, { timeout: 5000 }).catch(() => {})