From 42eae2cd3a36a36fb95c01a8f956d51fc951ae20 Mon Sep 17 00:00:00 2001 From: Laura_Escamilla Date: Wed, 15 Oct 2025 15:18:38 +0000 Subject: [PATCH] Bug 35612: Updates to Circulation.pm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To test: There are dependencies for this patch so you’ll need to apply bugs 36506 and 39802 1. Create three test libraries — I used the following existing branches in K-T-D: 1. FPL (use as item’s home library) 2. CPL (use as checkout/holding library) 3. PVL (use as patron home library) 2. Create a patron with home library PVL — Olga Rivera is an example patron. 3. Create an item with: 1. homebranch = FPL 2. holdingbranch = CPL 4. System preferences: 1. FinesMode: set to Calculate and charge. 2. Within Circulation rules ensure a rule exists that charges overdue fines for the item type/branch you’re using. 5. Check out the item you created or selected to your patron and set the due date to a past date so that it is overdue.  6. Run fines: perl /usr/share/koha/bin/cronjobs/fines.pl 7. Confirm an OVERDUE fine appears on the patron’s account.  8. SQL check (expect branchcode is NULL for the OVERDUE line): SELECT accountlines_id, branchcode, debit_type_code FROM accountlines ORDER BY accountlines_id DESC LIMIT 10;  9. Apply the patch, run updatedatabase, then restart_all. 10. Enable the system preference CircControl: select an option of PatronLibrary, PickupLibrary, or ItemHomeLibrary 11. Enable the HomeOrHoldingBranch system preference: homebranch or holdingbranch (only matters when CircControl = ItemHomeLibrary) 12. Repeat steps 3-6 for the following scenarios.  1. CircControl = PatronLibrary → expect PVL (patron’s home). 2. CircControl = PickupLibrary → expect CPL (checkout/issuing branch). 3. CircControl = ItemHomeLibrary + HomeOrHoldingBranch = homebranch → expect FPL (item’s home). 4. CircControl = ItemHomeLibrary + HomeOrHoldingBranch = holdingbranch → expect CPL (item’s holding). 13. Next we’re going to test this with ‘Lost Items’ 14. Make sure WhenLostChargeReplacementFee syspref is set to Charge 15. Set the LostChargesControl syspref to one of the following PatronLibrary, PickupLibrary, or ItemHomeLibrary 16. Replacement price on the item must be > 0, otherwise no LOST debit is created. 17. First test this manually by setting the item to lost.  18. Start by confirming that an item is currently checked out to the test patron (checked out at CPL). 19. Set preferences for the scenario. 20. Mark the checked out item as lost.  21. SQL check (find the most recent LOST row): SELECT accountlines_id, branchcode, debit_type_code FROM accountlines ORDER BY accountlines_id DESC LIMIT 10; 22. Next test this by using the longoverdue cron 23. Re-checkout the item (as above), adjust longoverdue rules so cron will mark it lost. 24. Run perl /usr/share/koha/bin/cronjobs/longoverdue.pl --lost 30=1 --charge 1 --confirm --verbose 25. SQL check again for the new LOST row. 26. Test for the following scenarios: 1. LostChargesControl = PatronLibrary → expect PVL (patron’s home). 2. LostChargesControl = PickupLibrary → expect CPL (checkout/issuing branch). 3. LostChargesControl = ItemHomeLibrary + HomeOrHoldingBranch = homebranch → expect FPL (item’s home). 4. LostChargesControl = ItemHomeLibrary + HomeOrHoldingBranch = holdingbranch → expect CPL (item’s holding). 27. Make sure that if the replacement price is 0 → no LOST debit should be created. 28. And ensure that if WhenLostChargeReplacementFee = Don’t charge → no LOST debit should be created. 29. Turn FinesMode OFF (i.e., not “Calculate and charge”), run fines again → no new OVERDUE debits should be added. --- C4/Circulation.pm | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index f3e55ae152..b655e9edeb 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -4468,7 +4468,7 @@ sub LostItem { borrowernumber => $borrowernumber, } )->next; - $library_id = branch_for_fee_context( + $library_id = C4::Overdues::branch_for_fee_context( fee_type => 'LOST', patron => $patron, item => $item_obj, @@ -4476,19 +4476,22 @@ sub LostItem { ); } - Koha::Account->new( { patron_id => $borrowernumber } )->add_debit( - { - amount => $issues->{'replacementprice'} + 0, - type => 'LOST', - description => $desc, - interface => $interface, - library_id => $library_id, - item_id => $itemnumber, - ( $issues->{issue_id} ? ( issue_id => $issues->{issue_id} ) : () ), - } - ); - } + my $amount = 0 + ( $issues->{replacementprice} // 0 ); + if ( $amount > 0 ) { + Koha::Account->new( { patron_id => $borrowernumber } )->add_debit( + { + amount => $amount, + type => 'LOST', + description => $desc, + interface => $interface, + library_id => $library_id, + item_id => $itemnumber, + ( $issues->{issue_id} ? ( issue_id => $issues->{issue_id} ) : () ), + } + ); + } + } MarkIssueReturned( $borrowernumber, $itemnumber, undef, $patron->privacy, $params ) if $mark_returned; } -- 2.39.5