Bugzilla – Attachment 187580 Details for
Bug 36506
Processing Fee should be configurable by branch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36506: Unit tests
Bug-36506-Unit-tests.patch (text/plain), 7.32 KB, created by
Andrew Fuerste-Henry
on 2025-10-08 13:51:41 UTC
(
hide
)
Description:
Bug 36506: Unit tests
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2025-10-08 13:51:41 UTC
Size:
7.32 KB
patch
obsolete
>From ba377991ef3f1adefd7dfc32af2e7ad8a5cc00e2 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 3 Oct 2025 16:08:05 +0000 >Subject: [PATCH] Bug 36506: Unit tests > >Sponsored-by: The Main Library Alliance <https://www.mainlib.org/> > >Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org> >--- > t/db_dependent/Accounts.t | 129 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 128 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index dbecb759fb6..7d0d9c67492 100755 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -581,7 +581,7 @@ subtest 'balance' => sub { > }; > > subtest "C4::Accounts::chargelostitem tests" => sub { >- plan tests => 3; >+ plan tests => 4; > > my $branch = $builder->build( { source => 'Branch' } ); > my $branchcode = $branch->{branchcode}; >@@ -683,6 +683,7 @@ subtest "C4::Accounts::chargelostitem tests" => sub { > > t::lib::Mocks::mock_preference( 'item-level_itypes', '1' ); > t::lib::Mocks::mock_preference( 'useDefaultReplacementCost', '0' ); >+ t::lib::Mocks::mock_preference( 'LostChargesControl', 'ItemHomeLibrary' ); > > C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber1, 0, "Perdedor" ); > $lostfine = Koha::Account::Lines->find( >@@ -887,9 +888,135 @@ subtest "C4::Accounts::chargelostitem tests" => sub { > $procfee->delete(); > }; > >+ subtest "further processing fee application tests" => sub { >+ plan tests => 8; >+ >+ my $branch_1 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $branch_2 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $branch_3 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $branch_4 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ my $one_rule = Koha::CirculationRules->set_rule( >+ { >+ itemtype => undef, branchcode => $branch_1->branchcode, rule_value => 1, >+ rule_name => 'lost_item_processing_fee' >+ } >+ ); >+ my $two_rule = Koha::CirculationRules->set_rule( >+ { >+ itemtype => undef, branchcode => $branch_2->branchcode, rule_value => 2, >+ rule_name => 'lost_item_processing_fee' >+ } >+ ); >+ my $three_rule = Koha::CirculationRules->set_rule( >+ { >+ itemtype => undef, branchcode => $branch_3->branchcode, rule_value => 3, >+ rule_name => 'lost_item_processing_fee' >+ } >+ ); >+ my $four_rule = Koha::CirculationRules->set_rule( >+ { >+ itemtype => undef, branchcode => $branch_4->branchcode, rule_value => 4, >+ rule_name => 'lost_item_processing_fee' >+ } >+ ); >+ >+ t::lib::Mocks::mock_preference( 'LostChargesControl', 'PatronLibrary' ); >+ diag("Test LostChargesControl = PatronLibrary"); >+ >+ my $borrower = >+ $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $branch_1->branchcode } } ); >+ my $item = $builder->build_sample_item( { homebranch => $branch_4->branchcode } ); >+ C4::Accounts::chargelostitem( $borrower->borrowernumber, $item->itemnumber, '1', "Branch 1 used" ); >+ $procfee = Koha::Account::Lines->find( >+ { >+ borrowernumber => $borrower->borrowernumber, itemnumber => $item->itemnumber, >+ debit_type_code => 'PROCESSING' >+ } >+ ); >+ ok( $procfee, "Processing fee created" ); >+ is( $procfee->amount + 0, 1, "Processing fee chosen correctly" ); >+ >+ t::lib::Mocks::mock_preference( 'LostChargesControl', 'PickupLibrary' ); >+ diag("Test LostChargesControl = PickupLibrary"); >+ $context->mock( >+ 'userenv', >+ sub { >+ return { >+ number => $borrower->borrowernumber, >+ branch => $branch_2->branchcode, >+ }; >+ } >+ ); >+ >+ # We can use same borrower - from branch 1 >+ $item = $builder->build_sample_item( { homebranch => $branch_4->branchcode } ) >+ ; # new item to ensure we don't create a duplicate charge >+ C4::Accounts::chargelostitem( $borrower->borrowernumber, $item->itemnumber, '2', "Branch 2 used" ); >+ $procfee = Koha::Account::Lines->find( >+ { >+ borrowernumber => $borrower->borrowernumber, itemnumber => $item->itemnumber, >+ debit_type_code => 'PROCESSING' >+ } >+ ); >+ ok( $procfee, "Processing fee created" ); >+ is( $procfee->amount + 0, 2, "Processing fee chosen correctly" ); >+ >+ t::lib::Mocks::mock_preference( 'LostChargesControl', 'ItemHomeLibrary' ); >+ diag("Test LostChargesControl = ItemhomeLibrary"); >+ >+ t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' ); >+ diag(" Test LostChargesControl = ItemhomeLibrary and HomeOrHoldingBranch = homebranch"); >+ >+ # We can use same borrower - from branch 1 >+ $item = $builder->build_sample_item( { library => $branch_3->branchcode } ); >+ $item->holdingbranch( $branch_4->branchcode ) >+ ->store; #build sample items makes them the same, ensure they are different >+ C4::Accounts::chargelostitem( $borrower->borrowernumber, $item->itemnumber, '3', "Branch 3 used" ); >+ $procfee = Koha::Account::Lines->find( >+ { >+ borrowernumber => $borrower->borrowernumber, itemnumber => $item->itemnumber, >+ debit_type_code => 'PROCESSING' >+ } >+ ); >+ ok( $procfee, "Processing fee created" ); >+ is( $procfee->amount + 0, 3, "Processing fee chosen correctly" ); >+ >+ t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'holdingbranch' ); >+ diag(" Test LostChargesControl = ItemhomeLibrary and HomeOrHoldingBranch = holdingbranch"); >+ >+ # We can use same borrower - from branch 1 >+ $item = $builder->build_sample_item( { library => $branch_4->branchcode } ); >+ $item->homebranch( $branch_3->branchcode ) >+ ->store; #build sample items makes them the same, ensure they are different >+ C4::Accounts::chargelostitem( $borrower->borrowernumber, $item->itemnumber, '4', "Branch 4 used" ); >+ $procfee = Koha::Account::Lines->find( >+ { >+ borrowernumber => $borrower->borrowernumber, itemnumber => $item->itemnumber, >+ debit_type_code => 'PROCESSING' >+ } >+ ); >+ ok( $procfee, "Processing fee created" ); >+ is( $procfee->amount + 0, 4, "Processing fee chosen correctly" ); >+ >+ }; >+ > subtest "basic fields tests" => sub { > plan tests => 12; > >+ my $staff = $builder->build( { source => 'Borrower' } ); >+ my $staff_id = $staff->{borrowernumber}; >+ $context->mock( >+ 'userenv', >+ sub { >+ return { >+ flags => 1, >+ number => $staff_id, >+ branch => $branchcode, >+ }; >+ } >+ ); >+ > t::lib::Mocks::mock_preference( 'ProcessingFeeNote', 'Test Note' ); > C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, '1.99', "Perdedor" ); > >-- >2.39.5
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 36506
:
187411
|
187412
|
187413
|
187414
|
187415
|
187416
|
187417
|
187418
|
187573
|
187574
|
187575
|
187576
|
187577
|
187578
|
187579
| 187580