Bugzilla – Attachment 193135 Details for
Bug 40445
Point of Sale reconciliation input during daily summaries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40445: (follow-up) Fix backend validation for non-cash transactions
ff7e13f.patch (text/plain), 5.61 KB, created by
Martin Renvoize (ashimema)
on 2026-02-13 17:21:39 UTC
(
hide
)
Description:
Bug 40445: (follow-up) Fix backend validation for non-cash transactions
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-02-13 17:21:39 UTC
Size:
5.61 KB
patch
obsolete
>From ff7e13f68470d23827b321fcecde4960be0f9c2a Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Mon, 12 Jan 2026 15:14:41 +0000 >Subject: [PATCH] Bug 40445: (follow-up) Fix backend validation for non-cash > transactions > >The previous commits fixed the frontend to allow cashup buttons when >there are non-cash transactions, but the backend validation was still >restricting cashups to cash-only scenarios. > >This patch fixes the backend validation in Koha::Cash::Register: > >1. start_cashup() - Changed validation to check for ANY transactions > instead of only CASH/SIP00 transactions. This allows starting a > cashup when there are Card or other non-cash payment types. > >2. add_cashup() - Removed the requirement that amount must be non-zero. > When there are only non-cash transactions, the cashup amount can > legitimately be 0.00 (no cash to count/remove). > >3. Updated error messages in register.tt to reflect the new validation > logic (removed references to "cash transactions" and "non-zero"). > >Without these backend fixes, the frontend changes would still result in >validation errors when users attempted cashups with only non-cash >transactions. > >Test plan: >1. Create transactions on a register using only Card payment type >2. Attempt to start a cashup - should succeed (not throw BadValue exception) >3. Enter 0.00 as the cashup amount - should complete successfully >4. Verify no surplus/deficit lines are created (balanced cashup) >5. Attempt to start cashup with zero transactions - should still fail > with appropriate error message > >Signed-off-by: Jackie Usher <jackie.usher@westsussex.gov.uk> >--- > Koha/Cash/Register.pm | 15 ++++++++------- > .../intranet-tmpl/prog/en/modules/pos/register.tt | 7 ++++--- > 2 files changed, 12 insertions(+), 10 deletions(-) > >diff --git a/Koha/Cash/Register.pm b/Koha/Cash/Register.pm >index ba2a9e5aa5c..aa9168b541e 100644 >--- a/Koha/Cash/Register.pm >+++ b/Koha/Cash/Register.pm >@@ -291,12 +291,13 @@ sub start_cashup { > > my $expected_amount = $self->outstanding_accountlines->total( { payment_type => [ 'CASH', 'SIP00' ] } ) * -1; > >- # Prevent starting a cashup when there are no cash transactions >- unless ( $expected_amount != 0 ) { >+ # Prevent starting a cashup when there are no transactions at all >+ my $total_transactions = $self->outstanding_accountlines->total() * -1; >+ unless ( $total_transactions != 0 ) { > Koha::Exceptions::Object::BadValue->throw( >- error => "Cannot start cashup with zero cash transactions", >+ error => "Cannot start cashup with no transactions", > type => 'amount', >- value => $expected_amount >+ value => $total_transactions > ); > } > >@@ -345,10 +346,10 @@ sub add_cashup { > } > my $manager_id = $params->{manager_id}; > >- # Validate amount is a non-zero number >+ # Validate amount is a valid number > my $amount = $params->{amount}; >- unless ( looks_like_number($amount) && $amount != 0 ) { >- Koha::Exceptions::Account::AmountNotPositive->throw( error => 'Cashup amount must be a non-zero number' ); >+ unless ( looks_like_number($amount) ) { >+ Koha::Exceptions::Account::AmountNotPositive->throw( error => 'Cashup amount must be a valid number' ); > } > > # Sanitize reconciliation note - treat empty/whitespace-only as undef >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt >index f85cb5c982e..13fe42f07cb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt >@@ -57,7 +57,7 @@ > [% END %] > > [% IF ( error_cashup_no_transactions ) %] >- <div id="error_message" class="alert alert-info"> Cannot start cashup - there are no cash transactions in this register since the last cashup. </div> >+ <div id="error_message" class="alert alert-info"> Cannot start cashup - there are no transactions in this register since the last cashup. </div> > [% END %] > > [% IF ( error_no_cashup_start ) %] >@@ -77,7 +77,7 @@ > [% END %] > > [% IF ( error_cashup_amount_invalid ) %] >- <div id="error_message" class="alert alert-warning"> The cashup amount must be a positive number greater than zero. </div> >+ <div id="error_message" class="alert alert-warning"> The cashup amount must be a valid number. </div> > [% END %] > > [% IF ( error_reconciliation_note_required ) %] >@@ -109,12 +109,13 @@ > [% END %] > > [% SET total_bankable = accountlines.total( payment_type => [ 'CASH', 'SIP00' ]) * -1 %] >+ [% SET total_transactions = accountlines.total() * -1 %] > [% IF ( CAN_user_cash_management_cashup ) %] > <div id="toolbar" class="btn-toolbar"> > [% IF cashup_in_progress %] > <button id="pos_complete_cashup" type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#confirmCashupModal"> <i class="fa-solid fa-check"></i> Complete cashup </button> > [% ELSE %] >- <button type="button" class="btn btn-default" data-bs-toggle="modal" data-bs-target="#triggerCashupModal" [% IF total_bankable == 0 %]disabled title="No bankable transactions"[% END %]> >+ <button type="button" class="btn btn-default" data-bs-toggle="modal" data-bs-target="#triggerCashupModal" [% IF total_transactions == 0 %]disabled title="No transactions"[% END %]> > <i class="fa fa-money-bill-alt"></i> Record cashup > </button> > [% END %] >-- >2.53.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40445
:
185289
|
185290
|
185291
|
185292
|
185809
|
186636
|
186637
|
186638
|
186639
|
186640
|
186641
|
186642
|
186643
|
189333
|
189334
|
189335
|
189336
|
189337
|
189338
|
189339
|
189340
|
189341
|
189353
|
189354
|
189355
|
189356
|
189357
|
189358
|
189359
|
189360
|
189361
|
189362
|
189363
|
189364
|
189410
|
189411
|
189412
|
189413
|
189414
|
189415
|
189420
|
189421
|
189422
|
189423
|
189424
|
189425
|
189426
|
189427
|
189428
|
189429
|
189430
|
189476
|
189477
|
189478
|
189479
|
189480
|
189481
|
189482
|
190361
|
190362
|
190363
|
190364
|
190365
|
190366
|
190367
|
190368
|
190369
|
190370
|
190371
|
190372
|
190373
|
190374
|
190375
|
190376
|
190379
|
190380
|
190388
|
190389
|
190404
|
190405
|
190406
|
190407
|
190408
|
190409
|
190410
|
190411
|
190412
|
190413
|
190414
|
190415
|
191273
|
191274
|
191275
|
191276
|
191277
|
191278
|
191279
|
191280
|
191281
|
191282
|
191283
|
191284
|
191285
|
191286
|
191287
|
191288
|
193123
|
193124
|
193125
|
193126
|
193127
|
193128
|
193129
|
193130
|
193131
|
193132
|
193133
|
193134
|
193135
|
193136
|
193137
|
193138
|
193139
|
193140
|
193141
|
193180
|
193181
|
193182
|
193183