Fix cashup bugs: PDQ totals, WET placeholder, print styles, cash summary

Issue #1: Parse card machine amounts as floats in applyLoaded — pg returns
DECIMAL as strings which caused JS string concatenation in totalPdq and
reconciliation banked amounts. After draft save, reload cashUp to get the
persisted ID so PDQ Z-report uploads work on first save.

Issue #2: Guard empty gl_code in sales breakdown name-matching — an empty
column code caused gName.includes('') to always be true, making placeholder
columns (like WET 5%) match the first available GL group (dry dept).

Issue #3: Move Cash Summary above Safe Count in sidebar nav. Extend
cash-summary endpoint with per-day breakdown. Rewrite CashSummary.tsx
with a daily cash takings table above the denomination summary.

Issue #4: Add @media print CSS — hide sidebar nav, force colour printing,
style disabled inputs as plain text, and keep tables/cards intact on paper.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-07 11:25:27 +00:00
parent c2ab162870
commit 2f9b876d0d
5 changed files with 156 additions and 61 deletions

View file

@ -93,7 +93,13 @@ export function DailyCashUp({ user }: Props) {
if (data.card_machines.length) {
setMachines(MACHINES.map(name => {
const m = data.card_machines.find(c => c.machine_name === name)
return m ?? { machine_name: name, total_amount: 0, amex_amount: 0, visa_mc_amount: 0 }
if (!m) return { machine_name: name, total_amount: 0, amex_amount: 0, visa_mc_amount: 0 }
return {
...m,
total_amount: parseFloat(String(m.total_amount)) || 0,
amex_amount: parseFloat(String(m.amex_amount)) || 0,
visa_mc_amount: parseFloat(String(m.visa_mc_amount)) || 0,
}
}))
}
@ -238,6 +244,11 @@ export function DailyCashUp({ user }: Props) {
if (status === 'final') {
setCashUp(prev => prev ? { ...prev, status: 'final' } : null)
setPageState('locked')
} else {
// Reload the cashUp record to get the persisted ID (needed for attachment uploads)
api.get<{ cash_up: CashUp; denominations: Denomination[]; card_machines: CardMachine[]; reconciliation: ReconciliationRow[]; attachments: Attachment[] }>(`/cashup?date=${date}`)
.then(data => setCashUp(data.cash_up))
.catch(() => {})
}
} catch (e: unknown) {
flash(e instanceof Error ? e.message : 'Save failed.', false)