@@ -, +, @@ but make the payment for less then the full amount --- C4/Accounts.pm | 21 --------------------- members/paycollect.pl | 15 ++++++++++++--- t/db_dependent/Accounts.t | 12 ++++-------- 3 files changed, 16 insertions(+), 32 deletions(-) --- a/C4/Accounts.pm +++ a/C4/Accounts.pm @@ -45,7 +45,6 @@ BEGIN { &getrefunds &chargelostitem &ReversePayment - &makepartialpayment &WriteOffFee &purge_zero_balance_fees ); @@ -352,26 +351,6 @@ sub ReversePayment { } -sub makepartialpayment { - my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_; - - my $line = Koha::Account::Lines->find( $accountlines_id ); - - return Koha::Account->new( - { - patron_id => $borrowernumber, - } - )->pay( - { - amount => $amount, - lines => [ $line ], - note => $payment_note, - library_id => $branch, - } - ); - -} - =head2 WriteOffFee WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note ); --- a/members/paycollect.pl +++ a/members/paycollect.pl @@ -119,9 +119,18 @@ if ( $total_paid and $total_paid ne '0.00' ) { note => $payment_note } ); - } else { - makepartialpayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, - $user, $branch, $payment_note ); + } + else { + my $line = Koha::Account::Lines->find($accountlines_id); + + Koha::Account->new( { patron_id => $borrowernumber, } )->pay( + { + amount => $total_paid, + lines => [$line], + note => $payment_note, + library_id => $branch, + } + ); } print $input->redirect( "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber"); --- a/t/db_dependent/Accounts.t +++ a/t/db_dependent/Accounts.t @@ -45,7 +45,6 @@ can_ok( 'C4::Accounts', getcredits getrefunds ReversePayment - makepartialpayment WriteOffFee purge_zero_balance_fees ) ); @@ -304,7 +303,7 @@ subtest "More Koha::Account::pay tests" => sub { } }; -subtest "makepartialpayment() tests" => sub { +subtest "Even more Koha::Account::pay tests" => sub { plan tests => 6; @@ -332,13 +331,10 @@ subtest "makepartialpayment() tests" => sub { is( $rs->count(), 1, 'Accountline created' ); + my $account = Koha::Account->new( { patron_id => $borrowernumber } ); + my $line = Koha::Account::Lines->find( $accountline->{ accountlines_id } ); # make the full payment - makepartialpayment( - $accountline->{ accountlines_id }, $borrowernumber, - $accountline->{ accountno }, $partialamount, - $borrowernumber, $branch, 'A payment note' ); - - # TODO: someone should write actual tests for makepartialpayment() + $account->pay({ lines => [$line], amount => $partialamount, library_id => $branch, note => 'A payment note' }); my $stat = $schema->resultset('Statistic')->search({ branch => $branch, --