=================================================================== RCS file: /cvs/RT/Invoicing/test.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- RT/Invoicing/test.pl 2011/12/21 02:20:59 1.5 +++ RT/Invoicing/test.pl 2020/08/02 02:05:31 1.6 @@ -1,15 +1,22 @@ #!/usr/bin/perl -# $AFresh1: test.pl,v 1.4 2011/03/22 04:53:59 andrew Exp $ +# $AFresh1: test.pl,v 1.5 2011/12/21 02:20:59 andrew Exp $ use strict; use warnings; use Template; +use DateTime; +use Cwd qw< abs_path >; my %invoice = ( - id => 1, - logo => '/home/andrew/.rt_invoicing/afresh_logo.pdf', - info1 => 'Visit me online at http://example.com', - info2 => 'Create a new ticket rt@example.com', + id => 1234, + invdate => DateTime->new( year => 2011, month => 3, day => 1 ), + start => DateTime->new( year => 2011, month => 1, day => 1 ), + end => DateTime->new( year => 2011, month => 3, day => 19 ), + logo => abs_path( 'logo.pdf' ), + info => [ + 'Visit me online at http://example.com', + 'Create a new ticket rt@example.com', + ], from => 'Example Company 22115 Central Way @@ -83,7 +90,7 @@ rate => 100, }, { - contents => '2011-01-12: REdefine Project (903)', + contents => '2011-01-12: Redefine Project (903)', count => 0.25, rate => 75, }, @@ -129,6 +136,18 @@ amount => '8.498', }, ); + +foreach my $project (@{ $invoice{projects} || [] }) { + foreach my $fee (@{ $project->{fees} || [] }) { + $invoice{total} += $fee->{count} * $fee->{rate}; + } + foreach my $expense (@{ $project->{expenses} || [] }) { + $invoice{total} += $expense->{amount}; + } +} + +$invoice{total} -= $invoice{discount}{amount} + if $invoice{discount}; my $tt = Template->new;