eliminate some false laziness in FS::Misc::send_email vs. msg_template/email.pm send_...
[freeside.git] / FS / FS / cust_bill_pkg_tax_location.pm
index 2ffc273..4a641be 100644 (file)
@@ -125,7 +125,7 @@ sub check {
     || $self->ut_number('pkgnum', 'cust_pkg', 'pkgnum' )
     || $self->ut_foreign_key('locationnum', 'cust_location', 'locationnum' )
     || $self->ut_money('amount')
-    || $self->ut_foreign_key('taxable_billpkgnum', 'cust_bill_pkg', 'billpkgnum')
+    || $self->ut_foreign_keyn('taxable_billpkgnum', 'cust_bill_pkg', 'billpkgnum')
   ;
   return $error if $error;
 
@@ -144,6 +144,19 @@ Returns the cust_bill_pkg object for the I<taxable> charge.
 
 Returns the associated cust_location object
 
+=item taxname
+
+Returns the tax name (for populating the itemdesc field).
+
+=cut
+
+sub taxname {
+  my $self = shift;
+  my $cust_main_county = FS::cust_main_county->by_key($self->taxnum)
+    or return '';
+  $cust_main_county->taxname || 'Tax';
+}
+
 =item desc
 
 Returns a description for this tax line item constituent.  Currently this
@@ -325,7 +338,7 @@ sub upgrade_taxable_billpkgnum {
         } #for $i
       } else {
         # the more complicated case
-        $log->warn("mismatched charges and tax links in pkg#$pkgnum",
+        $log->warning("mismatched charges and tax links in pkg#$pkgnum",
           object => $cust_bill);
         my $tax_amount = sum(map {$_->amount} @tax_links);
         # remove all tax link records and recreate them to be 1:1 with