| 
      
            Lines 19-25
          
      
      
        Link Here
      
     | 
  
        
          | 19 | 
           | 
          19 | 
           | 
        
        
          | 20 | 
          use Modern::Perl;  | 
          20 | 
          use Modern::Perl;  | 
        
        
          | 21 | 
           | 
          21 | 
           | 
        
          
            
              | 22 | 
              use Test::More tests => 10;  | 
              22 | 
              use Test::More tests => 11;  | 
            
        
          | 23 | 
          use Test::Exception;  | 
          23 | 
          use Test::Exception;  | 
        
        
          | 24 | 
           | 
          24 | 
           | 
        
        
          | 25 | 
          use C4::Circulation qw/AddIssue AddReturn/;  | 
          25 | 
          use C4::Circulation qw/AddIssue AddReturn/;  | 
        
  
    | 
      
            Lines 518-523
          subtest 'checkout() tests' => sub {
      
      
        Link Here
      
     | 
  
        
          | 518 | 
              $schema->storage->txn_rollback;  | 
          518 | 
              $schema->storage->txn_rollback;  | 
        
        
          | 519 | 
          };  | 
          519 | 
          };  | 
        
        
          | 520 | 
           | 
          520 | 
           | 
        
            
               | 
               | 
              521 | 
              subtest 'credits() and debits() tests' => sub { | 
            
            
              | 522 | 
                  plan tests => 10;  | 
            
            
              | 523 | 
               | 
            
            
              | 524 | 
                  $schema->storage->txn_begin;  | 
            
            
              | 525 | 
               | 
            
            
              | 526 | 
                  my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); | 
            
            
              | 527 | 
                  my $account = $patron->account;  | 
            
            
              | 528 | 
               | 
            
            
              | 529 | 
                  my $debit1 = $account->add_debit({ | 
            
            
              | 530 | 
                      amount    => 8,  | 
            
            
              | 531 | 
                      interface => 'commandline',  | 
            
            
              | 532 | 
                      type      => 'ACCOUNT',  | 
            
            
              | 533 | 
                  });  | 
            
            
              | 534 | 
                  my $debit2 = $account->add_debit({ | 
            
            
              | 535 | 
                      amount    => 12,  | 
            
            
              | 536 | 
                      interface => 'commandline',  | 
            
            
              | 537 | 
                      type      => 'ACCOUNT',  | 
            
            
              | 538 | 
                  });  | 
            
            
              | 539 | 
                  my $credit1 = $account->add_credit({ | 
            
            
              | 540 | 
                      amount    => 5,  | 
            
            
              | 541 | 
                      interface => 'commandline',  | 
            
            
              | 542 | 
                      type      => 'CREDIT',  | 
            
            
              | 543 | 
                  });  | 
            
            
              | 544 | 
                  my $credit2 = $account->add_credit({ | 
            
            
              | 545 | 
                      amount    => 10,  | 
            
            
              | 546 | 
                      interface => 'commandline',  | 
            
            
              | 547 | 
                      type      => 'CREDIT',  | 
            
            
              | 548 | 
                  });  | 
            
            
              | 549 | 
               | 
            
            
              | 550 | 
                  $credit1->apply({ debits => [ $debit1 ] }); | 
            
            
              | 551 | 
                  $credit2->apply({ debits => [ $debit1, $debit2 ] }); | 
            
            
              | 552 | 
               | 
            
            
              | 553 | 
                  my $credits = $debit1->credits;  | 
            
            
              | 554 | 
                  is($credits->count, 2, '2 Credits applied to debit 1');  | 
            
            
              | 555 | 
                  my $credit = $credits->next;  | 
            
            
              | 556 | 
                  is($credit->amount + 0, -5, 'Correct first credit');  | 
            
            
              | 557 | 
                  $credit = $credits->next;  | 
            
            
              | 558 | 
                  is($credit->amount + 0, -10, 'Correct second credit');  | 
            
            
              | 559 | 
               | 
            
            
              | 560 | 
                  $credits = $debit2->credits;  | 
            
            
              | 561 | 
                  is($credits->count, 1, '1 Credits applied to debit 2');  | 
            
            
              | 562 | 
                  $credit = $credits->next;  | 
            
            
              | 563 | 
                  is($credit->amount + 0, -10, 'Correct first credit');  | 
            
            
              | 564 | 
               | 
            
            
              | 565 | 
                  my $debits = $credit1->debits;  | 
            
            
              | 566 | 
                  is($debits->count, 1, 'Credit 1 applied to 1 debit');  | 
            
            
              | 567 | 
                  my $debit = $debits->next;  | 
            
            
              | 568 | 
                  is($debit->amount + 0, 8, 'Correct first debit');  | 
            
            
              | 569 | 
               | 
            
            
              | 570 | 
                  $debits = $credit2->debits;  | 
            
            
              | 571 | 
                  is($debits->count, 2, 'Credit 2 applied to 2 debits');  | 
            
            
              | 572 | 
                  $debit = $debits->next;  | 
            
            
              | 573 | 
                  is($debit->amount + 0, 8, 'Correct first debit');  | 
            
            
              | 574 | 
                  $debit = $debits->next;  | 
            
            
              | 575 | 
                  is($debit->amount + 0, 12, 'Correct second debit');  | 
            
            
              | 576 | 
               | 
            
            
              | 577 | 
                  $schema->storage->txn_rollback;  | 
            
            
              | 578 | 
              };  | 
            
            
              | 579 | 
               | 
            
        
          | 521 | 
          subtest "void() tests" => sub { | 
          580 | 
          subtest "void() tests" => sub { | 
        
        
          | 522 | 
           | 
          581 | 
           | 
        
        
          | 523 | 
              plan tests => 16;  | 
          582 | 
              plan tests => 16;  | 
        
            
              | 524 | 
              -   | 
               | 
               |