Bugzilla – Attachment 192515 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 OVERDUE fees
ea0a189.patch (text/plain), 4.49 KB, created by
Martin Renvoize (ashimema)
on 2026-02-05 08:53:59 UTC
(
hide
)
Description:
Bug 35612: Add tests for branch context recording in OVERDUE fees
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-02-05 08:53:59 UTC
Size:
4.49 KB
patch
obsolete
>From ea0a189c9cfe60b0a270656579d1f2b77d370344 Mon Sep 17 00:00:00 2001 >From: Laura_Escamilla <laura.escamilla@bywatersolutions.com> >Date: Mon, 2 Feb 2026 21:17:33 +0000 >Subject: [PATCH] Bug 35612: Add tests for branch context recording in OVERDUE > fees > >Adds comprehensive test coverage for C4::Overdues::UpdateFine to verify >that the branchcode field is correctly populated based on CircControl >and HomeOrHoldingBranch system preferences. > >Tests verify: >- CircControl = PatronLibrary uses patron's home branch >- CircControl = PickupLibrary uses checkout/issue branch >- CircControl = ItemHomeLibrary respects HomeOrHoldingBranch: > * homebranch: uses item's home library > * holdingbranch: uses item's holding library > >The tests create distinct libraries for each context (patron home, >item home, item holding, checkout branch) and verify the correct >branch is recorded in accountlines.branchcode for OVERDUE debits. > >Signed-off-by: Trevor Diamond <trevor.diamond@mainlib.org> >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > t/db_dependent/Overdues.t | 75 ++++++++++++++++++++++++++++++++++++++- > 1 file changed, 74 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Overdues.t b/t/db_dependent/Overdues.t >index f17ee28d18e..9084a1d04ed 100755 >--- a/t/db_dependent/Overdues.t >+++ b/t/db_dependent/Overdues.t >@@ -165,12 +165,85 @@ $schema->storage->txn_rollback; > > subtest 'UpdateFine tests' => sub { > >- plan tests => 75; >+ plan tests => 83; > > $schema->storage->txn_begin; > > t::lib::Mocks::mock_preference( 'MaxFine', '100' ); > >+ # Branch context tests for OVERDUE fines (Bug 35612) >+ 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 $context_patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { branchcode => $lib_patron->branchcode } >+ } >+ ); >+ >+ # Helper to create a scenario checkout/item and assert the resulting fine's branchcode >+ my $assert_overdue_branchcode = sub { >+ my ( $circ_control, $hoh, $expected_branchcode, $label ) = @_; >+ >+ t::lib::Mocks::mock_preference( 'CircControl', $circ_control ); >+ t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', $hoh ) if defined $hoh; >+ >+ 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 => $context_patron->borrowernumber, >+ branchcode => $lib_issue->branchcode, >+ } >+ } >+ ); >+ >+ UpdateFine( >+ { >+ issue_id => $checkout->issue_id, >+ itemnumber => $item->itemnumber, >+ borrowernumber => $context_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_branchcode, "$label: branchcode recorded correctly" ); >+ }; >+ >+ $assert_overdue_branchcode->( >+ 'PatronLibrary', undef, $lib_patron->branchcode, >+ 'CircControl=PatronLibrary' >+ ); >+ >+ $assert_overdue_branchcode->( >+ 'PickupLibrary', undef, $lib_issue->branchcode, >+ 'CircControl=PickupLibrary' >+ ); >+ >+ $assert_overdue_branchcode->( >+ 'ItemHomeLibrary', 'homebranch', $lib_home->branchcode, >+ 'CircControl=ItemHomeLibrary + HomeOrHoldingBranch=homebranch' >+ ); >+ >+ $assert_overdue_branchcode->( >+ 'ItemHomeLibrary', 'holdingbranch', $lib_hold->branchcode, >+ 'CircControl=ItemHomeLibrary + HomeOrHoldingBranch=holdingbranch' >+ ); >+ > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > my $item1 = $builder->build_sample_item(); > my $item2 = $builder->build_sample_item(); >-- >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