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

(-)a/C4/Accounts.pm (-21 lines)
Lines 45-51 BEGIN { Link Here
45
		&getrefunds
45
		&getrefunds
46
		&chargelostitem
46
		&chargelostitem
47
		&ReversePayment
47
		&ReversePayment
48
        &makepartialpayment
49
        &WriteOffFee
48
        &WriteOffFee
50
        &purge_zero_balance_fees
49
        &purge_zero_balance_fees
51
	);
50
	);
Lines 352-377 sub ReversePayment { Link Here
352
351
353
}
352
}
354
353
355
sub makepartialpayment {
356
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
357
358
    my $line = Koha::Account::Lines->find( $accountlines_id );
359
360
    return Koha::Account->new(
361
        {
362
            patron_id => $borrowernumber,
363
        }
364
      )->pay(
365
        {
366
            amount => $amount,
367
            lines  => [ $line ],
368
            note   => $payment_note,
369
            library_id => $branch,
370
        }
371
      );
372
373
}
374
375
=head2 WriteOffFee
354
=head2 WriteOffFee
376
355
377
  WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note );
356
  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 304-310 subtest "More Koha::Account::pay tests" => sub { Link Here
304
    }
303
    }
305
};
304
};
306
305
307
subtest "makepartialpayment() tests" => sub {
306
subtest "Even more Koha::Account::pay tests" => sub {
308
307
309
    plan tests => 6;
308
    plan tests => 6;
310
309
Lines 332-344 subtest "makepartialpayment() tests" => sub { Link Here
332
331
333
    is( $rs->count(), 1, 'Accountline created' );
332
    is( $rs->count(), 1, 'Accountline created' );
334
333
334
    my $account = Koha::Account->new( { patron_id => $borrowernumber } );
335
    my $line = Koha::Account::Lines->find( $accountline->{ accountlines_id } );
335
    # make the full payment
336
    # make the full payment
336
    makepartialpayment(
337
    $account->pay({ lines => [$line], amount => $partialamount, library_id => $branch, note => 'A payment note' });
337
        $accountline->{ accountlines_id }, $borrowernumber,
338
        $accountline->{ accountno },       $partialamount,
339
        $borrowernumber, $branch, 'A payment note' );
340
341
    # TODO: someone should write actual tests for makepartialpayment()
342
338
343
    my $stat = $schema->resultset('Statistic')->search({
339
    my $stat = $schema->resultset('Statistic')->search({
344
        branch  => $branch,
340
        branch  => $branch,
345
- 

Return to bug 15909