Bug 23018: Refunding a lost item fee may trigger error if any fee has been written...
authorKyle M Hall <kyle@bywatersolutions.com>
Thu, 30 May 2019 18:15:52 +0000 (14:15 -0400)
committerFridolin Somers <fridolin.somers@biblibre.com>
Tue, 30 Jul 2019 05:34:44 +0000 (07:34 +0200)
commit357d2c58e47e9abe72b8b0221d066f49c0707176
tree22955f2e4fbadce552dc951d1ff56ea11821b56a
parent87e0e88468e4af97426e4027b96d3c18d23d3e98
Bug 23018: Refunding a lost item fee may trigger error if any fee has been written off related to that item

If a lost item fee is written off, it creates a writeoff with the same itemnumber but the amount column is a negative number.

Now, when the lost item is returned, it calls _FixAccountForLostAndReturned which searchs for all accountlines with an account type of 'L' or 'W'.

Then, if the *first* of those lines has an outstanding balance, a credit is created and *all* the lines found are passed to $credit->apply. The apply method then calls is_debit on each line and when it hits the writeoff, it throws an exception ( Koha::Exceptions::Account::IsNotDebit ).

When this happens, the credit is creating but not applied the the outstanding lost item fee, and the librarian is presented with an error page.

It seems like the solution is to only fetch the first result since it seems like that is the only one we should be operating on.

Test Plan:
1) Create a lost item with a fee
2) Create a manual debit using the barcode of the item
3) Write off that manual debit
4) Check in the item, note the error
5) Apply this patch
6) Repeat steps 1-3
7) Check in the item, no error!

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit d4f41cc8aafbb9854b20d1de7115a81e1eb73b9c)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
C4/Circulation.pm