Bug 41109

Summary: Incorrect patron information when previously overdue and lost book is returned after item is marked lost when not checked out
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: Fines and feesAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low    
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Crowdfunding goal: 0
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Nick Clemens (kidclamp) 2025-10-27 15:01:02 UTC
The issue is that when charging a new overdue fine, the previous fine is left as 'OVERDUE' /  'LOST' which triggers a message of 'lost_charge' which pulls the info for the latest patron to return the item. Even if the info doesn't match a lost charge, we display it

To recreate:
1 - Set the Default lost item fee refund on return policy - to 'charge' (Refund lost item charge and charge new overdue fee)
2 - Ensure circulation rule for item has fine amount and interval
3 - Set system preference WhenLostChargeReplacementFee to charge 
4 - Checkout an item with a replacement fee set, backdating a month
5 - Have syspref  DefaultLongOverdueChargeValue and DefaultLongOverdueLostValue set to same value and DefaultLongOverdueDays to 10
6 - perl misc/cronjobs/fines.pl
7 - View patron account, confirm overdue charged
8 - perl misc/cronjobs/longoverdue.pl  --confirm
9 - View patron account, confirm item lost and lost fine charged
10 - Checkin the item
11 - Check the patron's accountlines
     SELECT * FROM accountlines WHERE borrowernumber=### AND debit_type_code='OVERDUE'
12 - Note that there are two, the original with status 'LOST' and a new one with status 'FOUND'
13 - Ensure syspref  ShowAllCheckins is set to 'Show'
14 - Check out the item to another patron, and return it
15 - Mark the item lost
16 - Check it in again
17 - You see the name of the patron from step 14