| 
      
            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 => 19;  | 
              275 | 
                  plan tests => 33;  | 
            
        
          | 276 | 
           | 
          276 | 
           | 
        
        
          | 277 | 
              $schema->storage->txn_begin;  | 
          277 | 
              $schema->storage->txn_begin;  | 
        
        
          | 278 | 
           | 
          278 | 
           | 
        
  
    | 
      
            Lines 352-357
          subtest 'adjust() tests' => sub {
      
      
        Link Here
      
     | 
  
        
          | 352 | 
           | 
          352 | 
           | 
        
        
          | 353 | 
              is( $schema->resultset('ActionLog')->count(), $action_logs + 1, 'Log was added' ); | 
          353 | 
              is( $schema->resultset('ActionLog')->count(), $action_logs + 1, 'Log was added' ); | 
        
        
          | 354 | 
           | 
          354 | 
           | 
        
            
               | 
               | 
              355 | 
                  # Decrement the partially paid fine, less than what was paid  | 
            
            
              | 356 | 
                  $debit_2->adjust( { amount => 50, type => 'fine_increment' } )->discard_changes; | 
            
            
              | 357 | 
               | 
            
            
              | 358 | 
                  is( $debit_2->amount * 1, 50, 'Fine amount was updated in full' );  | 
            
            
              | 359 | 
                  is( $debit_2->amountoutstanding * 1, 10, 'Fine amountoutstanding was updated by difference' );  | 
            
            
              | 360 | 
                  is( $debit_2->lastincrement * 1, -110, 'lastincrement is the to the right value' );  | 
            
            
              | 361 | 
               | 
            
            
              | 362 | 
                  $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } ); | 
            
            
              | 363 | 
                  is( $offsets->count, 4, 'An offset is generated for the decrement' );  | 
            
            
              | 364 | 
                  $THIS_offset = $offsets->last;  | 
            
            
              | 365 | 
                  is( $THIS_offset->amount * 1, -110, 'Amount was calculated correctly (decrement by 110)' );  | 
            
            
              | 366 | 
                  is( $THIS_offset->type, 'Fine Update', 'Adjust type stored correctly' );  | 
            
            
              | 367 | 
               | 
            
            
              | 368 | 
                  # Decrement the partially paid fine, more than what was paid  | 
            
            
              | 369 | 
                  $debit_2->adjust( { amount => 30, type => 'fine_increment' } )->discard_changes; | 
            
            
              | 370 | 
                  is( $debit_2->amount * 1, 30, 'Fine amount was updated in full' );  | 
            
            
              | 371 | 
                  is( $debit_2->amountoutstanding * 1, 0, 'Fine amountoutstanding was zeroed (payment was 40)' );  | 
            
            
              | 372 | 
                  is( $debit_2->lastincrement * 1, -20, 'lastincrement is the to the right value' );  | 
            
            
              | 373 | 
               | 
            
            
              | 374 | 
                  $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } ); | 
            
            
              | 375 | 
                  is( $offsets->count, 5, 'An offset is generated for the decrement' );  | 
            
            
              | 376 | 
                  $THIS_offset = $offsets->last;  | 
            
            
              | 377 | 
                  is( $THIS_offset->amount * 1, -20, 'Amount was calculated correctly (decrement by 20)' );  | 
            
            
              | 378 | 
                  is( $THIS_offset->type, 'Fine Update', 'Adjust type stored correctly' );  | 
            
            
              | 379 | 
               | 
            
            
              | 380 | 
                  my $overpayment_refund = $account->lines->last;  | 
            
            
              | 381 | 
                  is( $overpayment_refund->amount * 1, -10, 'A new credit has been added' );  | 
            
            
              | 382 | 
                  is( $overpayment_refund->description, 'Overpayment refund', 'Credit generated with the expected description' );  | 
            
            
              | 383 | 
               | 
            
        
          | 355 | 
              $schema->storage->txn_rollback;  | 
          384 | 
              $schema->storage->txn_rollback;  | 
        
        
          | 356 | 
          };  | 
          385 | 
          };  | 
        
        
          | 357 | 
           | 
          386 | 
           | 
        
            
              | 358 | 
              -   | 
               | 
               |