To confirm: - have an item checked out - mark it lost, generating a fee on the patron account - check it in, generating a full refund on the patron account - mark the item lost again (it doesn't matter if it's checked out to another patron or not) - go to moredetail.pl, see your item shows "Paid for: [your patron]" Bug 19919 introduced logic to determine whether or not an item had previously been lost and then paid for. It will show the "Paid for" message and a patron's name and barcode if: - the item is currently lost - there is an accountlines entry linked to that item number with the following qualities: -- accountlines.debit_type_code = LOST -- accountlines.status != 'RETURNED' -- accountlines.amountoutstanding = 0 So, show this if the item has an associated charge that reached $0 via means other than a return. But when a lost item gets checked in we update that status to "FOUND" and anyway the debit for a lost item that gets paid off has a NULL status, so it won't be found by looking for status != "FOUND". Would it work to look for lines with debit_type_code='LOST', amoundoutstanding=0, and status IS NULL? I don't have a good enough handle on accountlines statuses to be sure.
It seems to me like we should use the issue_id to link the accountlines and the issue, so there can be no mistake in who the patron in question was. As we have issue_id and old_issue_id on accountlines now, that would also be the saves approach for items that have already been returned. I think using the status won't work, as some libraries return lost items immediately when the status is set, but it doesn't tell you if the amount has been paid or not.
Backing up a step, under which circumstances are we looking to show a patron here? For a library that doesn't refund paid lost fees when an item is found, the current logic could lead to misleading info on the screen when an item is paid for, returned, and later lost again. The same would be true for libraries that retain the item record in Koha when replacing the physical item. It seems like what we're really aiming for here is to show a patron's name if they are the patron who caused and then paid for the item's *current* lost-ness. But Koha doesn't really have a conception of instances of lostness.
Responding to Andrew's last comment, what you're describing is what I would expect that field to be: who lost and literally paid for the item which is still currently lost. If it gets returned, I would want/expect the "Paid for" field to go away. Hope that drop in the information bucket is somewhat helpful.