avoid runcentral's weird proble distributing tax exemptions since it doesn't apply...
authorivan <ivan>
Thu, 10 Mar 2011 02:26:48 +0000 (02:26 +0000)
committerivan <ivan>
Thu, 10 Mar 2011 02:26:48 +0000 (02:26 +0000)
FS/FS/cust_main/Billing.pm

index 44181eb..5efeb82 100644 (file)
@@ -726,8 +726,16 @@ sub calculate_taxes {
   foreach my $tax ( keys %$taxlisthash ) {
     foreach ( @{ $taxlisthash->{$tax} }[1 ... scalar(@{ $taxlisthash->{$tax} })] ) {
       next unless ref($_) eq 'FS::cust_bill_pkg';
   foreach my $tax ( keys %$taxlisthash ) {
     foreach ( @{ $taxlisthash->{$tax} }[1 ... scalar(@{ $taxlisthash->{$tax} })] ) {
       next unless ref($_) eq 'FS::cust_bill_pkg';
-      push @{ $packagemap{$_->pkgnum}->_cust_tax_exempt_pkg }, 
-        splice( @{ $_->_cust_tax_exempt_pkg } );
+     
+      my @cust_tax_exempt_pkg = splice( @{ $_->_cust_tax_exempt_pkg } );
+
+      next unless @cust_tax_exempt_pkg; #just avoiding the prob when irrelevant?
+      die "can't distribute tax exemptions: no line item for ".  Dumper($_).
+          " in packagemap ". join(',', sort {$a<=>$b} keys %packagemap). "\n"
+        unless $packagemap{$_->pkgnum};
+
+      push @{ $packagemap{$_->pkgnum}->_cust_tax_exempt_pkg },
+           @cust_tax_exempt_pkg;
     }
   }
 
     }
   }