| Lines 19-25
          
      
      
        Link Here | 
        
          | 19 | use strict; | 19 | use strict; | 
        
          | 20 | use warnings; | 20 | use warnings; | 
        
          | 21 |  | 21 |  | 
          
            
              | 22 | use Test::More tests => 15; | 22 | use Test::More tests => 25; | 
        
          | 23 | use Test::Warn; | 23 | use Test::Warn; | 
        
          | 24 |  | 24 |  | 
        
          | 25 | BEGIN { | 25 | BEGIN { | 
  
    | Lines 43-49
          can_ok(	'C4::Accounts',
      
      
        Link Here | 
        
          | 43 | 		ReversePayment | 43 | 		ReversePayment | 
        
          | 44 | 		recordpayment_selectaccts | 44 | 		recordpayment_selectaccts | 
        
          | 45 | 		makepartialpayment | 45 | 		makepartialpayment | 
          
            
              | 46 | 		WriteOffFee	) | 46 | 		WriteOffFee | 
            
              |  |  | 47 | 		purge_zero_balance_fees | 
            
              | 48 |       ) | 
        
          | 47 | ); | 49 | ); | 
        
          | 48 |  | 50 |  | 
        
          | 49 | my $dbh = C4::Context->dbh; | 51 | my $dbh = C4::Context->dbh; | 
  
    | Lines 170-176
          $sth->execute($borrower->borrowernumber);
      
      
        Link Here | 
        
          | 170 | $note = $sth->fetchrow_array; | 172 | $note = $sth->fetchrow_array; | 
        
          | 171 | is($note,'$200.00 payment note', '$200.00 payment note is registered'); | 173 | is($note,'$200.00 payment note', '$200.00 payment note is registered'); | 
        
          | 172 |  | 174 |  | 
            
              |  |  | 175 | # Testing purge_zero_balance_fees | 
            
              | 176 |  | 
            
              | 177 | # The 3rd value in the insert is 'days ago' -- | 
            
              | 178 | # 0 => today | 
            
              | 179 | # 1 => yesterday | 
            
              | 180 | # etc. | 
            
              | 181 |  | 
            
              | 182 | $sth = $dbh->prepare( | 
            
              | 183 |     "INSERT INTO accountlines ( | 
            
              | 184 |          borrowernumber, | 
            
              | 185 |          amountoutstanding, | 
            
              | 186 |          date, | 
            
              | 187 |          description | 
            
              | 188 |      ) | 
            
              | 189 |      VALUES ( ?, ?, (select date_sub(CURRENT_DATE, INTERVAL ? DAY) ), ? )" | 
            
              | 190 | ); | 
            
              | 191 |  | 
            
              | 192 | my $days = 5; | 
            
              | 193 |  | 
            
              | 194 | my @test_data = ( | 
            
              | 195 |     { amount => 0  , days_ago => 0         , description =>'purge_zero_balance_fees should not delete 0 balance fees with date today'                     , delete => 0 } , | 
            
              | 196 |     { amount => 0  , days_ago => $days - 1 , description =>'purge_zero_balance_fees should not delete 0 balance fees with date before threshold day'      , delete => 0 } , | 
            
              | 197 |     { amount => 0  , days_ago => $days     , description =>'purge_zero_balance_fees should not delete 0 balance fees with date on threshold day'          , delete => 0 } , | 
            
              | 198 |     { amount => 0  , days_ago => $days + 1 , description =>'purge_zero_balance_fees should delete 0 balance fees with date after threshold day'           , delete => 1 } , | 
            
              | 199 |     { amount => 5  , days_ago => $days - 1 , description =>'purge_zero_balance_fees should not delete fees with postive amout owed before threshold day'  , delete => 0 } , | 
            
              | 200 |     { amount => 5  , days_ago => $days     , description =>'purge_zero_balance_fees should not delete fees with postive amout owed on threshold day'      , delete => 0 } , | 
            
              | 201 |     { amount => 5  , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with postive amout owed after threshold day'   , delete => 0 } , | 
            
              | 202 |     { amount => -5 , days_ago => $days - 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed before threshold day' , delete => 0 } , | 
            
              | 203 |     { amount => -5 , days_ago => $days     , description =>'purge_zero_balance_fees should not delete fees with negative amout owed on threshold day'     , delete => 0 } , | 
            
              | 204 |     { amount => -5 , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed after threshold day'  , delete => 0 } | 
            
              | 205 | ); | 
            
              | 206 |  | 
            
              | 207 | for my $data  ( @test_data ) { | 
            
              | 208 |     $sth->execute($borrower->borrowernumber, $data->{amount}, $data->{days_ago}, $data->{description}); | 
            
              | 209 | } | 
            
              | 210 |  | 
            
              | 211 | purge_zero_balance_fees( $days ); | 
        
          | 173 |  | 212 |  | 
            
              |  |  | 213 | $sth = $dbh->prepare( | 
            
              | 214 |             "select count(*) = 0 as deleted | 
            
              | 215 |              from accountlines | 
            
              | 216 |              where description = ?" | 
            
              | 217 |        ); | 
            
              | 218 |  | 
            
              | 219 | # | 
            
              | 220 | sub is_delete_correct { | 
            
              | 221 |     my $should_delete = shift; | 
            
              | 222 |     my $description = shift; | 
            
              | 223 |     $sth->execute( $description ); | 
            
              | 224 |     my $test = $sth->fetchrow_hashref(); | 
            
              | 225 |     is( $test->{deleted}, $should_delete, $description ) | 
            
              | 226 | } | 
            
              | 227 |  | 
            
              | 228 | for my $data  (@test_data) { | 
            
              | 229 |     is_delete_correct( $data->{delete}, $data->{description}); | 
            
              | 230 | } | 
        
          | 174 |  | 231 |  | 
        
          | 175 | $dbh->rollback; | 232 | $dbh->rollback; | 
        
          | 176 |  | 233 |  | 
  
    | Lines 180-183
          $dbh->rollback;
      
      
        Link Here | 
        
          | 180 | # C4::Context->userenv | 237 | # C4::Context->userenv | 
        
          | 181 | sub Mock_userenv { | 238 | sub Mock_userenv { | 
        
          | 182 |     return $userenv; | 239 |     return $userenv; | 
          
            
              | 183 | } | 240 | } | 
            
              | 184 | -  |  |  |