backup the schema for tables we don't need the data from. RT#85959
[freeside.git] / FS / FS / cust_credit_bill_pkg.pm
index be9cd70..71b674c 100644 (file)
@@ -37,7 +37,7 @@ The following fields are currently supported:
 
 =item creditbillpkgnum -  primary key
 
-=item creditbillnum - Credit application to the overall invoice (see L<FS::cust_credit::bill>)
+=item creditbillnum - Credit application to the overall invoice (see L<FS::cust_credit_bill>)
 
 =item billpkgnum - Line item to which credit is applied (see L<FS::cust_bill_pkg>)
 
@@ -112,7 +112,7 @@ sub insert {
 
   if ($taxable_per_month >= 0) {  #panic if its subzero?
     my $groupby = join(',',
-      qw(taxnum year month exempt_monthly exempt_cust 
+      qw(taxnum taxtype year month exempt_monthly exempt_cust 
          exempt_cust_taxname exempt_setup exempt_recur));
     my $sum = 'SUM(amount)';
     my @exemptions = qsearch(
@@ -140,7 +140,7 @@ sub insert {
         # (above the remaining taxable charge amount).  We'll "de-exempt"
         # that much, or the amount of the new credit, whichever is smaller.
         if ($amount > $credit_per_month) {
-               "cust_bill_pkg ". $self->billpkgnum. "  Reducing.\n";
+          #warn "cust_bill_pkg ". $self->billpkgnum. "  Reducing.\n";
           $amount = $credit_per_month;
         }
       } elsif ( $exemption->exempt_setup or $exemption->exempt_recur ) {
@@ -166,11 +166,16 @@ sub insert {
         'amount'           => sprintf('%.2f', 0-$amount),
       };
 
-      my $error = $cust_tax_exempt_pkg->insert;
-      if ( $error ) {
-        $dbh->rollback if $oldAutoCommit;
-        return "error inserting cust_tax_exempt_pkg: $error";
+      if ( $cust_tax_exempt_pkg->cust_main_county ) {
+
+        my $error = $cust_tax_exempt_pkg->insert;
+        if ( $error ) {
+          $dbh->rollback if $oldAutoCommit;
+          return "error inserting cust_tax_exempt_pkg: $error";
+        }
+
       }
+
     } #foreach $exemption
   }