Start cash up creates DB record immediately so photo uploads are available

Clicking 'Start Cash Up' now POSTs an empty draft to the backend straight
away, then reloads the record to populate cashUp.id — so PDQ Z-report and
receipt evidence uploaders are available without having to save a draft first.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-20 22:43:11 +00:00
parent e9cf648f8c
commit 5aafc0e99f

View file

@ -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' && (
<Card style={{ textAlign: 'center', padding: '2.5rem 1.5rem' }}>
<p style={{ color: 'var(--text-mid)', marginBottom: '1.25rem' }}>No cash up recorded for this date.</p>
<Btn onClick={() => setPageState('editing')}>Start Cash Up</Btn>
<Btn onClick={startCashUp} disabled={saving}>{saving ? 'Starting…' : 'Start Cash Up'}</Btn>
</Card>
)}