Merge branch 'master' of git.freeside.biz:/home/git/freeside
authorMark Wells <mark@freeside.biz>
Fri, 10 Jul 2015 23:38:28 +0000 (16:38 -0700)
committerMark Wells <mark@freeside.biz>
Fri, 10 Jul 2015 23:38:28 +0000 (16:38 -0700)
FS/FS/TaxEngine/suretax.pm
httemplate/elements/tr-part_pkg-taxproducts.html
httemplate/elements/tr-select-tax_status.html
httemplate/view/cust_main/menu.html

index 8139b1d..4e7edd5 100644 (file)
@@ -85,6 +85,8 @@ sub build_request {
   my @lines = map { $self->build_item($_) }
               $cust_bill->cust_bill_pkg;
 
+  return if !@lines;
+
   my $ClientNumber = $conf->config('suretax-client_number')
     or die "suretax-client_number config required.\n";
   my $ValidationKey = $conf->config('suretax-validation_key')
@@ -306,6 +308,10 @@ sub make_taxlines {
 
   # assemble the request hash
   my $request = $self->build_request;
+  if (!$request) {
+    warn "no taxable items in invoice; skipping SureTax request\n" if $DEBUG;
+    return;
+  }
 
   warn "sending SureTax request\n" if $DEBUG;
   my $request_json = $json->encode($request);
index 274dc3b..ad464ca 100644 (file)
 my %opt = @_;
 my $field = delete($opt{field}) || 'taxproductnum';
 my $pkgpart = delete($opt{pkgpart});
-my $part_pkg = FS::part_pkg->by_key($pkgpart);
-my %pkg_options = $part_pkg->options;
-$pkg_options{'usage_taxproductnum_'} = $part_pkg->taxproductnum;
+my %pkg_options;
+if ($pkgpart) {
+  my $part_pkg = FS::part_pkg->by_key($pkgpart);
+  my %pkg_options = $part_pkg->options;
+  $pkg_options{'usage_taxproductnum_'} = $part_pkg->taxproductnum;
+}
 
 my @classes = qsearch('usage_class', { 'disabled' => '' });
 unshift @classes,
index 1e0ea8a..387e49e 100644 (file)
@@ -10,6 +10,7 @@
     name_col  => 'description',
     hashref   => { data_vendor => $vendor },
     order_by  => 'order by taxstatus',
+    required  => 1,
     %opt
   &>
 
index ab56bcf..ff001bb 100644 (file)
@@ -557,6 +557,7 @@ foreach my $submenu (@menu) {
       }
       $a .= qq[>$label</A> ];
 
+      $cgi->param('show', $opt{show});
 
     } elsif ( $entry->{popup} ) {