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