From 45a8e2d8da8b1a82c41f3c17d93dc9facc465c3f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 12 Jan 2026 15:15:25 +0000 Subject: [PATCH] Bug 40445: (follow-up) Update tests for zero amount cashups The previous commit changed add_cashup() to allow amount=0 (for non-cash transaction scenarios like Card-only payments), but the tests still expected amount=0 to be rejected. This patch updates the test expectations: 1. Changed the 'invalid_amount' subtest to accept zero amounts as valid instead of expecting an exception 2. Added verification that zero amounts are stored correctly 3. Updated test plan count from 4 to 6 tests (added zero amount verification test) 4. Updated test description and comments to reflect the new behavior The zero amount scenario is now valid for cashups where there are only non-cash transactions (Card, Bank Transfer, etc.) and no physical cash to count or remove from the register. --- t/db_dependent/Koha/Cash/Register.t | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/t/db_dependent/Koha/Cash/Register.t b/t/db_dependent/Koha/Cash/Register.t index 3aab7e5d3a4..99684617a6e 100755 --- a/t/db_dependent/Koha/Cash/Register.t +++ b/t/db_dependent/Koha/Cash/Register.t @@ -1377,16 +1377,17 @@ subtest 'add_cashup' => sub { # Test 3: Invalid amount parameter subtest 'invalid_amount' => sub { - plan tests => 4; + plan tests => 6; my $register3 = $builder->build_object( { class => 'Koha::Cash::Registers' } ); - # Zero amount - throws_ok { - $register3->add_cashup( { manager_id => $manager->id, amount => '0.00' } ); + # Zero amount is now valid (for non-cash transaction scenarios) + my $zero_cashup; + lives_ok { + $zero_cashup = $register3->add_cashup( { manager_id => $manager->id, amount => '0.00' } ); } - 'Koha::Exceptions::Account::AmountNotPositive', - 'Zero amount throws AmountNotPositive exception'; + 'Zero amount is accepted for non-cash transaction scenarios'; + is( $zero_cashup->amount + 0, 0, 'Zero amount stored correctly' ); # Negative amount is now valid (for float deficits) my $negative_cashup; -- 2.52.0