From bf6a0b9df4daf8e0dbe48acad00cbd7af68a53ba Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 30 Jul 2020 09:35:38 -0400 Subject: [PATCH] Bug 26076: (QA Follow up) Prevent error by using a fresh resultset Signed-off-by: Katrin Fischer --- members/paycollect.pl | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/members/paycollect.pl b/members/paycollect.pl index a8f449e8ab..9ef0053f90 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -145,21 +145,27 @@ if ( $selected_accts ) { } my @acc = split /,/, $selected_accts; - my $selected_accountlines = Koha::Account::Lines->search( - { - borrowernumber => $borrowernumber, + my $search_params = { + borrowernumber => $borrowernumber, amountoutstanding => { '<>' => 0 }, accountlines_id => { 'in' => \@acc }, - }, + }; + + my @selected_accountlines = Koha::Account::Lines->search( + $search_params, { order_by => 'date' } ); - $total_due = $selected_accountlines->_resultset->get_column('amountoutstanding')->sum(); - - @selected_accountlines = $selected_accountlines->as_list; + my $sum = Koha::Account::Lines->search( + $search_params, + { + select => [ { sum => 'amountoutstanding' } ], + as => [ 'total_amountoutstanding'], + } + ); + $total_due = $sum->_resultset->first->get_column('total_amountoutstanding'); } - if ( $total_paid and $total_paid ne '0.00' ) { $total_paid = $total_due if (abs($total_paid - $total_due) < 0.01) && C4::Context->preference('RoundFinesAtPayment'); if ( $total_paid < 0 or $total_paid > $total_due ) { -- 2.11.0