[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.12 and 1.13

version 1.12, 2011/03/22 01:46:41 version 1.13, 2011/03/22 02:16:53
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 = ( end => DateTime->now, );      my $invoice = make_invoice();
   
     if ( $cust->{base_rate} ) {      if ( $cust->{base_rate} ) {
         my $day  = $cust->{day}       || 1;          my $day  = $cust->{day}       || 1;
Line 61 
Line 61 
             default { die "Unknown per [$cust->{per}]\n" }              default { die "Unknown per [$cust->{per}]\n" }
         }          }
   
         my $billends          my $billends = $invoice->{end}->clone;
             = DateTime->now->set( hour => 0, minute => 0, second => 0 );  
         $billends->subtract( days => 1 ) while $billends->$day_method != $day;          $billends->subtract( days => 1 ) while $billends->$day_method != $day;
   
         my $date = $billends->clone->subtract( $per => $freq );          my $date = $billends->clone->subtract( $per => $freq );
Line 97 
Line 96 
             next if $end < $start;              next if $end < $start;
   
             $startdate = $start->clone if !$startdate || $startdate > $start;              $startdate = $start->clone if !$startdate || $startdate > $start;
             $invoice{start} ||= $start->clone;              $invoice->{start} ||= $start->clone;
             $invoice{end} = $end->clone;              $invoice->{end} = $end->clone;
             my %hours = (              my %hours = (
                 start => $start->clone,                  start => $start->clone,
                 end   => $end->clone,                  end   => $end->clone,
                 hours => { %{ $cust->{hours} } },                  hours => { %{ $cust->{hours} } },
             );              );
   
             push @{ $invoice{hours} }, \%hours;              push @{ $invoice->{hours} }, \%hours;
             push @{ $project{fees} },              push @{ $project{fees} },
                 {                  {
                 count    => 1,                  count    => 1,
Line 116 
Line 115 
         }          }
   
         if ( @{ $project{fees} } ) {          if ( @{ $project{fees} } ) {
             push @{ $invoice{projects} }, \%project;              push @{ $invoice->{projects} }, \%project;
         }          }
     }      }
   
     $cust->{address} ||= get_user($custid);      $cust->{address} ||= get_user($custid);
     $cust->{invoice} = \%invoice;      $cust->{invoice} = $invoice;
 }  }
   
 my @limits = map +{  my @limits = map +{
Line 327 
Line 326 
     my $cust = $config->get('default') || {};      my $cust = $config->get('default') || {};
     $cust->{address} = get_user($custid);      $cust->{address} = get_user($custid);
   
     my %invoice = ( end => DateTime->now );      $cust->{match} = [{
               type => 'requestors',
               regex => $custid,
       }];
   
       my $invoice = make_invoice();
   
     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} ) ) {
         $cust->{invoice} = \%invoice;          $cust->{invoice} = $invoice;
     }      }
   
     $customers->{$custid} = $cust;      $customers->{$custid} = $cust;
Line 374 
Line 378 
   
     $users{$id} = \%user;      $users{$id} = \%user;
     return \%user;      return \%user;
   }
   
   sub make_invoice {
   
       my $billends
               = DateTime->now->set( hour => 0, minute => 0, second => 0 );
       my %invoice = ( end => $billends->clone->subtract( days => 1, seconds => 1 ) );
   
       return \%invoice;
 }  }
   
 sub make_address {  sub make_address {

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

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