Bug 30254 fixed this something like this previously. We're seeing erroneous fines created for patrons who previously returned something on time. In production, this occurs when an item is marked lost while not checked out to a patron. When that item is later found and checked in, Koha finds the most recent checkout and generates an overdue fine using the current date as the return date of the item (even though the item was returned at some point in the past). 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 At step 12 we're pushing the date_due of the old issue into the past to make date_due<curdate(). In production, this comes up when there are days between steps 10 and 13.
AddReturn does some stuff, eventually calls Item->store In Koha::Item->store we call _set_found_trigger _set_found_trigger adds a 'lost_charge' message to the item if we have found a previous lost or overdue lost accountline and the rule is set to charge a new fine This gets passed back to AddReturn which looks for the last issue of the item, and charges a new fine from the previous due_date until today I believe what we need to do is: 1 - Verify the lost charge found in _set_found_trigger is the same patron we are charging now 2 - Verify the issue was not returned since the issue Current thoughts: Store the borrowernumber in the item_lost entry in statistics when marking an item lost - then we can verify that current lost is attributed to patron Pass the patroid from the lost fine found in _set_found_trigger back to AddReturn and verify the patron is the same as the one with the issue