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 |
- |
|
|