Bugzilla – Attachment 193137 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 two-stage cashup completion not saving
3ed69bb.patch (text/plain), 4.84 KB, created by
Martin Renvoize (ashimema)
on 2026-02-13 17:21:42 UTC
(
hide
)
Description:
Bug 40445: (follow-up) Fix two-stage cashup completion not saving
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-02-13 17:21:42 UTC
Size:
4.84 KB
patch
obsolete
>From 3ed69bb1fe016b61612824f15d289c1771ab72b9 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Mon, 12 Jan 2026 15:15:12 +0000 >Subject: [PATCH] Bug 40445: (follow-up) Fix two-stage cashup completion not > saving >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >When attempting to complete a two-stage cashup, the submission was >failing silently and not recording the cashup completion. This was >caused by two bugs: > >1. Backend bug: pos/registers.pl was ignoring the user-entered amount > and reconciliation note from the form submission. Instead of reading > the 'amount' parameter from the form, it was recalculating the > expected amount, which meant reconciliation (surplus/deficit) was > never performed. > >2. Frontend bug: The JavaScript modal handler was crashing when trying > to parse the expected amount because jQuery's .data() method returns > a number (not a string) when the value looks numeric. The code was > calling .replace() on this number, which caused a TypeError. This > crash prevented the registerid from being set in the hidden form > field, causing the form submission to be ignored by the backend. > >Test plan: >1. Create some cash transactions on a register >2. Click "Record cashup" รข "Start cashup" >3. Click "Complete cashup" and enter an amount different from expected >4. Add a reconciliation note >5. Click "Complete cashup" >6. Verify the cashup completes successfully >7. Verify a CASHUP_SURPLUS or CASHUP_DEFICIT accountline was created >8. Verify the reconciliation note was saved > >Signed-off-by: Jackie Usher <jackie.usher@westsussex.gov.uk> >--- > .../prog/js/modals/cashup_modals.js | 6 +++- > pos/registers.pl | 33 +++++++++++++------ > 2 files changed, 28 insertions(+), 11 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/cashup_modals.js b/koha-tmpl/intranet-tmpl/prog/js/modals/cashup_modals.js >index 853c0319de8..34c82d3a85d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/modals/cashup_modals.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/modals/cashup_modals.js >@@ -243,7 +243,11 @@ function initConfirmCashupModal(modalSelector, options) { > modal.find(".register-id-field").val(rid); > > // Parse expected amount to check if negative >- var expectedAmount = expected.replace(/[^0-9.-]/g, ""); >+ // Convert to string first in case jQuery's .data() parsed it as a number >+ var expectedAmount = String(expected || "").replace( >+ /[^0-9.-]/g, >+ "" >+ ); > var isNegative = parseFloat(expectedAmount) < 0; > > // Update labels based on sign >diff --git a/pos/registers.pl b/pos/registers.pl >index 251363e01df..8e4543772c7 100755 >--- a/pos/registers.pl >+++ b/pos/registers.pl >@@ -166,19 +166,32 @@ if ( $op eq 'cud-cashup_start' ) { > next unless $register; > > eval { >- # Quick cashup: calculate expected amount from outstanding accountlines >- my $expected_amount = >- $register->outstanding_accountlines->total( { payment_type => [ 'CASH', 'SIP00' ] } ) * -1; >+ # Get the amount from the request parameter >+ # For quick cashup, this will be the expected amount set by JavaScript >+ # For two-stage cashup completion, this will be the user-entered actual amount >+ my $amount = $input->param('amount'); >+ >+ # If no amount provided, calculate expected amount (backwards compatibility) >+ unless ( defined $amount && $amount ne '' ) { >+ $amount = >+ $register->outstanding_accountlines->total( { payment_type => [ 'CASH', 'SIP00' ] } ) * -1; >+ } > >- # Quick cashup assumes actual amount equals expected (no reconciliation needed) >- $register->add_cashup( >- { >- manager_id => $logged_in_user->id, >- amount => $expected_amount, >+ # Get optional reconciliation note >+ my $reconciliation_note = $input->param('reconciliation_note'); > >- # No reconciliation_note = quick cashup assumes correct amounts >- } >+ # Complete the cashup >+ my %cashup_params = ( >+ manager_id => $logged_in_user->id, >+ amount => $amount, > ); >+ >+ # Add reconciliation note if provided >+ if ( defined $reconciliation_note && $reconciliation_note ne '' ) { >+ $cashup_params{reconciliation_note} = $reconciliation_note; >+ } >+ >+ $register->add_cashup( \%cashup_params ); > $success_count++; > }; > if ($@) { >-- >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