From e17f3f3674224427c6c70f2d39806e15dba1f468 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 11 May 2017 15:58:11 +0100 Subject: [PATCH] Bug 18580 - Restore handling -ve amts in Account->pay The older api handled accountlines with a negative amountoutstanding this meant that credit amounts were applied to the user's balance and negative amountoutstanding were cleared to 0 rather than credits and paid fines persisting in the user display. This restores this behaviour and indicates in a comment why our selection needs to be not zero rather than greater than 0 --- Koha/Account.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Koha/Account.pm b/Koha/Account.pm index 9ec1c1b..662203b 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -131,11 +131,12 @@ sub pay { # Were not passed a specific line to pay, or the payment was for more # than the what was owed on the given line. In that case pay down other # lines with remaining balance. - my @outstanding_fines; - @outstanding_fines = Koha::Account::Lines->search( + # We select all lines with both positive and negative amountoutstanding + # this allows credits to be applied by the logic below and negative balances to be cleared + my @outstanding_fines = Koha::Account::Lines->search( { borrowernumber => $self->{patron_id}, - amountoutstanding => { '>' => 0 }, + amountoutstanding => { '<>' => 0 }, } ) if $balance_remaining > 0; -- 2.9.3