Bug 22331 - Lost items that are written off gives credit when returned
Summary: Lost items that are written off gives credit when returned
Status: CLOSED WONTFIX
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: 18.05
Hardware: All All
: P5 - low normal (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-14 01:47 UTC by Benjamin Daeuber
Modified: 2020-11-30 21:45 UTC (History)
8 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Daeuber 2019-02-14 01:47:17 UTC
When a lost item is written off by the library, but later returned, Koha gives a credit for that item. To recreate:

1. Ensure "Refund lost item fee" is set to "Yes" in Circulation and Fine Rules.
2. Check out an item to a patron.
3. Mark item as lost. Replacement price should be added to their account. 
4. Write off the fee.
5. Return the item. A refund is generated.

A write off should not generate a refund in this situation. 

Is it possible this is related to Bug 19919 ?
Comment 1 Nick Clemens (kidclamp) 2019-02-15 16:49:06 UTC
The issue appears to be from incorrectly assigned 'accountno' in Koha::Account->pay

 88     # We should remove accountno, it is no longer needed
 89     my $last = $self->lines->search(
 90         {},
 91         { order_by => 'accountno' } )->next();
 92     my $accountno = $last ? $last->accountno + 1 : 1;


The default order is ASC, so we end up assigning the lowest here

Then in C4::Circulation->_FixAccountForLostAndReturned

2387     # check for charge made for lost book
2388     my $accountlines = Koha::Account::Lines->search(
2389         {
2390             itemnumber  => $itemnumber,
2391             accounttype => { -in => [ 'L', 'Rep', 'W' ] },
2392         },
2393         {
2394             order_by => { -desc => [ 'date', 'accountno' ] }
2395         }
2396     );

We order the lines by accountno to get the most recent, however, the numbers are wrong so we don't get the most recent payment or write off.
Comment 2 Martin Renvoize 2020-02-11 12:04:41 UTC
18.05 is officially end of life at this point and I believe this bug is fixed in more recent versions... certainly, accountno was removed in 19.05, though not backported to 18.11 as far as I'm aware.. at this point, I would suggest we close this bug recommend an upgrade to 19.05 or above.