@@ -, +, @@ --- C4/Accounts.pm | 42 ------------------------------------------ members/paycollect.pl | 24 ++++++++++++++++++++++-- t/db_dependent/Accounts.t | 1 - 3 files changed, 22 insertions(+), 45 deletions(-) --- a/C4/Accounts.pm +++ a/C4/Accounts.pm @@ -46,7 +46,6 @@ BEGIN { &chargelostitem &ReversePayment &makepartialpayment - &recordpayment_selectaccts &WriteOffFee &purge_zero_balance_fees ); @@ -353,47 +352,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, - } - ); -} - sub makepartialpayment { my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_; --- a/members/paycollect.pl +++ a/members/paycollect.pl @@ -132,8 +132,28 @@ 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, + 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 } ); --- a/t/db_dependent/Accounts.t +++ a/t/db_dependent/Accounts.t @@ -45,7 +45,6 @@ can_ok( 'C4::Accounts', getcredits getrefunds ReversePayment - recordpayment_selectaccts makepartialpayment WriteOffFee purge_zero_balance_fees ) --