From d467c1d4bd2977e61e502a0a778fbf141c0c26fd Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 29 Jan 2026 18:17:08 +0000 Subject: [PATCH] Bug 36506: (QA follow-up) Add test for missing circulation rule This adds a test case to verify that when no lost_item_processing_fee circulation rule exists for a branch/itemtype combination, the system correctly defaults to 0 (no processing fee charged). The test confirms: - No PROCESSING account line is created when the rule is missing - The LOST fee is still created normally (only processing fee affected) - The // 0 fallback in C4::Accounts::chargelostitem works correctly Test plan: 1. prove t/db_dependent/Accounts.t 2. Verify all tests pass, including the new "missing circulation rule" test case Signed-off-by: Martin Renvoize --- t/db_dependent/Accounts.t | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t index 7d0d9c67492..2e0f0587ffd 100755 --- a/t/db_dependent/Accounts.t +++ b/t/db_dependent/Accounts.t @@ -889,7 +889,7 @@ subtest "C4::Accounts::chargelostitem tests" => sub { }; subtest "further processing fee application tests" => sub { - plan tests => 8; + plan tests => 10; my $branch_1 = $builder->build_object( { class => 'Koha::Libraries' } ); my $branch_2 = $builder->build_object( { class => 'Koha::Libraries' } ); @@ -999,6 +999,34 @@ subtest "C4::Accounts::chargelostitem tests" => sub { ok( $procfee, "Processing fee created" ); is( $procfee->amount + 0, 4, "Processing fee chosen correctly" ); + # Test missing rule defaults to 0 (no processing fee) + diag("Test missing circulation rule defaults to 0"); + my $branch_no_rule = $builder->build_object( { class => 'Koha::Libraries' } ); + $borrower = $builder->build_object( + { class => 'Koha::Patrons', value => { branchcode => $branch_no_rule->branchcode } } ); + $item = $builder->build_sample_item( { homebranch => $branch_no_rule->branchcode } ); + + t::lib::Mocks::mock_preference( 'LostChargesControl', 'PatronLibrary' ); + C4::Accounts::chargelostitem( $borrower->borrowernumber, $item->itemnumber, '1', "No rule test" ); + + $procfee = Koha::Account::Lines->find( + { + borrowernumber => $borrower->borrowernumber, + itemnumber => $item->itemnumber, + debit_type_code => 'PROCESSING' + } + ); + ok( !$procfee, "No processing fee created when circulation rule is missing" ); + + my $lostfee = Koha::Account::Lines->find( + { + borrowernumber => $borrower->borrowernumber, + itemnumber => $item->itemnumber, + debit_type_code => 'LOST' + } + ); + ok( $lostfee, "Lost fee still created even when processing fee rule is missing" ); + }; subtest "basic fields tests" => sub { -- 2.52.0