[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.17 and 1.18

version 1.17, 2011/03/22 05:06:05 version 1.18, 2011/03/22 05:55:27
Line 20 
Line 20 
   
 use 5.010;  use 5.010;
   
 use YAML::Any;  
 use Template;  use Template;
 use RT::Client::REST;  use RT::Client::REST;
 use RT::Client::REST::Ticket;  use RT::Client::REST::Ticket;
 use RT::Client::REST::User;  use RT::Client::REST::User;
   
   use File::Path;
 use DateTime;  use DateTime;
   
 my $config = RTI::Config->new();  my $config = RTI::Config->new();
Line 176 
Line 176 
     $invoice->{to}   = make_address( $cust->{address} || $custid );      $invoice->{to}   = make_address( $cust->{address} || $custid );
   
     $state->{lastinvoice}++;      $state->{lastinvoice}++;
     $invoice->{id}   = $state->{lastinvoice};      $invoice->{id} = $state->{lastinvoice};
     $invoice->{file} = sprintf 'invoice_%06d.pdf', $state->{lastinvoice};      $invoice->{file} = sprintf 'invoice_%06d.pdf', $state->{lastinvoice};
   
     foreach my $k (qw/ file transactions start end total past_due total_due /)      foreach my $k (qw/ file transactions start end total past_due total_due /)
Line 201 
Line 201 
             $invoice->{$key} = $invoice->{$key}->strftime('%B %d, %Y');              $invoice->{$key} = $invoice->{$key}->strftime('%B %d, %Y');
         }          }
     }      }
   
       my $invoice_dir = $config->get('invoice_dir');
       File::Path::make_path($invoice_dir);
       my $file = join '/', $invoice_dir, $invoice->{file};
   
     my $tt = Template->new;      my $tt = Template->new;
     $tt->process( 'invoice.tex.tt', $invoice, $invoice->{file} )      $tt->process( 'invoice.tex.tt', $invoice, $file )
         or die $tt->error . "\n";          or die $tt->error . "\n";
   
     printf "Generated %s for %s: \$%.02f\n", $invoice->{file}, $custid,      printf "Generated %s for %s: \$%.02f\n", $invoice->{file}, $custid,
Line 611 
Line 616 
 sub get {  sub get {
     my ( $self, $key ) = @_;      my ( $self, $key ) = @_;
     my $value = Load( Dump( $self->{_config}->{$key} ) );      my $value = Load( Dump( $self->{_config}->{$key} ) );
     if ( !$value ) {  
         given ($key) {      return $value if $value;
             when ('state') {  
                 $value = dirname( $self->{file} ) . '/rt_invoice.state'      given ($key) {
             }          when ('state') {
               $value = $self->{file};
               $value =~ s/(?:\.[^.]+)?$/\.state/;
         }          }
           when ('invoice_dir') {
               $value = dirname( $self->{file} ) . '/invoices';
           }
     }      }
   
     return $value;      return $value;
 }  }
   

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

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