Lines 1004-1020
sub _set_found_trigger {
Link Here
|
1004 |
# some amount has been cancelled. collect the offsets that are not writeoffs |
1004 |
# some amount has been cancelled. collect the offsets that are not writeoffs |
1005 |
# this works because the only way to subtract from this kind of a debt is |
1005 |
# this works because the only way to subtract from this kind of a debt is |
1006 |
# using the UI buttons 'Pay' and 'Write off' |
1006 |
# using the UI buttons 'Pay' and 'Write off' |
1007 |
my $credits_offsets = Koha::Account::Offsets->search( |
1007 |
my $credit_offsets = $lost_charge->debit_offsets( |
1008 |
{ |
1008 |
{ |
1009 |
debit_id => $lost_charge->id, |
1009 |
'credit_id' => { '!=' => undef }, |
1010 |
credit_id => { '!=' => undef }, # it is not the debit itself |
1010 |
'credit.credit_type_code' => { '!=' => 'Writeoff' } |
1011 |
type => { '!=' => 'Writeoff' }, |
1011 |
}, |
1012 |
amount => { '<' => 0 } # credits are negative on the DB |
1012 |
{ join => 'credit' } |
1013 |
} |
|
|
1014 |
); |
1013 |
); |
1015 |
|
1014 |
|
1016 |
$total_to_refund = ( $credits_offsets->count > 0 ) |
1015 |
$total_to_refund = ( $credit_offsets->count > 0 ) |
1017 |
? $credits_offsets->total * -1 # credits are negative on the DB |
1016 |
? $credit_offsets->total * -1 # credits are negative on the DB |
1018 |
: 0; |
1017 |
: 0; |
1019 |
} |
1018 |
} |
1020 |
|
1019 |
|