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:
parent
e9cf648f8c
commit
5aafc0e99f
1 changed files with 22 additions and 1 deletions
|
|
@ -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') {
|
async function save(status: 'draft' | 'final') {
|
||||||
setSaving(true)
|
setSaving(true)
|
||||||
try {
|
try {
|
||||||
|
|
@ -331,7 +352,7 @@ export function DailyCashUp({ user }: Props) {
|
||||||
{pageState === 'empty' && (
|
{pageState === 'empty' && (
|
||||||
<Card style={{ textAlign: 'center', padding: '2.5rem 1.5rem' }}>
|
<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>
|
<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>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue