[BACK]Return to test.pl CVS log [TXT][DIR] Up to [local] / RT / Invoicing

Diff for /RT/Invoicing/test.pl between version 1.2 and 1.6

version 1.2, 2011/03/20 02:34:42 version 1.6, 2020/08/02 02:05:31
Line 1 
Line 1 
 #!/usr/bin/perl  #!/usr/bin/perl
 # $AFresh1: test.pl,v 1.1.1.1 2011/03/19 22:27:16 andrew Exp $  # $AFresh1: test.pl,v 1.5 2011/12/21 02:20:59 andrew Exp $
 use strict;  use strict;
 use warnings;  use warnings;
   
 use Template;  use Template;
   use DateTime;
   use Cwd qw< abs_path >;
   
 my %invoice = (  my %invoice = (
     id => 1,      id      => 1234,
     info1 => 'Visit me online at http://example.com',      invdate => DateTime->new( year => 2011, month => 3, day => 1 ),
     info2 => 'Create a new ticket rt@example.com',      start   => DateTime->new( year => 2011, month => 1, day => 1 ),
     from => {      end     => DateTime->new( year => 2011, month => 3, day => 19 ),
         name => 'Example Company',      logo    => abs_path( 'logo.pdf' ),
         #attn => 'Jane Smith',      info    => [
         addr1 => '22115 Central Way',          'Visit me online at http://example.com',
         addr2 => 'Suite C',          'Create a new ticket rt@example.com',
         city => 'Anytown',      ],
         state => 'America',      from => 'Example Company
         zip  => '11111',  
         phone => '(800) 555-1212',  22115 Central Way
         email => 'company@example.com',  
     },  Suite C
     to => {  
         name => 'John Doe',  Anytown, America  11111
         addr1 => '123 W Main St',  
         city => 'Anytown',  (800) 555-1212
         state => 'America',  
         zip  => '11111',  \texttt{<company@example.com>}',
     },      to => 'John Doe
   
   123 W Main St
   
   Anytown, America  11111',
     projects => [      projects => [
         {          {
             title => 'Weekly Retainer',              title => 'Weekly Retainer',
Line 60 
Line 66 
                     count => 1.5,                      count => 1.5,
                     rate => 100,                      rate => 100,
                 },                  },
             ],  
             discounts => [  
                 {                  {
                     contents => 'Included Hours',                      contents => 'Rounding FAIL',
                     amount   => .33 * 75,                      detail => 'Should be $8.30',
                       count => .083,
                       rate => 100,
                 },                  },
                 {  
                     contents => 'Included Hours',  
                     amount   => 1.5 * 100,  
                 },  
             ],              ],
         },          },
         {          {
Line 88 
Line 90 
                     rate => 100,                      rate => 100,
                 },                  },
                 {                  {
                     contents => '2011-01-12: REdefine Project (903)',                      contents => '2011-01-12: Redefine Project (903)',
                     count => 0.25,                      count => 0.25,
                     rate => 75,                      rate => 75,
                 },                  },
Line 98 
Line 100 
                     rate => 125,                      rate => 125,
                 },                  },
             ],              ],
             discounts => [  
                 {  
                     contents => 'Included Hours',  
                     amount   => (.33 * 75) + ( 3.33 * 100 ),  
                 },  
                 {  
                     contents => 'Included Hours',  
                     amount   => (.25 * 75 ) + (2.25 * 100),  
                 },  
             ],  
         },          },
         {          {
             id => 85,              id => 85,
Line 139 
Line 131 
             ],              ],
         },          },
     ],      ],
       discount => {
           contents => 'Discount',
           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;  my $tt = Template->new;
   

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.6

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