feat: Phase 2E — cash drawer reconciliation
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>
This commit is contained in:
@@ -192,11 +192,23 @@ export default function ShiftDetailModal({ shiftId, shiftWaiterId, onClose }) {
|
||||
{ label: 'Πληρωμή Βάρδιας', value: summary.shift_pay != null ? fmtEUR(summary.shift_pay) : 'Δεν παρακολουθείται', accent: summary.shift_pay != null ? '#059669' : undefined },
|
||||
{ label: 'Αρχικά Μετρητά', value: summary.starting_cash != null ? fmtEUR(summary.starting_cash) : '—' },
|
||||
]
|
||||
const discrepancy = summary.cash_discrepancy
|
||||
const discLabel = discrepancy == null
|
||||
? '—'
|
||||
: Math.abs(discrepancy) < 0.005
|
||||
? '✓ Εντάξει'
|
||||
: discrepancy < 0
|
||||
? `Έλλειμμα ${fmtEUR(Math.abs(discrepancy))}`
|
||||
: `Πλεόνασμα ${fmtEUR(discrepancy)}`
|
||||
const discAccent = discrepancy == null
|
||||
? undefined
|
||||
: Math.abs(discrepancy) < 0.005 ? '#16a34a' : '#dc2626'
|
||||
|
||||
const row2 = [
|
||||
{ label: 'Σύνολο Παραγγελιών', value: String(totalOrders) },
|
||||
{ label: 'Εισπράξεις', value: fmtEUR(summary.total_collected), accent: '#2f9e5e' },
|
||||
{ label: 'Προς Παράδοση', value: fmtEUR(summary.net_to_deliver), accent: '#3758c9' },
|
||||
{ label: 'Εξ. Τραπεζιών', value: String(tablesServed) },
|
||||
{ label: 'Παραδόθηκαν', value: summary.counted_cash_end != null ? fmtEUR(summary.counted_cash_end) : '—', accent: '#3758c9' },
|
||||
{ label: 'Ταμείο', value: discLabel, accent: discAccent },
|
||||
]
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, padding: '14px 24px', borderBottom: '1px solid #edeff1', flexShrink: 0 }}>
|
||||
|
||||
@@ -124,6 +124,7 @@ export default function ShiftsOverview({ onNavigate } = {}) {
|
||||
<TH align="right">Αρχικά Μετρητά</TH>
|
||||
<TH align="right">Εισπράχθηκαν</TH>
|
||||
<TH align="right">Οφείλει</TH>
|
||||
<TH align="right">Ταμείο</TH>
|
||||
<TH>Κατάσταση</TH>
|
||||
<TH className="w-28" />
|
||||
</THead>
|
||||
@@ -158,6 +159,24 @@ export default function ShiftsOverview({ onNavigate } = {}) {
|
||||
<TD mono align="right">{fmtEUR(s.starting_cash)}</TD>
|
||||
<TD mono align="right">{fmtEUR(s.total_collected)}</TD>
|
||||
<TD mono align="right" className="font-semibold text-slate-900">{fmtEUR(s.net_to_deliver)}</TD>
|
||||
<TD mono align="right">
|
||||
{s.counted_cash_end != null ? (
|
||||
<span className={
|
||||
s.cash_discrepancy == null || Math.abs(s.cash_discrepancy) < 0.005
|
||||
? 'text-emerald-600 font-semibold'
|
||||
: 'text-red-600 font-semibold'
|
||||
}>
|
||||
{fmtEUR(s.counted_cash_end)}
|
||||
{s.cash_discrepancy != null && Math.abs(s.cash_discrepancy) >= 0.005 && (
|
||||
<span className="block text-[10px] font-medium">
|
||||
{s.cash_discrepancy > 0 ? '+' : ''}{fmtEUR(s.cash_discrepancy)}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-slate-400 text-[11px]">—</span>
|
||||
)}
|
||||
</TD>
|
||||
<TD><StatusBadge status={s.is_active ? 'active' : 'closed'} pulse /></TD>
|
||||
<TD align="right">
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
@@ -182,7 +201,7 @@ export default function ShiftsOverview({ onNavigate } = {}) {
|
||||
</TR>,
|
||||
isOpen && (
|
||||
<tr key={`${s.id}-detail`}>
|
||||
<td colSpan={11} className="border-b border-slate-100 bg-slate-50/60 px-6 py-3">
|
||||
<td colSpan={12} className="border-b border-slate-100 bg-slate-50/60 px-6 py-3">
|
||||
<div className="flex items-center gap-4 text-[12px] text-slate-500">
|
||||
<span>
|
||||
{'Εργάσιμη Μέρα: '}
|
||||
|
||||
Reference in New Issue
Block a user