| 
      
            Lines 33-43
          my $builder = t::lib::TestBuilder->new;
      
      
        Link Here
      
     | 
  
        
          | 33 | 
           | 
          33 | 
           | 
        
        
          | 34 | 
          subtest 'outstanding_debits() tests' => sub { | 
          34 | 
          subtest 'outstanding_debits() tests' => sub { | 
        
        
          | 35 | 
           | 
          35 | 
           | 
        
          
            
              | 36 | 
                  plan tests => 12;  | 
              36 | 
                  plan tests => 21;  | 
            
        
          | 37 | 
           | 
          37 | 
           | 
        
        
          | 38 | 
              $schema->storage->txn_begin;  | 
          38 | 
              $schema->storage->txn_begin;  | 
        
        
          | 39 | 
           | 
          39 | 
           | 
        
          
            
              | 40 | 
                  my $patron = $builder->build_object({ class => 'Koha::Patrons' }); | 
              40 | 
                  my $patron  = $builder->build_object({ class => 'Koha::Patrons' }); | 
            
            
               | 
               | 
              41 | 
                  my $account = $patron->account;  | 
            
        
          | 41 | 
           | 
          42 | 
           | 
        
        
          | 42 | 
              my @generated_lines;  | 
          43 | 
              my @generated_lines;  | 
        
        
          | 43 | 
              push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 1 })->store; | 
          44 | 
              push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 1 })->store; | 
        
  
    | 
      
            Lines 45-59
          subtest 'outstanding_debits() tests' => sub {
      
      
        Link Here
      
     | 
  
        
          | 45 | 
              push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 3 })->store; | 
          46 | 
              push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 3 })->store; | 
        
        
          | 46 | 
              push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 4 })->store; | 
          47 | 
              push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 4 })->store; | 
        
        
          | 47 | 
           | 
          48 | 
           | 
        
          
            
              | 48 | 
                  my $account = $patron->account;  | 
              49 | 
                  my $lines     = $account->outstanding_debits();  | 
            
            
              | 49 | 
                  my $lines   = $account->outstanding_debits();  | 
              50 | 
                  my @lines_arr = $account->outstanding_debits();  | 
            
        
          | 50 | 
           | 
          51 | 
           | 
        
            
               | 
               | 
              52 | 
                  is( ref($lines), 'Koha::Account::Lines', 'Called in scalar context, outstanding_debits returns a Koha::Account::Lines object' );  | 
            
        
          | 51 | 
              is( $lines->total_outstanding, 10, 'Outstandig debits total is correctly calculated' );  | 
          53 | 
              is( $lines->total_outstanding, 10, 'Outstandig debits total is correctly calculated' );  | 
        
        
          | 52 | 
           | 
          54 | 
           | 
        
        
          | 53 | 
              my $i = 0;  | 
          55 | 
              my $i = 0;  | 
        
        
          | 54 | 
              foreach my $line ( @{ $lines->as_list } ) { | 
          56 | 
              foreach my $line ( @{ $lines->as_list } ) { | 
        
        
          | 55 | 
                  my $fetched_line = Koha::Account::Lines->find( $generated_lines[$i]->id );  | 
          57 | 
                  my $fetched_line = Koha::Account::Lines->find( $generated_lines[$i]->id );  | 
        
        
          | 56 | 
                  is_deeply( $line->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" );  | 
          58 | 
                  is_deeply( $line->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" );  | 
        
            
               | 
               | 
              59 | 
                      is_deeply( $lines_arr[$i]->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" );  | 
            
            
              | 60 | 
                      is( ref($lines_arr[$i]), 'Koha::Account::Line', 'outstanding_debits returns a list of Koha::Account::Line objects in list context' );  | 
            
        
          | 57 | 
                  $i++;  | 
          61 | 
                  $i++;  | 
        
        
          | 58 | 
              }  | 
          62 | 
              }  | 
        
        
          | 59 | 
           | 
          63 | 
           | 
        
  
    | 
      
            Lines 85-91
          subtest 'outstanding_debits() tests' => sub {
      
      
        Link Here
      
     | 
  
        
          | 85 | 
           | 
          89 | 
           | 
        
        
          | 86 | 
          subtest 'outstanding_credits() tests' => sub { | 
          90 | 
          subtest 'outstanding_credits() tests' => sub { | 
        
        
          | 87 | 
           | 
          91 | 
           | 
        
          
            
              | 88 | 
                  plan tests => 7;  | 
              92 | 
                  plan tests => 16;  | 
            
        
          | 89 | 
           | 
          93 | 
           | 
        
        
          | 90 | 
              $schema->storage->txn_begin;  | 
          94 | 
              $schema->storage->txn_begin;  | 
        
        
          | 91 | 
           | 
          95 | 
           | 
        
  
    | 
      
            Lines 98-111
          subtest 'outstanding_credits() tests' => sub {
      
      
        Link Here
      
     | 
  
        
          | 98 | 
              push @generated_lines, $account->add_credit({ amount => 3 }); | 
          102 | 
              push @generated_lines, $account->add_credit({ amount => 3 }); | 
        
        
          | 99 | 
              push @generated_lines, $account->add_credit({ amount => 4 }); | 
          103 | 
              push @generated_lines, $account->add_credit({ amount => 4 }); | 
        
        
          | 100 | 
           | 
          104 | 
           | 
        
          
            
              | 101 | 
                  my $lines = $account->outstanding_credits();  | 
              105 | 
                  my $lines     = $account->outstanding_credits();  | 
            
            
               | 
               | 
              106 | 
                  my @lines_arr = $account->outstanding_credits();  | 
            
        
          | 102 | 
           | 
          107 | 
           | 
        
            
               | 
               | 
              108 | 
                  is( ref($lines), 'Koha::Account::Lines', 'Called in scalar context, outstanding_credits returns a Koha::Account::Lines object' );  | 
            
        
          | 103 | 
              is( $lines->total_outstanding, -10, 'Outstandig credits total is correctly calculated' );  | 
          109 | 
              is( $lines->total_outstanding, -10, 'Outstandig credits total is correctly calculated' );  | 
        
        
          | 104 | 
           | 
          110 | 
           | 
        
        
          | 105 | 
              my $i = 0;  | 
          111 | 
              my $i = 0;  | 
        
        
          | 106 | 
              foreach my $line ( @{ $lines->as_list } ) { | 
          112 | 
              foreach my $line ( @{ $lines->as_list } ) { | 
        
        
          | 107 | 
                  my $fetched_line = Koha::Account::Lines->find( $generated_lines[$i]->id );  | 
          113 | 
                  my $fetched_line = Koha::Account::Lines->find( $generated_lines[$i]->id );  | 
        
        
          | 108 | 
                  is_deeply( $line->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" );  | 
          114 | 
                  is_deeply( $line->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" );  | 
        
            
               | 
               | 
              115 | 
                      is_deeply( $lines_arr[$i]->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" );  | 
            
            
              | 116 | 
                      is( ref($lines_arr[$i]), 'Koha::Account::Line', 'outstanding_debits returns a list of Koha::Account::Line objects in list context' );  | 
            
        
          | 109 | 
                  $i++;  | 
          117 | 
                  $i++;  | 
        
        
          | 110 | 
              }  | 
          118 | 
              }  | 
        
        
          | 111 | 
           | 
          119 | 
           | 
        
            
              | 112 | 
              -   | 
               | 
               |