| version 1.44, 2011/12/30 05:01:41 |
version 1.45, 2011/12/31 02:14:32 |
|
|
| #!/usr/bin/perl |
#!/usr/bin/perl |
| # $AFresh1: rt_invoices.pl,v 1.43 2011/12/30 03:30:51 andrew Exp $ |
# $AFresh1: rt_invoices.pl,v 1.44 2011/12/30 05:01:41 andrew Exp $ |
| ######################################################################## |
######################################################################## |
| # Copyright (c) 2011 Andrew Fresh <andrew@afresh1.com> |
# Copyright (c) 2011 Andrew Fresh <andrew@afresh1.com> |
| # |
# |
|
|
| use lib './lib'; # XXX This is fragile, there are better ways |
use lib './lib'; # XXX This is fragile, there are better ways |
| use RTI::Config; |
use RTI::Config; |
| use RTI::State; |
use RTI::State; |
| |
use RTI::Util qw/ round ymd_to_DateTime /; |
| |
|
| my $config = RTI::Config->new(); |
my $config = RTI::Config->new(); |
| my $state = RTI::State->new( $config->get('state') ); |
my $state = RTI::State->new( $config->get('state') ); |
|
|
| |
|
| $state->add_invoice($invoice); |
$state->add_invoice($invoice); |
| |
|
| foreach my $key (qw/ start end /) { |
|
| if ( exists $invoice->{$key} ) { |
|
| $invoice->{$key} = $invoice->{$key}->strftime('%B %d, %Y'); |
|
| } |
|
| } |
|
| |
|
| my $invoice_dir = $config->get('invoice_dir'); |
my $invoice_dir = $config->get('invoice_dir'); |
| File::Path::make_path($invoice_dir); |
File::Path::make_path($invoice_dir); |
| my $file = join '/', $invoice_dir, $invoice->{file}; |
my $file = join '/', $invoice_dir, $invoice->{file}; |
|
|
| |
|
| $state->save; |
$state->save; |
| |
|
| sub round { |
|
| my ($amount) = @_; |
|
| |
|
| #$amount =~ s/\.\d\d\K.*$//; |
|
| #return $amount; |
|
| return sprintf "%.02f", $amount; |
|
| } |
|
| |
|
| sub find_customer_for_ticket { |
sub find_customer_for_ticket { |
| my ( $ticket, $customers ) = @_; |
my ( $ticket, $customers ) = @_; |
| |
|
|
|
| } |
} |
| } |
} |
| return $hours; |
return $hours; |
| } |
|
| |
|
| sub ymd_to_DateTime { |
|
| my ($ymd) = @_; |
|
| my ( $date, $time ) = split /[\sT]/, $ymd; |
|
| my ( $year, $month, $day ) = split '-', $date; |
|
| my ( $hour, $minute, $second ) = split ':', $time if $time; |
|
| |
|
| return DateTime->new( |
|
| year => $year, |
|
| month => $month, |
|
| day => $day, |
|
| hour => $hour || 0, |
|
| minute => $minute || 0, |
|
| second => $second || 0, |
|
| time_zone => 'local', |
|
| ); |
|
| } |
} |
| |
|
| sub get_billing_frequency { |
sub get_billing_frequency { |