Bugzilla – Attachment 192349 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: Unit tests - Accounts.t
Bug-35612-Unit-tests---Accountst.patch (text/plain), 6.38 KB, created by
Laura Escamilla
on 2026-02-02 22:54:05 UTC
(
hide
)
Description:
Bug 35612: Unit tests - Accounts.t
Filename:
MIME Type:
Creator:
Laura Escamilla
Created:
2026-02-02 22:54:05 UTC
Size:
6.38 KB
patch
obsolete
>From aa35b8011999bd09c62293426e0219ba83b6967f Mon Sep 17 00:00:00 2001 >From: Laura_Escamilla <laura.escamilla@bywatersolutions.com> >Date: Mon, 2 Feb 2026 22:51:41 +0000 >Subject: [PATCH] Bug 35612: Unit tests - Accounts.t > >--- > t/db_dependent/Accounts.t | 140 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 138 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index 2e0f0587ff..1f98dfafcf 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 => 4; >+ plan tests => 5; > > my $branch = $builder->build( { source => 'Branch' } ); > my $branchcode = $branch->{branchcode}; >@@ -678,6 +678,139 @@ subtest "C4::Accounts::chargelostitem tests" => sub { > my $lostfine; > my $procfee; > >+ subtest "Bug 35612: chargelostitem records branch context in accountlines.branchcode" => sub { >+ plan tests => 7; >+ >+ t::lib::Mocks::mock_preference( 'LostChargesControl', 'ItemHomeLibrary' ); >+ t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' ); >+ >+ my $lib_home = $builder->build( { source => 'Branch' } )->{branchcode}; >+ my $lib_hold = $builder->build( { source => 'Branch' } )->{branchcode}; >+ my $lib_issue = $builder->build( { source => 'Branch' } )->{branchcode}; >+ my $lib_patron = $builder->build( { source => 'Branch' } )->{branchcode}; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $lib_patron } } ); >+ >+ my $item = $builder->build_sample_item(); >+ $item->homebranch($lib_home)->holdingbranch($lib_hold)->store; >+ >+ my $issue_id = $builder->build( >+ { >+ source => 'Issue', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ itemnumber => $item->itemnumber, >+ branchcode => $lib_issue, >+ } >+ } >+ )->{issue_id}; >+ >+ my $fake_user_branch = $builder->build( { source => 'Branch' } )->{branchcode}; >+ my $module = Test::MockModule->new('C4::Context'); >+ $module->mock( >+ 'userenv', >+ sub { >+ return { >+ flags => 1, >+ number => $patron->borrowernumber, >+ branch => $fake_user_branch, >+ }; >+ } >+ ); >+ >+ t::lib::Mocks::mock_preference( 'item-level_itypes', 1 ); >+ t::lib::Mocks::mock_preference( 'useDefaultReplacementCost', 0 ); >+ >+ t::lib::Mocks::mock_preference( 'LostChargesControl', 'PatronLibrary' ); >+ t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' ); >+ >+ C4::Accounts::chargelostitem( >+ $patron->borrowernumber, >+ $item->itemnumber, >+ 6.12, >+ "Lost test", >+ { issue_id => $issue_id } >+ ); >+ >+ my $lost = Koha::Account::Lines->find( >+ { >+ borrowernumber => $patron->borrowernumber, itemnumber => $item->itemnumber, debit_type_code => 'LOST', >+ issue_id => $issue_id >+ } >+ ); >+ ok( $lost, "LOST line created" ); >+ is( $lost->branchcode, $lib_patron, "LOST uses PatronLibrary context branchcode" ); >+ >+ $lost->delete; >+ >+ t::lib::Mocks::mock_preference( 'LostChargesControl', 'ItemHomeLibrary' ); >+ t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'holdingbranch' ); >+ >+ C4::Accounts::chargelostitem( >+ $patron->borrowernumber, >+ $item->itemnumber, >+ 6.12, >+ "Lost test 2", >+ { issue_id => $issue_id } >+ ); >+ >+ $lost = Koha::Account::Lines->find( >+ { >+ borrowernumber => $patron->borrowernumber, itemnumber => $item->itemnumber, debit_type_code => 'LOST', >+ issue_id => $issue_id >+ } >+ ); >+ ok( $lost, "LOST line created (case 2)" ); >+ is( $lost->branchcode, $lib_hold, "LOST uses item holdingbranch when HomeOrHoldingBranch=holdingbranch" ); >+ $lost->delete; >+ >+ C4::Accounts::chargelostitem( >+ $patron->borrowernumber, >+ $item->itemnumber, >+ 6.12, >+ "Lost test 3", >+ { issue_id => $issue_id, library_id => $lib_issue } >+ ); >+ >+ $lost = Koha::Account::Lines->find( >+ { >+ borrowernumber => $patron->borrowernumber, itemnumber => $item->itemnumber, debit_type_code => 'LOST', >+ issue_id => $issue_id >+ } >+ ); >+ >+ ok( $lost, "LOST line created (override)" ); >+ is( $lost->branchcode, $lib_issue, "Explicit library_id is recorded as branchcode" ); >+ $lost->delete; >+ >+ C4::Accounts::chargelostitem( >+ $patron->borrowernumber, >+ $item->itemnumber, >+ 6.12, >+ "Lost test dedupe", >+ { issue_id => $issue_id, library_id => $lib_issue } >+ ); >+ >+ C4::Accounts::chargelostitem( >+ $patron->borrowernumber, >+ $item->itemnumber, >+ 6.12, >+ "Lost test dedupe", >+ { issue_id => $issue_id, library_id => $lib_issue } >+ ); >+ >+ is( >+ Koha::Account::Lines->search( >+ { >+ borrowernumber => $patron->borrowernumber, itemnumber => $item->itemnumber, >+ debit_type_code => 'LOST', issue_id => $issue_id >+ } >+ )->count, >+ 1, >+ "Dedupes LOST charges for same itemnumber + issue_id (no item_id regression)" >+ ); >+ }; >+ > subtest "fee application tests" => sub { > plan tests => 48; > >@@ -1046,7 +1179,10 @@ subtest "C4::Accounts::chargelostitem tests" => sub { > ); > > t::lib::Mocks::mock_preference( 'ProcessingFeeNote', 'Test Note' ); >- C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, '1.99', "Perdedor" ); >+ C4::Accounts::chargelostitem( >+ $cli_borrowernumber, $cli_itemnumber4, '1.99', "Perdedor", >+ { library_id => $branchcode, issue_id => $cli_issue_id_4X } >+ ); > > # Lost Item Fee > $lostfine = Koha::Account::Lines->find( >-- >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 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