[BACK]Return to rt_invoices.pl CVS log [TXT][DIR] Up to [local] / RT / Invoicing

Diff for /RT/Invoicing/rt_invoices.pl between version 1.29 and 1.32

version 1.29, 2011/05/03 05:38:56 version 1.32, 2011/05/07 02:09:43
Line 1 
Line 1 
 #!/usr/bin/perl  #!/usr/bin/perl
 # $AFresh1: rt_invoices.pl,v 1.28 2011/04/19 03:35:12 andrew Exp $  # $AFresh1: rt_invoices.pl,v 1.31 2011/05/07 01:03:55 andrew Exp $
 ########################################################################  ########################################################################
 # Copyright (c) 2011 Andrew Fresh <andrew@afresh1.com>  # Copyright (c) 2011 Andrew Fresh <andrew@afresh1.com>
 #  #
Line 101 
Line 101 
     foreach my $fee ( @{ $project->{fees} } ) {      foreach my $fee ( @{ $project->{fees} } ) {
         my $hours = hours_for_date( $cust->{invoice}, $fee->{date} );          my $hours = hours_for_date( $cust->{invoice}, $fee->{date} );
   
         my $h_type          my $type = exists $hours->{ $fee->{type} }
             = exists $hours->{ $fee->{type} }              && $hours->{ $fee->{type} } > 0 ? $fee->{type} : 'default';
             ? $fee->{type}  
             : 'default';  
   
         next unless exists $hours->{$h_type} && $hours->{$h_type} > 0;          next unless exists $hours->{$type} && $hours->{$type} > 0;
   
         my $discount_time = 0;          my $discount_time = 0;
         if ( $hours->{$h_type} > $fee->{count} ) {          if ( $hours->{$type} > $fee->{count} ) {
             $hours->{$h_type} -= $fee->{count};              $hours->{$type} -= $fee->{count};
             $discount_time = $fee->{count};              $discount_time = $fee->{count};
         }          }
         else {          else {
             $discount_time = $hours->{$h_type};              $discount_time = $hours->{$type};
             $hours->{$h_type} = 0;              $hours->{$type} = 0;
         }          }
   
         if ($discount_time) {          if ($discount_time) {
             $cust->{invoice}->{discount}->{amount}              $cust->{invoice}->{discount}->{amount}
                 += round( $discount_time * $fee->{rate} );                  += round( $discount_time * $fee->{rate} );
             $cust->{invoice}->{discount}->{hours}{$h_type} += $discount_time;              $cust->{invoice}->{discount}->{hours}{$type} += $discount_time;
   
             $h_type = '' if $h_type eq 'default';              $type = '' if $type eq 'default';
             $fee->{detail} = "$discount_time $h_type Hours Discounted";              $fee->{detail} = "$discount_time $type Hours Discounted";
         }          }
     }      }
   
Line 341 
Line 339 
     }      }
   
     # Is the start date more than $freq $per before the end date?      # Is the start date more than $freq $per before the end date?
     my $diff = $billend - $date;      return {}
     return {} if $diff->in_units($per) < 1;          if DateTime->compare( $date->clone->add( $per => $freq ), $billend )
               > 0;
   
     if ( $cust->{base_rate} ) {      if ( $cust->{base_rate} ) {
         my ( $project, $hours ) = make_base_project(          my ( $project, $hours ) = make_base_project(

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.32

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>