View | Details | Raw Unified | Return to bug 15909
Collapse All | Expand All

(-)a/C4/Accounts.pm (-23 lines)
Lines 45-51 BEGIN { Link Here
45
		&getrefunds
45
		&getrefunds
46
		&chargelostitem
46
		&chargelostitem
47
		&ReversePayment
47
		&ReversePayment
48
        &makepartialpayment
49
        &recordpayment_selectaccts
48
        &recordpayment_selectaccts
50
        &WriteOffFee
49
        &WriteOffFee
51
        &purge_zero_balance_fees
50
        &purge_zero_balance_fees
Lines 448-475 sub recordpayment_selectaccts { Link Here
448
      );
447
      );
449
}
448
}
450
449
451
# makepayment needs to be fixed to handle partials till then this separate subroutine
452
# fills in
453
sub makepartialpayment {
454
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
455
456
    my $line = Koha::Account::Lines->find( $accountlines_id );
457
458
    return Koha::Account->new(
459
        {
460
            patron_id => $borrowernumber,
461
        }
462
      )->pay(
463
        {
464
            amount => $amount,
465
            lines  => [ $line ],
466
            note   => $payment_note,
467
            library_id => $branch,
468
        }
469
      );
470
471
}
472
473
=head2 WriteOffFee
450
=head2 WriteOffFee
474
451
475
  WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note );
452
  WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note );
(-)a/members/paycollect.pl (-3 / +12 lines)
Lines 112-120 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
112
            if ( $total_paid == $total_due ) {
112
            if ( $total_paid == $total_due ) {
113
                makepayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, $user,
113
                makepayment( $accountlines_id, $borrowernumber, $accountno, $total_paid, $user,
114
                    $branch, $payment_note );
114
                    $branch, $payment_note );
115
            } else {
115
            }
116
                makepartialpayment( $accountlines_id, $borrowernumber, $accountno, $total_paid,
116
            else {
117
                    $user, $branch, $payment_note );
117
                my $line = Koha::Account::Lines->find($accountlines_id);
118
119
                Koha::Account->new( { patron_id => $borrowernumber, } )->pay(
120
                    {
121
                        amount     => $total_paid,
122
                        lines      => [$line],
123
                        note       => $payment_note,
124
                        library_id => $branch,
125
                    }
126
                );
118
            }
127
            }
119
            print $input->redirect(
128
            print $input->redirect(
120
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
129
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
(-)a/t/db_dependent/Accounts.t (-9 / +4 lines)
Lines 46-52 can_ok( 'C4::Accounts', Link Here
46
        getrefunds
46
        getrefunds
47
        ReversePayment
47
        ReversePayment
48
        recordpayment_selectaccts
48
        recordpayment_selectaccts
49
        makepartialpayment
50
        WriteOffFee
49
        WriteOffFee
51
        purge_zero_balance_fees )
50
        purge_zero_balance_fees )
52
);
51
);
Lines 302-308 subtest "makepayment() tests" => sub { Link Here
302
    }
301
    }
303
};
302
};
304
303
305
subtest "makepartialpayment() tests" => sub {
304
subtest "Even more Koha::Account::pay tests" => sub {
306
305
307
    plan tests => 6;
306
    plan tests => 6;
308
307
Lines 330-342 subtest "makepartialpayment() tests" => sub { Link Here
330
329
331
    is( $rs->count(), 1, 'Accountline created' );
330
    is( $rs->count(), 1, 'Accountline created' );
332
331
332
    my $account = Koha::Account->new( { patron_id => $borrowernumber } );
333
    my $line = Koha::Account::Lines->find( $accountline->{ accountlines_id } );
333
    # make the full payment
334
    # make the full payment
334
    makepartialpayment(
335
    $account->pay({ lines => [$line], amount => $partialamount, library_id => $branch, note => 'A payment note' });
335
        $accountline->{ accountlines_id }, $borrowernumber,
336
        $accountline->{ accountno },       $partialamount,
337
        $borrowernumber, $branch, 'A payment note' );
338
339
    # TODO: someone should write actual tests for makepartialpayment()
340
336
341
    my $stat = $schema->resultset('Statistic')->search({
337
    my $stat = $schema->resultset('Statistic')->search({
342
        branch  => $branch,
338
        branch  => $branch,
343
- 

Return to bug 15909