From af1560d58fcb3ca45220abddc40a4c428ad6d4ec Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Mon, 21 Sep 2026 10:50:06 +0000 Subject: [PATCH] Show refunds as refunds in transaction breakdown checklist Refunds were rendered like payments (abs value, no marker). Backend now flags items with is_refund from NewBook item_type (refunds_raised / refunds_voided) and labels the type '-refund'; frontend shows them in red with a leading minus. Co-Authored-By: Claude Sonnet 5 --- backend/src/lib/newbook.js | 4 +++- frontend/src/pages/DailyCashUp.tsx | 10 +++++++--- frontend/src/types.ts | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/backend/src/lib/newbook.js b/backend/src/lib/newbook.js index e667ebb..b788a4b 100644 --- a/backend/src/lib/newbook.js +++ b/backend/src/lib/newbook.js @@ -279,7 +279,8 @@ export function parseTransactionBreakdown(rawData) { const desc = t.item_description || '' const payType = t.payment_type || '' const isVoided = t.item_type === 'payments_voided' || t.item_type === 'refunds_voided' - const displayType = isVoided ? payType + ' -void' : payType + const isRefund = t.item_type === 'refunds_raised' || t.item_type === 'refunds_voided' + const displayType = (isRefund ? payType + ' -refund' : payType) + (isVoided ? ' -void' : '') const category = categorise(payType) const item = { @@ -288,6 +289,7 @@ export function parseTransactionBreakdown(rawData) { details: '', amount: parseFloat(t.item_amount || 0), is_voided: isVoided, + is_refund: isRefund, } const ticketMatch = desc.match(/^Ticket:\s*(\d+)\s*-\s*(.+)$/i) diff --git a/frontend/src/pages/DailyCashUp.tsx b/frontend/src/pages/DailyCashUp.tsx index 90bb27c..0d160e9 100644 --- a/frontend/src/pages/DailyCashUp.tsx +++ b/frontend/src/pages/DailyCashUp.tsx @@ -929,6 +929,8 @@ function TransactionChecklist({ breakdown, checked, onToggle }: { {items.map((item, i) => { const key = `${section}:${category}:${i}` const isDone = checked.has(key) + // Refunds are a transaction type, not a negative value — amount stays positive + const isRefund = item.is_refund return (
onToggle(key)} style={{ display: 'grid', gridTemplateColumns: '20px 1fr auto auto', @@ -949,9 +951,11 @@ function TransactionChecklist({ breakdown, checked, onToggle }: { {item.time.slice(11, 16)} )}
- {item.payment_type} - - {item.is_voided ? '-' : ''}{fmtGBP(Math.abs(item.amount))} + + {item.payment_type} + + + {item.is_voided || isRefund ? '-' : ''}{fmtGBP(Math.abs(item.amount))} ) diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 36953b0..c111722 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -75,6 +75,7 @@ export interface TransactionItem { details: string amount: number is_voided: boolean + is_refund: boolean } export interface TransactionBreakdown {