summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2004-11-09 11:42:57 +0000
committerivan <ivan>2004-11-09 11:42:57 +0000
commit8ff40ad9fda839402bce3c2ec40925a6588675c8 (patch)
tree355ad2b3df61048f85e01505685491d352520c74
parent9a71f10cf255c7af74022a3e79342b3da7ceda68 (diff)
add handling for texas tax exemption and warning that report might not make sense for partial months other than the current one
-rwxr-xr-xhttemplate/search/report_tax.cgi51
1 files changed, 27 insertions, 24 deletions
diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi
index aa85be686..587665740 100755
--- a/httemplate/search/report_tax.cgi
+++ b/httemplate/search/report_tax.cgi
@@ -77,43 +77,45 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) {
$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 @@ push @regions, {
'exempt' => $exempt,
'taxable' => $taxable,
'rate' => '',
+ 'owed' => $owed,
'tax' => $tax,
};