(and REALLY fix the line-item links too, whew) fix overreporting of tax invoiced...
[freeside.git] / httemplate / search / cust_bill_pkg.cgi
index 2354be9..1a95d01 100644 (file)
@@ -70,8 +70,6 @@ my $agentnums_sql =
 
 my @where = ( $agentnums_sql );
 
-push @where, "(duplicate IS NULL OR duplicate = '' )";
-
 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
 push @where, "_date >= $beginning",
              "_date <= $ending";
@@ -121,6 +119,13 @@ if ( $cgi->param('out') ) {
     " ( state   = $state  OR $state  = '' ) ",
     "   country = $country "
   ;
+  if ( $cgi->param('taxname') ) {
+    push @where, 'itemdesc = '. dbh->quote( $cgi->param('taxname') );
+  #} elsif ( $cgi->param('taxnameNULL') {
+  } else {
+    push @where, "( itemdesc IS NULL OR itemdesc = '' OR itemdesc = 'Tax' )";
+  }
+
   push @where, ' taxclass = '. dbh->quote( $cgi->param('taxclass') )
     if $cgi->param('taxclass');
 
@@ -140,6 +145,13 @@ if ( $cgi->param('out') ) {
 
 }
 
+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');