summaryrefslogtreecommitdiff
path: root/httemplate/search/report_tax.cgi
diff options
context:
space:
mode:
authorivan <ivan>2004-11-09 11:00:08 +0000
committerivan <ivan>2004-11-09 11:00:08 +0000
commit8d08e1ab9469979d5213621139a3f308ad7e5d16 (patch)
treecb9d1fa54e1398cbc3cca36cdfd6bcccab1120a7 /httemplate/search/report_tax.cgi
parentf2eeb9006f36d49a222e55f4d595a79cdef496fb (diff)
add handling for texas tax exemption and warning that report might not make sense for partial months other than the current one
Diffstat (limited to 'httemplate/search/report_tax.cgi')
-rwxr-xr-xhttemplate/search/report_tax.cgi38
1 files changed, 34 insertions, 4 deletions
diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi
index 8cf6bd758..aa85be686 100755
--- a/httemplate/search/report_tax.cgi
+++ b/httemplate/search/report_tax.cgi
@@ -42,6 +42,7 @@ my $gotcust = "
)
";
+my $monthly_exempt_warning = 0;
my($total, $exempt, $taxable, $owed, $tax) = ( 0, 0, 0, 0, 0 );
my $out = 'Out of taxable region(s)';
my %regions;
@@ -81,16 +82,37 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) {
my $t = scalar_sql($r, \@param,
"SELECT SUM($e) $fromwhere AND $nottax AND ( tax != 'Y' OR tax IS NULL )"
);
- $taxable += $t;
- $regions{$label}->{'taxable'} += $t;
- $owed += $t * ($r->tax/100);
- $regions{$label}->{'owed'} += $t * ($r->tax/100);
my $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 $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;
+ }
+
+ $taxable += $t;
+ $regions{$label}->{'taxable'} += $t;
+
$exempt += $x;
$regions{$label}->{'exempt'} += $x;
+
+ $owed += $t * ($r->tax/100);
+ $regions{$label}->{'owed'} += $t * ($r->tax/100);
+
}
if ( defined($regions{$label}->{'rate'})
@@ -214,6 +236,14 @@ sub scalar_sql {
</TABLE>
+<% if ( $monthly_exempt_warning ) { %>
+ <BR>
+ Partial-month tax reports (except for current month) may not be correct due
+ to month-granularity tax exemption (usually "texas tax"). For an accurate
+ report, start on the first of a month and end on the last day of a month (or
+ leave blank for to now).
+<% } %>
+
</BODY>
</HTML>