| 
      
            Lines 272-278
          subtest 'apply() tests' => sub {
      
      
        Link Here
      
     | 
  
        
          | 272 | 
           | 
          272 | 
           | 
        
        
          | 273 | 
          subtest 'adjust() tests' => sub { | 
          273 | 
          subtest 'adjust() tests' => sub { | 
        
        
          | 274 | 
           | 
          274 | 
           | 
        
          
            
              | 275 | 
                  plan tests => 16;  | 
              275 | 
                  plan tests => 19;  | 
            
        
          | 276 | 
           | 
          276 | 
           | 
        
        
          | 277 | 
              $schema->storage->txn_begin;  | 
          277 | 
              $schema->storage->txn_begin;  | 
        
        
          | 278 | 
           | 
          278 | 
           | 
        
  
    | 
      
            Lines 311-320
          subtest 'adjust() tests' => sub {
      
      
        Link Here
      
     | 
  
        
          | 311 | 
                'Exception thrown for type conflict';  | 
          311 | 
                'Exception thrown for type conflict';  | 
        
        
          | 312 | 
           | 
          312 | 
           | 
        
        
          | 313 | 
              # Increment an unpaid fine  | 
          313 | 
              # Increment an unpaid fine  | 
        
          
            
              | 314 | 
                  $debit_2->adjust( { amount => 150, type => 'fine_increment' } ); | 
              314 | 
                  $debit_2->adjust( { amount => 150, type => 'fine_increment' } )->discard_changes; | 
            
        
          | 315 | 
           | 
          315 | 
           | 
        
          
            
              | 316 | 
                  is( $debit_2->discard_changes->amount * 1, 150, 'Fine amount was updated in full' );  | 
              316 | 
                  is( $debit_2->amount * 1, 150, 'Fine amount was updated in full' );  | 
            
            
              | 317 | 
                  is( $debit_2->discard_changes->amountoutstanding * 1, 150, 'Fine amountoutstanding was update in full' );  | 
              317 | 
                  is( $debit_2->amountoutstanding * 1, 150, 'Fine amountoutstanding was update in full' );  | 
            
            
               | 
               | 
              318 | 
                  isnt( $debit_2->date, undef, 'Date has been set' );  | 
            
            
              | 319 | 
                  is( $debit_2->lastincrement * 1, 50, 'lastincrement is the to the right value' );  | 
            
        
          | 318 | 
           | 
          320 | 
           | 
        
        
          | 319 | 
              my $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } ); | 
          321 | 
              my $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } ); | 
        
        
          | 320 | 
              is( $offsets->count, 1, 'An offset is generated for the increment' );  | 
          322 | 
              is( $offsets->count, 1, 'An offset is generated for the increment' );  | 
        
  
    | 
      
            Lines 328-344
          subtest 'adjust() tests' => sub {
      
      
        Link Here
      
     | 
  
        
          | 328 | 
              my $debits = Koha::Account::Lines->search({ accountlines_id => $debit_2->id }); | 
          330 | 
              my $debits = Koha::Account::Lines->search({ accountlines_id => $debit_2->id }); | 
        
        
          | 329 | 
              $credit->apply( { debits => $debits, offset_type => 'Manual Credit' } ); | 
          331 | 
              $credit->apply( { debits => $debits, offset_type => 'Manual Credit' } ); | 
        
        
          | 330 | 
           | 
          332 | 
           | 
        
          
            
              | 331 | 
                  is( $debit_2->discard_changes->amount * 1, 150, 'Fine amount unaffected by partial payment' );  | 
              333 | 
                  $debit_2->discard_changes;  | 
            
            
              | 332 | 
                  is( $debit_2->discard_changes->amountoutstanding * 1, 110, 'Fine amountoutstanding updated by partial payment' );  | 
              334 | 
                  is( $debit_2->amount * 1, 150, 'Fine amount unaffected by partial payment' );  | 
            
            
               | 
               | 
              335 | 
                  is( $debit_2->amountoutstanding * 1, 110, 'Fine amountoutstanding updated by partial payment' );  | 
            
        
          | 333 | 
           | 
          336 | 
           | 
        
        
          | 334 | 
              # Enable logs  | 
          337 | 
              # Enable logs  | 
        
        
          | 335 | 
              t::lib::Mocks::mock_preference( 'FinesLog', 1 );  | 
          338 | 
              t::lib::Mocks::mock_preference( 'FinesLog', 1 );  | 
        
        
          | 336 | 
           | 
          339 | 
           | 
        
        
          | 337 | 
              # Increment the partially paid fine  | 
          340 | 
              # Increment the partially paid fine  | 
        
          
            
              | 338 | 
                  $debit_2->adjust( { amount => 160, type => 'fine_increment' } ); | 
              341 | 
                  $debit_2->adjust( { amount => 160, type => 'fine_increment' } )->discard_changes; | 
            
        
          | 339 | 
           | 
          342 | 
           | 
        
          
            
              | 340 | 
                  is( $debit_2->discard_changes->amount * 1, 160, 'Fine amount was updated in full' );  | 
              343 | 
                  is( $debit_2->amount * 1, 160, 'Fine amount was updated in full' );  | 
            
            
              | 341 | 
                  is( $debit_2->discard_changes->amountoutstanding * 1, 120, 'Fine amountoutstanding was updated by difference' );  | 
              344 | 
                  is( $debit_2->amountoutstanding * 1, 120, 'Fine amountoutstanding was updated by difference' );  | 
            
            
               | 
               | 
              345 | 
                  is( $debit_2->lastincrement * 1, 10, 'lastincrement is the to the right value' );  | 
            
        
          | 342 | 
           | 
          346 | 
           | 
        
        
          | 343 | 
              $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } ); | 
          347 | 
              $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } ); | 
        
        
          | 344 | 
              is( $offsets->count, 3, 'An offset is generated for the increment' );  | 
          348 | 
              is( $offsets->count, 3, 'An offset is generated for the increment' );  | 
        
            
              | 345 | 
              -   | 
               | 
               |