From af0124caebf284b308b4b9aef09825bafa9608e3 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 22 May 2025 11:28:54 +0000 Subject: [PATCH] Bug 38477: Only charge a new lost fine when the last patron to return the item matches the original fined patron Set these sysprefs: - FinesMode: Calculate and Charge - WhenLostForgiveFine: Forgive - WhenLostChargeReplacementFee: Charge In circ rules: - Have a rule that charges fines - Set Refund lost item replacement fee to "Refund lost item charge and charge new overdue fine" 1 - Have/create item with replacement price 2 - Check item out to patron 1, due date in past 3 - Run fines.pl 4 - confirm fines on patron 1 5 - mark item lost 6 - confirm replacement cost generated and fine forgiven on patron 1 7 - check item in 8 - confirm replacement cost forgiven and new fine generated on patron 1 9 - check item out to patron 2, due date in future 10 - check item in 11 - mark item lost (no replacement fee generated because item is not checked out) 12 - in database, update date_due for checkout to patron 2, set to a date in the past 13 - check item in 14 - confirm patron 2 now has a fine 15 - Apply patches, restart all 16 - Repeat test plan with another item and confirm no fine is added for patron 2 Note: At step 12 we're pushing the date_due of the old issue into the past to make date_due Signed-off-by: Pedro Amorim Signed-off-by: Lucas Gass (cherry picked from commit 67c95addeb903d8b22c71eb6004da7121950bbfb) Signed-off-by: Paul Derscheid (cherry picked from commit 9c81bdf529ebf65f36c1659c15f7c9fd74f5bfc6) Signed-off-by: Fridolin Somers --- C4/Circulation.pm | 5 +++++ Koha/Item.pm | 2 ++ 2 files changed, 7 insertions(+) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 80cead8a96..ab8438ae67 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2329,6 +2329,10 @@ sub AddReturn { my $patron = $issue->patron; $patron_unblessed = $patron->unblessed; } + + # Confirm the lost charge came from the most recent patron to return the item + # and only charge the fine if so + if ( $message->payload->{patron_id} == $patron_unblessed->{borrowernumber} ) { _CalculateAndUpdateFine( { issue => $issue, @@ -2344,6 +2348,7 @@ sub AddReturn { } } } + } # check if we have a transfer for this document my $transfer = $item->get_transfer; diff --git a/Koha/Item.pm b/Koha/Item.pm index 07fc6ad5c8..0de5531f1e 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -1666,10 +1666,12 @@ sub _set_found_trigger { } } elsif ( $lostreturn_policy eq 'charge' && ( $lost_overdue || $lost_charge ) ) { + my $patron_id = $lost_overdue ? $lost_overdue->borrowernumber : $lost_charge->borrowernumber; $self->add_message( { type => 'info', message => 'lost_charge', + payload => { patron_id => $patron_id } } ); }