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

(-)a/C4/Accounts.pm (-21 lines)
Lines 43-49 BEGIN { Link Here
43
		&getrefunds
43
		&getrefunds
44
		&chargelostitem
44
		&chargelostitem
45
		&ReversePayment
45
		&ReversePayment
46
        &makepartialpayment
47
        &WriteOffFee
46
        &WriteOffFee
48
        &purge_zero_balance_fees
47
        &purge_zero_balance_fees
49
	);
48
	);
Lines 350-375 sub ReversePayment { Link Here
350
349
351
}
350
}
352
351
353
sub makepartialpayment {
354
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
355
356
    my $line = Koha::Account::Lines->find( $accountlines_id );
357
358
    return Koha::Account->new(
359
        {
360
            patron_id => $borrowernumber,
361
        }
362
      )->pay(
363
        {
364
            amount => $amount,
365
            lines  => [ $line ],
366
            note   => $payment_note,
367
            library_id => $branch,
368
        }
369
      );
370
371
}
372
373
=head2 WriteOffFee
352
=head2 WriteOffFee
374
353
375
  WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note );
354
  WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note );
(-)a/members/paycollect.pl (-3 / +12 lines)
Lines 119-127 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
119
                        note       => $payment_note
119
                        note       => $payment_note
120
                    }
120
                    }
121
                );
121
                );
122
            } else {
122
            }
123
                makepartialpayment( $accountlines_id, $borrowernumber, $accountno, $total_paid,
123
            else {
124
                    $user, $branch, $payment_note );
124
                my $line = Koha::Account::Lines->find($accountlines_id);
125
126
                Koha::Account->new( { patron_id => $borrowernumber, } )->pay(
127
                    {
128
                        amount     => $total_paid,
129
                        lines      => [$line],
130
                        note       => $payment_note,
131
                        library_id => $branch,
132
                    }
133
                );
125
            }
134
            }
126
            print $input->redirect(
135
            print $input->redirect(
127
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
136
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
(-)a/t/db_dependent/Accounts.t (-9 / +4 lines)
Lines 45-51 can_ok( 'C4::Accounts', Link Here
45
        getcredits
45
        getcredits
46
        getrefunds
46
        getrefunds
47
        ReversePayment
47
        ReversePayment
48
        makepartialpayment
49
        WriteOffFee
48
        WriteOffFee
50
        purge_zero_balance_fees )
49
        purge_zero_balance_fees )
51
);
50
);
Lines 303-309 subtest "More Koha::Account::pay tests" => sub { Link Here
303
    }
302
    }
304
};
303
};
305
304
306
subtest "makepartialpayment() tests" => sub {
305
subtest "Even more Koha::Account::pay tests" => sub {
307
306
308
    plan tests => 6;
307
    plan tests => 6;
309
308
Lines 331-343 subtest "makepartialpayment() tests" => sub { Link Here
331
330
332
    is( $rs->count(), 1, 'Accountline created' );
331
    is( $rs->count(), 1, 'Accountline created' );
333
332
333
    my $account = Koha::Account->new( { patron_id => $borrowernumber } );
334
    my $line = Koha::Account::Lines->find( $accountline->{ accountlines_id } );
334
    # make the full payment
335
    # make the full payment
335
    makepartialpayment(
336
    $account->pay({ lines => [$line], amount => $partialamount, library_id => $branch, note => 'A payment note' });
336
        $accountline->{ accountlines_id }, $borrowernumber,
337
        $accountline->{ accountno },       $partialamount,
338
        $borrowernumber, $branch, 'A payment note' );
339
340
    # TODO: someone should write actual tests for makepartialpayment()
341
337
342
    my $stat = $schema->resultset('Statistic')->search({
338
    my $stat = $schema->resultset('Statistic')->search({
343
        branch  => $branch,
339
        branch  => $branch,
344
- 

Return to bug 15909