diff --git a/frontend/src/pages/FloatManagement.tsx b/frontend/src/pages/FloatManagement.tsx index 3da201a..3135ff0 100644 --- a/frontend/src/pages/FloatManagement.tsx +++ b/frontend/src/pages/FloatManagement.tsx @@ -237,7 +237,10 @@ export function FloatCountForm({ type }: { type: CountType }) { }).catch(() => {}) }, [type]) - const totalCounted = denoms.reduce((s, d) => s + d.value * (denomQtys[d.value] ?? 0), 0) + function unitVal(d: { value: number }) { + return type === 'change_tin' ? (BAG_VALUES[d.value] ?? d.value) : d.value + } + const totalCounted = denoms.reduce((s, d) => s + unitVal(d) * (denomQtys[d.value] ?? 0), 0) const totalReceipts = receipts.reduce((s, r) => s + (parseFloat(r.amount) || 0), 0) const targetAmount = type === 'petty_cash' ? pettyTarget : type === 'change_tin' ? Object.entries(changeTinTargets).reduce((s, [, v]) => s + (v || 0), 0) @@ -252,7 +255,7 @@ export function FloatCountForm({ type }: { type: CountType }) { try { const denominations = denoms.filter(d => (denomQtys[d.value] ?? 0) > 0).map(d => ({ denomination: d.value, quantity: denomQtys[d.value] ?? 0, bag_quantity: 0, - total: d.value * (denomQtys[d.value] ?? 0), + total: unitVal(d) * (denomQtys[d.value] ?? 0), })) const result = await api.post<{ count_id: number }>('/floats/save', { count_type: type, @@ -308,10 +311,15 @@ export function FloatCountForm({ type }: { type: CountType }) {

DENOMINATIONS

{denoms.map(d => { const qty = denomQtys[d.value] ?? 0 - const rowTotal = d.value * qty + const uv = unitVal(d) + const rowTotal = uv * qty + const isBag = type === 'change_tin' && BAG_VALUES[d.value] !== undefined return ( -
- {d.label} +
+
+ {d.label} + {isBag &&
{fmtGBP(uv)}/bag
} +
setDenomQtys(prev => ({ ...prev, [d.value]: parseInt(e.target.value) || 0 }))} placeholder="0" style={inpSt} /> @@ -380,7 +388,7 @@ export function FloatCountForm({ type }: { type: CountType }) { const target = parseFloat(String(changeTinTargets[d.value.toFixed(2)] ?? 0)) if (target <= 0) return null const targetUnits = unitVal > 0 ? Math.round(target / unitVal) : 0 - const counted = d.value * (denomQtys[d.value] ?? 0) + const counted = unitVal * (denomQtys[d.value] ?? 0) const needed = target - counted const orderUnits = needed > 0.005 ? Math.ceil(needed / unitVal) : 0 return { d, target, targetUnits, counted, orderUnits, unitLabel }