freeside/httemplate/search report_tax.cgi,1.5.4.17,1.5.4.18
ivan
ivan at pouncequick.420.am
Tue Nov 9 03:43:02 PST 2004
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory pouncequick:/tmp/cvs-serv31480
Modified Files:
Tag: FREESIDE_1_4_BRANCH
report_tax.cgi
Log Message:
add handling for texas tax exemption and warning that report might not make sense for partial months other than the current one
Index: report_tax.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_tax.cgi,v
retrieving revision 1.5.4.17
retrieving revision 1.5.4.18
diff -u -d -r1.5.4.17 -r1.5.4.18
--- report_tax.cgi 9 Nov 2004 11:00:09 -0000 1.5.4.17
+++ report_tax.cgi 9 Nov 2004 11:42:57 -0000 1.5.4.18
@@ -77,43 +77,45 @@
$regions{$label}->{'exempt'} += $x;
}
+ my($t, $x) = (0, 0);
foreach my $e ( grep { $r->get($_.'tax') !~ /^Y/i }
qw( cust_bill_pkg.setup cust_bill_pkg.recur ) ) {
- my $t = scalar_sql($r, \@param,
+ $t += scalar_sql($r, \@param,
"SELECT SUM($e) $fromwhere AND $nottax AND ( tax != 'Y' OR tax IS NULL )"
);
- my $x = scalar_sql($r, \@param,
+ $x += scalar_sql($r, \@param,
"SELECT SUM($e) $fromwhere AND $nottax AND tax = 'Y'"
);
+ }
- my($sday,$smon,$syear) = (localtime($beginning) )[ 3, 4, 5 ];
- $monthly_exempt_warning=1 if $sday != 1 && $beginning;
- $smon++; $syear+=1900;
-
- my($eday,$emon,$eyear) = (localtime($ending) )[ 3, 4, 5 ];
- $emon++; $eyear+=1900;
+ my($sday,$smon,$syear) = (localtime($beginning) )[ 3, 4, 5 ];
+ $monthly_exempt_warning=1 if $sday != 1 && $beginning;
+ $smon++; $syear+=1900;
- my $monthly_exemption = scalar_sql($r, [ 'taxnum' ],
- "SELECT SUM(amount) FROM cust_tax_exempt where taxnum = ? ".
- " AND ( year > $syear OR ( year = $syear and month >= $smon ) )".
- " AND ( year < $eyear OR ( year = $eyear and month <= $emon ) )"
- );
- if ( $monthly_exemption ) {
- $t -= $monthly_exemption;
- $x += $monthly_exemption;
- }
+ my $eending = ( $ending == 4294967295 ) ? time : $ending;
+ my($eday,$emon,$eyear) = (localtime($eending) )[ 3, 4, 5 ];
+ $emon++; $eyear+=1900;
- $taxable += $t;
- $regions{$label}->{'taxable'} += $t;
+ my $monthly_exemption = scalar_sql($r, [ 'taxnum' ],
+ "SELECT SUM(amount) FROM cust_tax_exempt where taxnum = ? ".
+ " AND ( year > $syear OR ( year = $syear and month >= $smon ) )".
+ " AND ( year < $eyear OR ( year = $eyear and month <= $emon ) )"
+ );
+ #warn $r->taxnum(). ": $monthly_exemption\n";
+ if ( $monthly_exemption ) {
+ $t -= $monthly_exemption;
+ $x += $monthly_exemption;
+ }
- $exempt += $x;
- $regions{$label}->{'exempt'} += $x;
+ $taxable += $t;
+ $regions{$label}->{'taxable'} += $t;
- $owed += $t * ($r->tax/100);
- $regions{$label}->{'owed'} += $t * ($r->tax/100);
+ $exempt += $x;
+ $regions{$label}->{'exempt'} += $x;
- }
+ $owed += $t * ($r->tax/100);
+ $regions{$label}->{'owed'} += $t * ($r->tax/100);
if ( defined($regions{$label}->{'rate'})
&& $regions{$label}->{'rate'} != $r->tax.'%' ) {
@@ -168,6 +170,7 @@
'exempt' => $exempt,
'taxable' => $taxable,
'rate' => '',
+ 'owed' => $owed,
'tax' => $tax,
};
More information about the freeside-commits
mailing list