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

(-)a/C4/Accounts.pm (-23 lines)
Lines 44-50 BEGIN { Link Here
44
		&getrefunds
44
		&getrefunds
45
		&chargelostitem
45
		&chargelostitem
46
		&ReversePayment
46
		&ReversePayment
47
        &makepartialpayment
48
        &recordpayment_selectaccts
47
        &recordpayment_selectaccts
49
        &WriteOffFee
48
        &WriteOffFee
50
        &purge_zero_balance_fees
49
        &purge_zero_balance_fees
Lines 420-447 sub recordpayment_selectaccts { Link Here
420
      );
419
      );
421
}
420
}
422
421
423
# makepayment needs to be fixed to handle partials till then this separate subroutine
424
# fills in
425
sub makepartialpayment {
426
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
427
428
    my $line = Koha::Account::Lines->find( $accountlines_id );
429
430
    return Koha::Account->new(
431
        {
432
            patron_id => $borrowernumber,
433
        }
434
      )->pay(
435
        {
436
            amount => $amount,
437
            lines  => [ $line ],
438
            note   => $payment_note,
439
            library_id => $branch,
440
        }
441
      );
442
443
}
444
445
=head2 WriteOffFee
422
=head2 WriteOffFee
446
423
447
  WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note );
424
  WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note );
(-)a/members/paycollect.pl (-3 / +12 lines)
Lines 121-129 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
121
                        note       => $payment_note
121
                        note       => $payment_note
122
                    }
122
                    }
123
                );
123
                );
124
            } else {
124
            }
125
                makepartialpayment( $accountlines_id, $borrowernumber, $accountno, $total_paid,
125
            else {
126
                    $user, $branch, $payment_note );
126
                my $line = Koha::Account::Lines->find($accountlines_id);
127
128
                Koha::Account->new( { patron_id => $borrowernumber, } )->pay(
129
                    {
130
                        amount     => $total_paid,
131
                        lines      => [$line],
132
                        note       => $payment_note,
133
                        library_id => $branch,
134
                    }
135
                );
127
            }
136
            }
128
            print $input->redirect(
137
            print $input->redirect(
129
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
138
                "/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 357-363 subtest "makepayment() tests" => sub { Link Here
357
    }
356
    }
358
};
357
};
359
358
360
subtest "makepartialpayment() tests" => sub {
359
subtest "Even more Koha::Account::pay tests" => sub {
361
360
362
    plan tests => 6;
361
    plan tests => 6;
363
362
Lines 385-397 subtest "makepartialpayment() tests" => sub { Link Here
385
384
386
    is( $rs->count(), 1, 'Accountline created' );
385
    is( $rs->count(), 1, 'Accountline created' );
387
386
387
    my $account = Koha::Account->new( { patron_id => $borrowernumber } );
388
    my $line = Koha::Account::Lines->find( $accountline->{ accountlines_id } );
388
    # make the full payment
389
    # make the full payment
389
    makepartialpayment(
390
    $account->pay({ lines => [$line], amount => $partialamount, library_id => $branch, note => 'A payment note' });
390
        $accountline->{ accountlines_id }, $borrowernumber,
391
        $accountline->{ accountno },       $partialamount,
392
        $borrowernumber, $branch, 'A payment note' );
393
394
    # TODO: someone should write actual tests for makepartialpayment()
395
391
396
    my $stat = $schema->resultset('Statistic')->search({
392
    my $stat = $schema->resultset('Statistic')->search({
397
        branch  => $branch,
393
        branch  => $branch,
398
- 

Return to bug 15909