diff --git a/frontend/src/pages/DailyCashUp.tsx b/frontend/src/pages/DailyCashUp.tsx index feed71e..aa5515a 100644 --- a/frontend/src/pages/DailyCashUp.tsx +++ b/frontend/src/pages/DailyCashUp.tsx @@ -238,6 +238,27 @@ export function DailyCashUp({ user }: Props) { } } + async function startCashUp() { + setSaving(true) + try { + await api.post<{ cash_up_id: number }>('/cashup/save', { + session_date: date, status: 'draft', notes: '', checked_transactions: [], + denominations: [], + card_machines: machines.map(m => ({ name: m.machine_name, total: 0, amex: 0, visa_mc: 0 })), + }) + const data = await api.get<{ + cash_up: CashUp; denominations: Denomination[]; card_machines: CardMachine[]; + reconciliation: ReconciliationRow[]; attachments: Attachment[] + }>(`/cashup?date=${date}`) + applyLoaded(data as { cash_up: CashUp; denominations: Denomination[]; card_machines: CardMachine[]; attachments: Attachment[] }) + } catch (e: unknown) { + flash(e instanceof Error ? e.message : 'Failed to start cash up.', false) + setPageState('editing') + } finally { + setSaving(false) + } + } + async function save(status: 'draft' | 'final') { setSaving(true) try { @@ -331,7 +352,7 @@ export function DailyCashUp({ user }: Props) { {pageState === 'empty' && (

No cash up recorded for this date.

- setPageState('editing')}>Start Cash Up + {saving ? 'Starting…' : 'Start Cash Up'}
)}