File: [local] / RT / Invoicing / test.pl (download)
Revision 1.2, Sun Mar 20 01:34:42 2011 UTC (13 years, 3 months ago) by andrew
Branch: MAIN
Changes since 1.1: +6 -1 lines
add latex_encode to filter output all fields, ugly but ?
add detail lines under project, fee, expense and discounts
|
#!/usr/bin/perl
# $AFresh1: test.pl,v 1.2 2011/03/20 01:34:42 andrew Exp $
use strict;
use warnings;
use Template;
my %invoice = (
id => 1,
info1 => 'Visit me online at http://example.com',
info2 => 'Create a new ticket rt@example.com',
from => {
name => 'Example Company',
#attn => 'Jane Smith',
addr1 => '22115 Central Way',
addr2 => 'Suite C',
city => 'Anytown',
state => 'America',
zip => '11111',
phone => '(800) 555-1212',
email => 'company@example.com',
},
to => {
name => 'John Doe',
addr1 => '123 W Main St',
city => 'Anytown',
state => 'America',
zip => '11111',
},
projects => [
{
title => 'Weekly Retainer',
fees => [
{
contents => '2011-03-06 through 2011-03-12',
count => 1,
rate => 300,
},
{
contents => '2011-03-13 through 2011-03-19',
count => 1,
rate => 300,
},
],
},
{
id => 60,
title => '60: A Special Project',
detail => 'Requestors jdoe@example.net',
fees => [
{
contents => '2011-01-01: Talk a lot (727)',
detail => 'This is detail about 727',
count => 0.33,
rate => 75,
},
{
contents => '2011-01-15: Write Stuff (730)',
detail => 'This is detail about 730',
count => 1.5,
rate => 100,
},
],
discounts => [
{
contents => 'Included Hours',
amount => .33 * 75,
},
{
contents => 'Included Hours',
amount => 1.5 * 100,
},
],
},
{
id => 65,
title => '65: More work!',
detail => 'Requestors jdoe@example.net',
fees => [
{
contents => '2011-01-06: Define Project (751)',
count => 0.33,
rate => 75,
},
{
contents => '2011-01-11: Code it up! (823)',
count => 5,
rate => 100,
},
{
contents => '2011-01-12: REdefine Project (903)',
count => 0.25,
rate => 75,
},
{
contents => '2011-01-13: Change everything: 933',
count => 3,
rate => 125,
},
],
discounts => [
{
contents => 'Included Hours',
amount => (.33 * 75) + ( 3.33 * 100 ),
},
{
contents => 'Included Hours',
amount => (.25 * 75 ) + (2.25 * 100),
},
],
},
{
id => 85,
title => '85: Replace stuff',
detail => 'Requestors maintenance@example.net',
fees => [
{
contents => '2011-01-13: Go unplug, replace, replug (834)',
count => 2,
rate => 125,
},
],
expenses => [
{
contents => '2x unbroken thingys',
amount => 25,
}
],
},
{
id => 90,
title => '90: Make a two page invoice',
fees => [
{
contents => '2011-01-13: Add some stuff (834)',
count => 2,
rate => 125,
},
],
},
],
);
my $tt = Template->new;
$tt->process( 'invoice.tex.tt', \%invoice, 'invoice.pdf' ) || die $tt->error . "\n";