From 706d7c9808eba10767b8a3f2c7735c00be3797fb Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 5 Feb 2009 16:57:34 +0000 Subject: [PATCH] add a config flag to ignore new style taxes instead of throwing fatal errors --- FS/FS/Conf.pm | 7 +++++++ FS/FS/tax_rate.pm | 49 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 72fb98c0d..eb20590cf 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1468,6 +1468,13 @@ worry that config_items is freeside-specific and icky. }, { + 'key' => 'ignore_incalculable_taxes', + 'section' => 'billing', + 'description' => 'Prefer to invoice without tax over not billing at all', + 'type' => 'checkbox', + }, + + { 'key' => 'welcome_email', 'section' => '', 'description' => 'Template file for welcome email. Welcome emails are sent to the customer email invoice destination(s) each time a svc_acct record is created. See the Text::Template documentation for details on the template substitution language. The following variables are available', diff --git a/FS/FS/tax_rate.pm b/FS/FS/tax_rate.pm index 95d1c60fd..021bce333 100644 --- a/FS/FS/tax_rate.pm +++ b/FS/FS/tax_rate.pm @@ -385,27 +385,35 @@ sub taxline { if $DEBUG; if ($self->passflag eq 'N') { - return "fatal: can't (yet) handle taxes not passed to the customer"; + # return "fatal: can't (yet) handle taxes not passed to the customer"; + # until someone needs to track these in freeside + return { + 'name' => $name, + 'amount' => 0, + }; } if ($self->maxtype != 0 && $self->maxtype != 9) { - return qq!fatal: can't (yet) handle tax with "!. $self->maxtype_name. - '" threshold'; + return $self->_fatal_or_null( 'tax with "'. + $self->maxtype_name. '" threshold' + ); } if ($self->maxtype == 9) { - return qq!fatal: can't (yet) handle tax with "!. $self->maxtype_name. - '" threshold'; # "texas" tax + return + $self->_fatal_or_null( 'tax with "'. $self->maxtype_name. '" threshold' ); + # "texas" tax } # we treat gross revenue as gross receipts and expect the tax data # to DTRT (i.e. tax on tax rules) if ($self->basetype != 0 && $self->basetype != 1 && - $self->basetype != 6 && $self->basetype != 7 && - $self->basetype != 8 && $self->basetype != 14 + $self->basetype != 5 && $self->basetype != 6 && + $self->basetype != 7 && $self->basetype != 8 && + $self->basetype != 14 ) { - return qq!fatal: can't (yet) handle tax with "!. $self->basetype_name. - '" basis'; + return + $self->_fatal_or_null( 'tax with "'. $self->basetype_name. '" basis' ); } unless ($self->setuptax =~ /^Y$/i) { @@ -425,12 +433,11 @@ sub taxline { $seen{$_->pkgnum}++; } }elsif ($self->unittype == 1) { - return qq!fatal: can't (yet) handle fee with minute unit type!; + return $self->_fatal_or_null( 'fee with minute unit type' ); }elsif ($self->unittype == 2) { $taxable_units = 1; }else { - return qq!fatal: can't (yet) handle unknown unit type in tax!. - $self->taxnum; + return $self->_fatal_or_null( 'unknown unit type in tax'. $self->taxnum ); } } @@ -454,6 +461,24 @@ sub taxline { } +sub _fatal_or_null { + my ($self, $error) = @_; + + my $conf = new FS::Conf; + + $error = "fatal: can't yet handle ". $error; + my $name = $self->taxname; + $name = 'Other surcharges' + if ($self->passtype == 2); + + if ($conf->exists('ignore_incalculable_tax')) { + warn $error; + return { name => $name, amount => 0 }; + } else { + return $error; + } +} + =item tax_on_tax CUST_MAIN Returns a list of taxes which are candidates for taxing taxes for the -- 2.11.0