Bugzilla – Attachment 189363 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: Prevent starting cashup with zero cash transactions
Bug-40445-Prevent-starting-cashup-with-zero-cash-t.patch (text/plain), 5.28 KB, created by
Martin Renvoize (ashimema)
on 2025-11-07 17:07:46 UTC
(
hide
)
Description:
Bug 40445: Prevent starting cashup with zero cash transactions
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-11-07 17:07:46 UTC
Size:
5.28 KB
patch
obsolete
>From 8a61535e636de534faeff95eab88cb8d49ec96a2 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Fri, 7 Nov 2025 16:39:54 +0000 >Subject: [PATCH] Bug 40445: Prevent starting cashup with zero cash > transactions > >In the two-phase cashup workflow, users could start a cashup session >when there were no cash transactions, but then get trapped unable to >complete it because the completion validation requires amount > 0. > >This creates a poor user experience where: >1. User starts cashup (allowed with 0 expected amount) >2. Modal shows "Expected cashup amount: 0.00" >3. User enters "0" as actual amount >4. Validation fails: "amount must be positive number greater than zero" >5. User is stuck - cannot complete, cashup session remains open > >This patch prevents the trap by validating at cashup start time: > >Backend changes: >- start_cashup() now checks if expected_amount > 0 >- Throws Koha::Exceptions::Object::BadValue if no transactions exist >- Prevents creating a cashup session that cannot be completed > >Error handling: >- pos/register.pl catches BadValue and displays informative message >- pos/registers.pl catches BadValue for multi-register cashup >- Error message clearly explains no transactions exist to cashup > >UI changes: >- Added error_cashup_no_transactions template parameter >- Displays as alert-info (informational) rather than alert-warning >- Message: "Cannot start cashup - there are no cash transactions > in this register since the last cashup" > >This validates the business rule consistently: cashups require cash >transactions. Users are informed upfront rather than getting trapped >in an incomplete workflow. > >Test plan: >1. Start a register with no cash transactions since last cashup >2. Attempt to start a cashup (two-phase workflow) >3. Verify error message appears preventing cashup start >4. Add a cash transaction to the register >5. Attempt to start cashup again >6. Verify cashup starts successfully >7. Test multi-register cashup on registers page >8. Verify appropriate error for registers with no transactions >--- > Koha/Cash/Register.pm | 9 +++++++++ > koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt | 4 ++++ > pos/register.pl | 2 ++ > pos/registers.pl | 2 ++ > 4 files changed, 17 insertions(+) > >diff --git a/Koha/Cash/Register.pm b/Koha/Cash/Register.pm >index efb4d8620b4..3261ca1ff11 100644 >--- a/Koha/Cash/Register.pm >+++ b/Koha/Cash/Register.pm >@@ -291,6 +291,15 @@ sub start_cashup { > > my $expected_amount = abs( $self->outstanding_accountlines->total( { payment_type => [ 'CASH', 'SIP00' ] } ) ); > >+ # Prevent starting a cashup when there are no cash transactions >+ unless ( $expected_amount > 0 ) { >+ Koha::Exceptions::Object::BadValue->throw( >+ error => "Cannot start cashup with zero cash transactions", >+ type => 'amount', >+ value => $expected_amount >+ ); >+ } >+ > # Create the CASHUP_START action using centralized exception handling > my $schema = $self->_result->result_source->schema; > my $rs = $schema->safe_do( >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 53ec4dbda88..a23383c01e0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt >@@ -56,6 +56,10 @@ > <div id="error_message" class="alert alert-warning"> A cashup is already in progress for this register. </div> > [% 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> >+ [% END %] >+ > [% IF ( error_no_cashup_start ) %] > <div id="error_message" class="alert alert-warning"> No cashup session has been started. Please start a cashup before attempting to complete it. </div> > [% END %] >diff --git a/pos/register.pl b/pos/register.pl >index 41d62fff656..3a9524adfe4 100755 >--- a/pos/register.pl >+++ b/pos/register.pl >@@ -117,6 +117,8 @@ if ( !$registers->count ) { > if ($@) { > if ( $@->isa('Koha::Exceptions::Object::DuplicateID') ) { > $template->param( error_cashup_in_progress => 1 ); >+ } elsif ( $@->isa('Koha::Exceptions::Object::BadValue') ) { >+ $template->param( error_cashup_no_transactions => 1 ); > } else { > $template->param( error_cashup_start => 1 ); > } >diff --git a/pos/registers.pl b/pos/registers.pl >index 071a4a17824..2dc7e0fa441 100755 >--- a/pos/registers.pl >+++ b/pos/registers.pl >@@ -98,6 +98,8 @@ if ( $op eq 'cud-cashup_start' ) { > if ($@) { > if ( $@->isa('Koha::Exceptions::Object::DuplicateID') ) { > push @errors, "Register " . $register->name . ": Cashup already in progress"; >+ } elsif ( $@->isa('Koha::Exceptions::Object::BadValue') ) { >+ push @errors, "Register " . $register->name . ": No cash transactions to cashup"; > } else { > push @errors, "Register " . $register->name . ": Failed to start cashup"; > } >-- >2.51.1
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