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

(-)a/C4/Accounts.pm (-42 lines)
Lines 44-50 BEGIN { Link Here
44
		&chargelostitem
44
		&chargelostitem
45
		&ReversePayment
45
		&ReversePayment
46
        &makepartialpayment
46
        &makepartialpayment
47
        &recordpayment_selectaccts
48
        &WriteOffFee
47
        &WriteOffFee
49
        &purge_zero_balance_fees
48
        &purge_zero_balance_fees
50
	);
49
	);
Lines 351-397 sub ReversePayment { Link Here
351
350
352
}
351
}
353
352
354
=head2 recordpayment_selectaccts
355
356
  recordpayment_selectaccts($borrowernumber, $payment,$accts);
357
358
Record payment by a patron. C<$borrowernumber> is the patron's
359
borrower number. C<$payment> is a floating-point number, giving the
360
amount that was paid. C<$accts> is an array ref to a list of
361
accountnos which the payment can be recorded against
362
363
Amounts owed are paid off oldest first. That is, if the patron has a
364
$1 fine from Feb. 1, another $1 fine from Mar. 1, and makes a payment
365
of $1.50, then the oldest fine will be paid off in full, and $0.50
366
will be credited to the next one.
367
368
=cut
369
370
sub recordpayment_selectaccts {
371
    my ( $borrowernumber, $amount, $accts, $note ) = @_;
372
373
    my @lines = Koha::Account::Lines->search(
374
        {
375
            borrowernumber    => $borrowernumber,
376
            amountoutstanding => { '<>' => 0 },
377
            accountno         => { 'IN' => $accts },
378
        },
379
        { order_by => 'date' }
380
    );
381
382
    return Koha::Account->new(
383
        {
384
            patron_id => $borrowernumber,
385
        }
386
      )->pay(
387
        {
388
            amount => $amount,
389
            lines  => \@lines,
390
            note   => $note,
391
        }
392
      );
393
}
394
395
sub makepartialpayment {
353
sub makepartialpayment {
396
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
354
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
397
355
(-)a/members/paycollect.pl (-2 / +22 lines)
Lines 132-139 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
132
                }
132
                }
133
                my @acc = split /,/, $select;
133
                my @acc = split /,/, $select;
134
                my $note = $input->param('selected_accts_notes');
134
                my $note = $input->param('selected_accts_notes');
135
                recordpayment_selectaccts( $borrowernumber, $total_paid, \@acc, $note );
135
136
            } else {
136
                my @lines = Koha::Account::Lines->search(
137
                    {
138
                        borrowernumber    => $borrowernumber,
139
                        accountno         => { 'IN' => \@acc },
140
                    },
141
                    { order_by => 'date' }
142
                );
143
144
                return Koha::Account->new(
145
                    {
146
                        patron_id => $borrowernumber,
147
                    }
148
                  )->pay(
149
                    {
150
                        amount => $total_paid,
151
                        lines  => \@lines,
152
                        note   => $note,
153
                    }
154
                  );
155
            }
156
            else {
137
                my $note = $input->param('selected_accts_notes');
157
                my $note = $input->param('selected_accts_notes');
138
                Koha::Account->new( { patron_id => $borrowernumber } )
158
                Koha::Account->new( { patron_id => $borrowernumber } )
139
                  ->pay( { amount => $total_paid, note => $note } );
159
                  ->pay( { amount => $total_paid, note => $note } );
(-)a/t/db_dependent/Accounts.t (-2 lines)
Lines 45-51 can_ok( 'C4::Accounts', Link Here
45
        getcredits
45
        getcredits
46
        getrefunds
46
        getrefunds
47
        ReversePayment
47
        ReversePayment
48
        recordpayment_selectaccts
49
        makepartialpayment
48
        makepartialpayment
50
        WriteOffFee
49
        WriteOffFee
51
        purge_zero_balance_fees )
50
        purge_zero_balance_fees )
52
- 

Return to bug 15908