Cashup: fix exchange table — show all over-par denominations
Was filtering out any denomination with target=0 before checking if it was counted, so notes (default target £0) never appeared even when surplus. Now: skip only shortfalls where no target is set; surpluses always show. Also use denom.target from the saved record (backend already populates this) instead of current-settings lookup. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4b0b73c520
commit
5fe8fe2814
1 changed files with 4 additions and 3 deletions
|
|
@ -76,12 +76,13 @@ function FloatRecordPrint({ record, changeTinTargets, onClose, closeLabel = 'New
|
|||
|
||||
// Build exchange table for change tin: surplus → "to bank", shortfall → "in exchange"
|
||||
const exchangeRows = isTin ? CHANGE_TIN_DENOMS.map(d => {
|
||||
const tgt = parseFloat(String(changeTinTargets[d.value.toFixed(2)] ?? 0))
|
||||
if (tgt <= 0) return null
|
||||
const denom = record.denominations.find(x => Math.abs(parseFloat(x.denomination_value) - d.value) < 0.001)
|
||||
// Use per-denom target from the saved record (backend populates this); fall back to current settings
|
||||
const tgt = parseFloat(String(denom?.target ?? changeTinTargets[d.value.toFixed(2)] ?? 0))
|
||||
const counted = parseFloat(denom?.total_amount ?? '0')
|
||||
const diff = counted - tgt
|
||||
if (Math.abs(diff) < 0.005) return null
|
||||
if (Math.abs(diff) < 0.005) return null // at par — nothing to exchange
|
||||
if (diff < 0 && tgt <= 0) return null // shortfall but no target set — skip
|
||||
return {
|
||||
label: d.label,
|
||||
toBank: diff > 0 ? diff : 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue