Backend:
- WaiterShift: add counted_cash_end (physical cash handed over) + cash_discrepancy (computed)
- BusinessDay: add store_opening_cash, store_closing_cash, store_cash_discrepancy
- EndShiftRequest: accept counted_cash_end (optional)
- CloseBusinessDayRequest: accept store_closing_cash (optional)
- Shift end (both /end and /manager/end/{id}): compute cash_discrepancy =
counted_cash_end - (starting_cash + total_collected); negative = short, positive = over
- Business day close: compute store_cash_discrepancy = store_closing_cash - expected;
expected = store_opening_cash + sum(shift.total_collected for day)
- _enrich_shift: expose counted_cash_end + cash_discrepancy in all shift responses
- Business day summary: expose store cash fields + store_expected_closing + total_waiter_collected
- BusinessDayOut schema: expose new store cash fields
- Shifts CSV export: add counted_cash_end + cash_discrepancy columns
Frontend:
- EndShiftConfirmModal: 2-step flow — step 1 notes, step 2 cash handover with live discrepancy
(shows ✓ clean / ⚠ short / ⚠ over in real time before confirming)
- WorkdaySummaryModal close flow: new Ταμείο tab with store cash count + live discrepancy;
footer navigates overview → Ταμείο → Έλεγχοι; store_closing_cash included in close payload
- ShiftsOverview report: Ταμείο column showing counted_cash_end + discrepancy badge
- ShiftDetailModal row 2: replaces Εξ.Τραπεζιών with Παραδόθηκαν + Ταμείο discrepancy
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.8 KiB
Python
42 lines
1.8 KiB
Python
from sqlalchemy import Column, Integer, Float, DateTime, ForeignKey, Text
|
|
from sqlalchemy.orm import relationship
|
|
from datetime import datetime, timezone
|
|
from database import Base
|
|
|
|
|
|
def _utcnow():
|
|
return datetime.now(timezone.utc)
|
|
|
|
|
|
class WaiterShift(Base):
|
|
__tablename__ = "waiter_shifts"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
waiter_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
business_day_id = Column(Integer, ForeignKey("business_days.id"), nullable=False)
|
|
started_at = Column(DateTime(timezone=True), default=_utcnow, nullable=False)
|
|
ended_at = Column(DateTime(timezone=True), nullable=True)
|
|
starting_cash = Column(Float, nullable=True)
|
|
total_collected = Column(Float, nullable=True) # snapshot written at shift end
|
|
notes = Column(Text, nullable=True)
|
|
# Phase 2B — payroll snapshot (copied from user.hourly_rate at shift start, never updated)
|
|
hourly_rate_snapshot = Column(Float, nullable=True)
|
|
# Phase 2E — cash reconciliation
|
|
counted_cash_end = Column(Float, nullable=True) # physical cash waiter hands over
|
|
cash_discrepancy = Column(Float, nullable=True) # counted_cash_end - expected; neg = short
|
|
|
|
waiter = relationship("User", foreign_keys=[waiter_id])
|
|
business_day = relationship("BusinessDay", back_populates="shifts")
|
|
breaks = relationship("ShiftBreak", back_populates="shift", cascade="all, delete-orphan")
|
|
|
|
|
|
class ShiftBreak(Base):
|
|
__tablename__ = "shift_breaks"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
shift_id = Column(Integer, ForeignKey("waiter_shifts.id"), nullable=False)
|
|
started_at = Column(DateTime(timezone=True), default=_utcnow, nullable=False)
|
|
ended_at = Column(DateTime(timezone=True), nullable=True)
|
|
|
|
shift = relationship("WaiterShift", back_populates="breaks")
|