Bugzilla – Attachment 190413 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) Update unit tests for negative cashup amounts
b53d9cb.patch (text/plain), 2.76 KB, created by
Martin Renvoize (ashimema)
on 2025-12-10 18:37:02 UTC
(
hide
)
Description:
Bug 40445: (follow-up) Update unit tests for negative cashup amounts
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-12-10 18:37:02 UTC
Size:
2.76 KB
patch
obsolete
>From b53d9cb332be0a2644d672b2ff386e5d65256ad2 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Tue, 9 Dec 2025 17:21:23 +0000 >Subject: [PATCH] Bug 40445: (follow-up) Update unit tests for negative cashup > amounts > >Updated tests to reflect that negative amounts are now valid: > >1. start_cashup_parameter_validation - Changed expected amount test > from >= 0 to != 0, since amounts can now be negative > >2. add_cashup - Updated invalid_amount subtest: > - Removed test expecting negative amounts to throw exception > - Added test confirming negative amounts are now accepted > - Verifies negative amount is stored correctly > - Kept tests for zero, non-numeric, and empty amounts > >All other tests remain unchanged as they don't specifically test >for positive-only validation. > >To test: >prove t/db_dependent/Koha/Cash/Register.t > >Sponsored-by: OpenFifth <https://openfifth.co.uk/> >--- > t/db_dependent/Koha/Cash/Register.t | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > >diff --git a/t/db_dependent/Koha/Cash/Register.t b/t/db_dependent/Koha/Cash/Register.t >index 875a1bc9c8c..3aab7e5d3a4 100755 >--- a/t/db_dependent/Koha/Cash/Register.t >+++ b/t/db_dependent/Koha/Cash/Register.t >@@ -1325,8 +1325,8 @@ subtest 'start_cashup_parameter_validation' => sub { > my $final_action_count = $register5->_result->search_related('cash_register_actions')->count; > is( $final_action_count, $initial_action_count + 1, 'CASHUP_START action created in database' ); > >- # Verify expected amount calculation >- ok( $start->amount >= 0, 'Expected amount calculated correctly' ); >+ # Verify expected amount calculation (can be positive or negative, but not zero) >+ ok( $start->amount != 0, 'Expected amount calculated correctly' ); > > # Verify timestamp is set > ok( defined $start->timestamp, 'Timestamp is set on CASHUP_START action' ); >@@ -1388,12 +1388,13 @@ subtest 'add_cashup' => sub { > 'Koha::Exceptions::Account::AmountNotPositive', > 'Zero amount throws AmountNotPositive exception'; > >- # Negative amount >- throws_ok { >- $register3->add_cashup( { manager_id => $manager->id, amount => '-5.00' } ); >+ # Negative amount is now valid (for float deficits) >+ my $negative_cashup; >+ lives_ok { >+ $negative_cashup = $register3->add_cashup( { manager_id => $manager->id, amount => '-5.00' } ); > } >- 'Koha::Exceptions::Account::AmountNotPositive', >- 'Negative amount throws AmountNotPositive exception'; >+ 'Negative amount is accepted for float deficit scenarios'; >+ is( $negative_cashup->amount + 0, -5, 'Negative amount stored correctly' ); > > # Non-numeric amount > throws_ok { >-- >2.52.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