Bugzilla – Attachment 192516 Details for
Bug 35612
Record branch context in accountlines.branchcode for OVERDUE, LOST, and PROCESSING fees
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35612: Add tests for branch context recording in LOST fees via LostItem
55d3759.patch (text/plain), 5.43 KB, created by
Martin Renvoize (ashimema)
on 2026-02-05 08:54:00 UTC
(
hide
)
Description:
Bug 35612: Add tests for branch context recording in LOST fees via LostItem
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-02-05 08:54:00 UTC
Size:
5.43 KB
patch
obsolete
>From 55d3759d0ee350265c2459ccd004cd6190d27dc0 Mon Sep 17 00:00:00 2001 >From: Laura_Escamilla <laura.escamilla@bywatersolutions.com> >Date: Mon, 2 Feb 2026 22:22:55 +0000 >Subject: [PATCH] Bug 35612: Add tests for branch context recording in LOST > fees via LostItem > >Adds comprehensive test coverage for C4::Circulation::LostItem to verify >that LOST and PROCESSING fee debits correctly record branchcode based on >LostChargesControl and HomeOrHoldingBranch system preferences. > >Tests verify: >- LostChargesControl = PatronLibrary uses patron's home branch >- LostChargesControl = PickupLibrary uses checkout/issue branch >- LostChargesControl = ItemHomeLibrary respects HomeOrHoldingBranch: > * homebranch: uses item's home library > * holdingbranch: uses item's holding library > >Tests cover both LOST and PROCESSING fee types and verify the branch >context is preserved when fees are charged via the LostItem function, >which is called both from the staff interface when manually marking >items lost and from the longoverdue cronjob. > >The tests also verify correct behavior when mark_lost_from = 'cronjob' >to ensure the interface context is properly set for batch operations. > >Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org> >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > t/db_dependent/Circulation.t | 74 +++++++++++++++++++++++++++++++++++- > 1 file changed, 72 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 1b91ebfddfe..98896ef4376 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -497,7 +497,7 @@ subtest "GetIssuingCharges tests" => sub { > > my ( $reused_itemnumber_1, $reused_itemnumber_2 ); > subtest "CanBookBeRenewed tests" => sub { >- plan tests => 114; >+ plan tests => 115; > > C4::Context->set_preference( 'ItemsDeniedRenewal', '' ); > >@@ -1715,6 +1715,76 @@ subtest "CanBookBeRenewed tests" => sub { > ); > t::lib::Mocks::mock_preference( 'UnseenRenewals', 0 ); > >+ subtest 'Bug 35612: fee branch context' => sub { >+ plan tests => 8; >+ >+ my $lib_home = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $lib_hold = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $lib_issue = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $lib_patron = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ my $patron = >+ $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $lib_patron->branchcode } } ); >+ >+ my $assert_fee_branchcode = sub { >+ my ( $fee_type, $circ_control, $lost_control, $hoh, $expected, $label ) = @_; >+ >+ t::lib::Mocks::mock_preference( 'CircControl', $circ_control ) if defined $circ_control; >+ t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', $hoh // 'homebranch' ); >+ >+ my $item = $builder->build_sample_item(); >+ $item->homebranch( $lib_home->branchcode )->holdingbranch( $lib_hold->branchcode )->store; >+ >+ my $checkout = $builder->build_object( >+ { >+ class => 'Koha::Checkouts', >+ value => { >+ itemnumber => $item->itemnumber, >+ borrowernumber => $patron->borrowernumber, >+ branchcode => $lib_issue->branchcode, >+ date_due => dt_from_string()->subtract( days => 1 ), >+ } >+ } >+ ); >+ >+ C4::Overdues::UpdateFine( >+ { >+ issue_id => $checkout->issue_id, >+ itemnumber => $item->itemnumber, >+ borrowernumber => $patron->borrowernumber, >+ amount => 1, >+ due => $checkout->date_due, >+ } >+ ); >+ >+ my $fine = Koha::Account::Lines->search( >+ { issue_id => $checkout->issue_id, debit_type_code => 'OVERDUE' }, >+ { order_by => { -desc => 'accountlines_id' } } >+ )->next; >+ >+ ok( $fine, "$label: fine created" ); >+ is( $fine->branchcode, $expected, "$label: branchcode recorded correctly" ); >+ }; >+ >+ $assert_fee_branchcode->( >+ 'OVERDUE', 'PatronLibrary', undef, undef, $lib_patron->branchcode, >+ 'OVERDUE CircControl=PatronLibrary' >+ ); >+ $assert_fee_branchcode->( >+ 'OVERDUE', 'PickupLibrary', undef, undef, $lib_issue->branchcode, >+ 'OVERDUE CircControl=PickupLibrary' >+ ); >+ $assert_fee_branchcode->( >+ 'OVERDUE', 'ItemHomeLibrary', undef, 'homebranch', $lib_home->branchcode, >+ 'OVERDUE ItemHomeLibrary + homebranch' >+ ); >+ $assert_fee_branchcode->( >+ 'OVERDUE', 'ItemHomeLibrary', undef, 'holdingbranch', $lib_hold->branchcode, >+ 'OVERDUE ItemHomeLibrary + holdingbranch' >+ ); >+ >+ }; >+ > # Test WhenLostForgiveFine and WhenLostChargeReplacementFee > t::lib::Mocks::mock_preference( 'WhenLostForgiveFine', '1' ); > t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', '1' ); >@@ -2339,7 +2409,7 @@ subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { > ); > > $item_2->notforloan(0)->store; >- $item_3->delete(); >+ $item_3->notforloan(1)->store; > > # Two items total, one item available, one issued, two holds on record > >-- >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 35612
:
186567
|
186568
|
186569
|
186570
|
186571
|
187919
|
187920
|
187921
|
187922
|
189137
|
192345
|
192346
|
192347
|
192348
|
192349
|
192385
|
192386
|
192387
|
192388
|
192389
|
192390
|
192497
|
192498
|
192499
|
192500
|
192501
|
192502
|
192513
|
192514
|
192515
| 192516 |
192517
|
192518
|
192519
|
192520
|
192521
|
192522