[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.13 and 1.14

version 1.13, 2011/03/22 02:16:53 version 1.14, 2011/03/22 02:37:14
Line 47 
Line 47 
 my $customers = $config->get('customers');  my $customers = $config->get('customers');
 CUSTOMER: while ( my ( $custid, $cust ) = each %{$customers} ) {  CUSTOMER: while ( my ( $custid, $cust ) = each %{$customers} ) {
   
     my $invoice = make_invoice();      my $invoice = make_invoice($cust);
   
     if ( $cust->{base_rate} ) {      if ( $cust->{base_rate} ) {
           $invoice->{hours} = [];
         my $day  = $cust->{day}       || 1;          my $day  = $cust->{day}       || 1;
         my $freq = $cust->{frequency} || 1;          my $freq = $cust->{frequency} || 1;
   
Line 188 
Line 189 
         }          }
   
         if ($discount_time) {          if ($discount_time) {
             $invoice->{discount}{amount} += $discount_time * $fee->{rate};              $invoice->{discount}{amount}
                   += round($discount_time * $fee->{rate});
             $invoice->{discount}{hours}{$h_type} += $discount_time;              $invoice->{discount}{hours}{$h_type} += $discount_time;
   
             $h_type = '' if $h_type eq 'default';              $h_type = '' if $h_type eq 'default';
Line 326 
Line 328 
     my $cust = $config->get('default') || {};      my $cust = $config->get('default') || {};
     $cust->{address} = get_user($custid);      $cust->{address} = get_user($custid);
   
     $cust->{match} = [{      $cust->{match} = [
             type => 'requestors',          {   type  => 'requestors',
             regex => $custid,              regex => $custid,
     }];          }
       ];
   
     my $invoice = make_invoice();      my $invoice = make_invoice($cust);
   
     my $lastinvoice = $state->last_invoice($custid);      my $lastinvoice = $state->last_invoice($custid);
     if ( $lastinvoice->{date} ) {      if ( $lastinvoice->{date} ) {
         my $last_invoice_date = ymd_to_DateTime( $lastinvoice->{date} );          my $last_invoice_date = ymd_to_DateTime( $lastinvoice->{date} );
             $invoice->{start} = $last_invoice_date->clone->add( days => 1 );          $invoice->{start} = $last_invoice_date->clone->add( days => 1 );
     }      }
   
     if ( !( $invoice->{start} && $invoice->{start} < $invoice->{end} ) ) {      if ( !( $invoice->{start} && $invoice->{start} < $invoice->{end} ) ) {
Line 381 
Line 384 
 }  }
   
 sub make_invoice {  sub make_invoice {
       my ($cust) = @_;
   
     my $billends      my $billends = DateTime->now->set( hour => 0, minute => 0, second => 0 )
             = DateTime->now->set( hour => 0, minute => 0, second => 0 );          ->clone->subtract( days => 1, seconds => 1 );
     my %invoice = ( end => $billends->clone->subtract( days => 1, seconds => 1 ) );  
       my %invoice = ( end => $billends );
   
       if ( $cust && $cust->{hours} ) {
           $invoice{hours} = [
               {   end   => $billends,
                   hours => $cust->{hours},
               }
           ];
       }
   
     return \%invoice;      return \%invoice;
 }  }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

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