From 1e0becf91586b6a03d2e5681eb63483dc06cd940 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 24 Feb 2016 16:24:04 +0000 Subject: [PATCH] Bug 15908 - Remove use of recordpayment_selectaccts Test Plan: 1) Apply this patch 2) prove t/db_dependent/Accounts.t 3) Test fine payment via the "Pay selected" button Signed-off-by: Laura Slavin Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- C4/Accounts.pm | 42 --------------------------------------- members/paycollect.pl | 25 +++++++++++++++++++++-- t/db_dependent/Accounts.t | 1 - 3 files changed, 23 insertions(+), 45 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index 14487a4ad7..92df8947d0 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -44,7 +44,6 @@ BEGIN { &getrefunds &chargelostitem &ReversePayment - &recordpayment_selectaccts &WriteOffFee &purge_zero_balance_fees ); @@ -378,47 +377,6 @@ sub ReversePayment { } -=head2 recordpayment_selectaccts - - recordpayment_selectaccts($borrowernumber, $payment,$accts); - -Record payment by a patron. C<$borrowernumber> is the patron's -borrower number. C<$payment> is a floating-point number, giving the -amount that was paid. C<$accts> is an array ref to a list of -accountnos which the payment can be recorded against - -Amounts owed are paid off oldest first. That is, if the patron has a -$1 fine from Feb. 1, another $1 fine from Mar. 1, and makes a payment -of $1.50, then the oldest fine will be paid off in full, and $0.50 -will be credited to the next one. - -=cut - -sub recordpayment_selectaccts { - my ( $borrowernumber, $amount, $accts, $note ) = @_; - - my @lines = Koha::Account::Lines->search( - { - borrowernumber => $borrowernumber, - amountoutstanding => { '<>' => 0 }, - accountno => { 'IN' => $accts }, - }, - { order_by => 'date' } - ); - - return Koha::Account->new( - { - patron_id => $borrowernumber, - } - )->pay( - { - amount => $amount, - lines => \@lines, - note => $note, - } - ); -} - =head2 WriteOffFee WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note ); diff --git a/members/paycollect.pl b/members/paycollect.pl index be920e1463..a76f00765c 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -143,8 +143,29 @@ if ( $total_paid and $total_paid ne '0.00' ) { } my @acc = split /,/, $select; my $note = $input->param('selected_accts_notes'); - recordpayment_selectaccts( $borrowernumber, $total_paid, \@acc, $note ); - } else { + + my @lines = Koha::Account::Lines->search( + { + borrowernumber => $borrowernumber, + amountoutstanding => { '<>' => 0 }, + accountno => { 'IN' => \@acc }, + }, + { order_by => 'date' } + ); + + return Koha::Account->new( + { + patron_id => $borrowernumber, + } + )->pay( + { + amount => $total_paid, + lines => \@lines, + note => $note, + } + ); + } + else { my $note = $input->param('selected_accts_notes'); Koha::Account->new( { patron_id => $borrowernumber } ) ->pay( { amount => $total_paid, note => $note } ); diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t index 230a1d795d..b24a386cf5 100644 --- a/t/db_dependent/Accounts.t +++ b/t/db_dependent/Accounts.t @@ -45,7 +45,6 @@ can_ok( 'C4::Accounts', getcredits getrefunds ReversePayment - recordpayment_selectaccts WriteOffFee purge_zero_balance_fees ) ); -- 2.39.5