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

(-)a/Koha/Account/Line.pm (-2 / +11 lines)
Lines 657-663 sub apply { Link Here
657
            # Attempt to renew the item associated with this debit if
657
            # Attempt to renew the item associated with this debit if
658
            # appropriate
658
            # appropriate
659
            if ( $self->credit_type_code ne 'FORGIVEN' && $debit->renewable ) {
659
            if ( $self->credit_type_code ne 'FORGIVEN' && $debit->renewable ) {
660
                $debit->renew_item( { interface => $params->{interface} } );
660
                my $outcome = $debit->renew_item( { interface => $params->{interface} } );
661
                $self->add_message(
662
                    {
663
                        type    => 'info',
664
                        message => 'renewal',
665
                        payload => $outcome
666
                    }
667
                ) if $outcome;
661
            }
668
            }
662
669
663
            # Same logic exists in Koha::Account::pay
670
            # Same logic exists in Koha::Account::pay
Lines 677-686 sub apply { Link Here
677
                C4::Circulation::ReturnLostItem( $self->borrowernumber,
684
                C4::Circulation::ReturnLostItem( $self->borrowernumber,
678
                    $debit->itemnumber );
685
                    $debit->itemnumber );
679
            }
686
            }
687
688
            last if $available_credit == 0;
680
        }
689
        }
681
    });
690
    });
682
691
683
    return $available_credit;
692
    return $self;
684
}
693
}
685
694
686
=head3 payout
695
=head3 payout
(-)a/Koha/REST/V1/Patrons/Account.pm (-4 / +2 lines)
Lines 132-144 sub add_credit { Link Here
132
        $debits = Koha::Account::Lines->search({ accountlines_id => { -in => $debits_ids } })
132
        $debits = Koha::Account::Lines->search({ accountlines_id => { -in => $debits_ids } })
133
            if $debits_ids;
133
            if $debits_ids;
134
134
135
        my $outstanding_credit = $credit->amountoutstanding;
136
        if ($debits) {
135
        if ($debits) {
137
            # pay them!
136
            # pay them!
138
            $outstanding_credit = $credit->apply({ debits => [ $debits->as_list ], offset_type => 'payment' });
137
            $credit = $credit->apply({ debits => [ $debits->as_list ], offset_type => 'payment' });
139
        }
138
        }
140
139
141
        if ($outstanding_credit) {
140
        if ($credit->amountoutstanding != 0) {
142
            my $outstanding_debits = $account->outstanding_debits;
141
            my $outstanding_debits = $account->outstanding_debits;
143
            $credit->apply({ debits => [ $outstanding_debits->as_list ], offset_type => 'payment' });
142
            $credit->apply({ debits => [ $outstanding_debits->as_list ], offset_type => 'payment' });
144
        }
143
        }
145
- 

Return to bug 27995