| Lines 209-222
          foreach my $item (@items){
      
      
        Link Here | 
        
          | 209 |         ); | 209 |         ); | 
        
          | 210 |  | 210 |  | 
        
          | 211 |         if ( my $accountline = $accountlines->next ) { | 211 |         if ( my $accountline = $accountlines->next ) { | 
          
            
              | 212 |             my $payment_offsets = Koha::Account::Offsets->search( | 212 |             my $payment_offsets = $accountline->debit_offsets( | 
        
          | 213 |                 { | 213 |                 { | 
            
              | 214 |                     debit_id  => $accountline->id, |  |  | 
        
          | 215 |                     credit_id => { '!=' => undef }, # it is not the debit itself | 214 |                     credit_id => { '!=' => undef }, # it is not the debit itself | 
          
            
              | 216 |                     type => { '!=' => [ 'Writeoff', 'Forgiven' ] }, | 215 |                     'credit.credit_type_code' => | 
            
              | 217 |                     amount => { '<' => 0 }    # credits are negative on the DB | 216 |                       { '!=' => [ 'Writeoff', 'Forgiven' ] }, | 
        
          | 218 |                 }, | 217 |                 }, | 
          
            
              | 219 |                 { order_by => { '-desc' => 'created_on' } } | 218 |                 { join => 'credit', order_by => { '-desc' => 'created_on' } } | 
        
          | 220 |             ); | 219 |             ); | 
        
          | 221 |  | 220 |  | 
        
          | 222 |             if ($payment_offsets->count) { | 221 |             if ($payment_offsets->count) { | 
            
              | 223 | -  |  |  |