don't return an error about changing the cust_main record to the user as a payment...
[freeside.git] / FS / FS / tax_rate.pm
index 58be8cb..30d7f58 100644 (file)
@@ -407,13 +407,14 @@ sub taxline {
     };
   }
 
-  if ($self->maxtype != 0 && $self->maxtype != 9) {
+  my $maxtype = $self->maxtype || 0;
+  if ($maxtype != 0 && $maxtype != 9) {
     return $self->_fatal_or_null( 'tax with "'.
                                     $self->maxtype_name. '" threshold'
                                 );
   }
 
-  if ($self->maxtype == 9) {
+  if ($maxtype == 9) {
     return
       $self->_fatal_or_null( 'tax with "'. $self->maxtype_name. '" threshold' );
                                                                 # "texas" tax
@@ -439,7 +440,7 @@ sub taxline {
 
   my $taxable_units = 0;
   unless ($self->recurtax =~ /^Y$/i) {
-    if ($self->unittype == 0) {
+    if (( $self->unittype || 0 ) == 0) {
       my %seen = ();
       foreach (@cust_bill_pkg) {
         $taxable_units += $_->units
@@ -480,16 +481,16 @@ sub _fatal_or_null {
 
   my $conf = new FS::Conf;
 
-  $error = "fatal: can't yet handle ". $error;
+  $error = "can't yet handle $error";
   my $name = $self->taxname;
   $name = 'Other surcharges'
     if ($self->passtype == 2);
 
   if ($conf->exists('ignore_incalculable_taxes')) {
-    warn $error;
+    warn "WARNING: $error; billing anyway per ignore_incalculable_taxes conf\n";
     return { name => $name, amount => 0 };
   } else {
-    return $error;
+    return "fatal: $error";
   }
 }
 
@@ -1398,11 +1399,14 @@ sub process_download_and_update {
     eval "use XBase;";
     die $@ if $@;
 
-    my $conffile = '%%%FREESIDE_CONF%%%/cchconf';
-    my $conffh = new IO::File "<$conffile" or die "can't open $conffile: $!\n";
-    my ( $urls, $secret, $states ) =
-      map { /^(.*)$/ or die "bad config line in $conffile: $_\n"; $1 }
-          <$conffh>;
+    my $conf = new FS::Conf;
+    die "direct download of tax data not enabled\n" 
+      unless $conf->exists('taxdatadirectdownload');
+    my ( $urls, $username, $secret, $states ) =
+      $conf->config('taxdatadirectdownload');
+    die "No tax download URL provided.  ".
+        "Did you set the taxdatadirectdownload configuration value?\n"
+      unless $urls;
 
     $dir .= '/cch';