From 86d034e628ac4f232eada6644eeac6c2cb2c59fb Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 29 Apr 2026 18:28:43 +0100 Subject: [PATCH] Bug 40445: (follow-up) Clarify cashup summary cash row wording and sign A cashup is the process of removing cash from the till to send it to the bank, so labelling the headline cash line "Cash added to register" was confusing. Re-word it to "Cash removed from register" in the typical case and "Cash added to register" in the edge case where the cashier has had to top up the till to cover refunds. While doing this, align the sign convention of total_grouped with that of the overall total field on the summary: positive means cash collected (i.e. removed from the register at cashup time), negative means cash had to be added back into the register. Previously total_grouped used the raw accounting sign (credits negative, debits positive), so a typical $2 cash session would display "Total: 2.00" and "Cash added to register: -2.00", which was internally inconsistent. The conditions on the cash and other-payment-type rows in cashup_modal.js are swapped to match the new convention. Test plan: 1. Apply the patch and rebuild JS (yarn js:build) inside KTD. 2. As a staff user with permission to manage cash registers, take payments via several payment types (some cash, some not). 3. Trigger a cashup and view the cashup summary modal. 4. Confirm the "Total" line and the per-payment-type lines all display as positive amounts in the typical "money was collected" scenario, with the cash row labelled "Cash removed from register". 5. Issue some refunds large enough to exceed cash collected, then cash up again. 6. Confirm the cash row is labelled "Cash added to register" with a negative amount and the per-non-cash-type rows are labelled "{type} to add" where applicable. 7. Run prove t/db_dependent/Koha/Cash/Register/Cashup.t and prove t/db_dependent/Koha/Cash/Register.t inside KTD; both should pass. Sponsored-by: OpenFifth Signed-off-by: Jackie Usher Signed-off-by: Andrew Fuerste Henry Signed-off-by: Pedro Amorim --- Koha/Cash/Register/Cashup.pm | 6 +++++- koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js | 14 +++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Koha/Cash/Register/Cashup.pm b/Koha/Cash/Register/Cashup.pm index 7e6ba1ac64..0742cffeaa 100644 --- a/Koha/Cash/Register/Cashup.pm +++ b/Koha/Cash/Register/Cashup.pm @@ -184,7 +184,11 @@ sub summary { my $typed_income = $income_transactions->total( { payment_type => $type->authorised_value } ); my $typed_payout = $payout_transactions->total( { payment_type => $type->authorised_value } ); my $typed_total = ( $typed_income + $typed_payout ); - push @total_grouped, { payment_type => $type->lib, total => $typed_total }; + + # Flip sign to match the convention used for `total` above: + # positive = net amount collected (i.e. removed from register at cashup), + # negative = net amount paid out (i.e. needed to be added to register). + push @total_grouped, { payment_type => $type->lib, total => $typed_total * -1 }; } # Check for reconciliation lines separately (for footer display only) diff --git a/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js b/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js index ba236ee67c..a79a394d47 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js +++ b/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js @@ -142,7 +142,7 @@ $(document).ready(function () { "
" ); - // 2. Cash collected (amount recorded as removed from register) + // 2. Cash removed from register (positive = collected and removed at cashup) var cashCollected = null; for (type of data.summary.total_grouped) { if ( @@ -155,9 +155,9 @@ $(document).ready(function () { } if (cashCollected !== null) { var cashLabel = - cashCollected < 0 - ? __("Cash added to register") - : __("Cash collected"); + cashCollected >= 0 + ? __("Cash removed from register") + : __("Cash added to register"); tfoot.append( "" + @@ -176,13 +176,13 @@ $(document).ready(function () { type.payment_type !== "CASH" ) { var paymentTypeLabel = - type.total < 0 - ? __x("{payment_type} to add", { + type.total >= 0 + ? __x("{payment_type} collected", { payment_type: escape_str( type.payment_type ), }) - : __x("{payment_type} collected", { + : __x("{payment_type} to add", { payment_type: escape_str( type.payment_type ),