simple reporting for new tax system
[freeside.git] / httemplate / search / cust_bill_pkg.cgi
index 4ac9d9f..61d9a75 100644 (file)
@@ -123,12 +123,28 @@ if ( $cgi->param('out') ) {
     if $cgi->param('taxclass');
 
   if ( $cgi->param('taxclassNULL') ) {
-    my $same_sql = $r->sql_taxclass_sameregion;
+
+    my %hash = ( 'country' => scalar($cgi->param('country')) );
+    foreach (qw( state county )) {
+      $hash{$_} = scalar($cgi->param($_)) if $cgi->param($_);
+    }
+    my $cust_main_county = qsearchs('cust_main_county', \%hash);
+    die "unknown base region for empty taxclass" unless $cust_main_county;
+
+    my $same_sql = $cust_main_county->sql_taxclass_sameregion;
     push @where, $same_sql if $same_sql;
+
   }
 
 }
 
+if ($cgi->param('itemdesc')) {
+  if ($cgi->param('itemdesc') eq 'Tax') {
+    push @where, "(itemdesc='Tax' OR itemdesc is null)";
+  }else{
+    push @where, 'itemdesc='. dbh->quote($cgi->param('itemdesc'));
+  }
+}
 push @where, 'pkgnum != 0' if $cgi->param('nottax');
 push @where, 'pkgnum  = 0' if $cgi->param('istax');