X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Ftax_rate.pm;h=0d9156b4316d62b7127c296c878872aec4e76afd;hb=399e73ed1e73443523d6889b703d04289ec0e117;hp=bd981e30107891a9f810eace4d20fa7b9d647dd9;hpb=6397a30ca9f53c90a503da8786925ec75535a699;p=freeside.git diff --git a/FS/FS/tax_rate.pm b/FS/FS/tax_rate.pm index bd981e301..0d9156b43 100644 --- a/FS/FS/tax_rate.pm +++ b/FS/FS/tax_rate.pm @@ -369,8 +369,12 @@ sub taxline { if ($self->passtype == 2); my $amount = 0; - return [$name, $amount] # we always know how to handle disabled taxes - if $self->disabled; + if ( $self->disabled ) { # we always know how to handle disabled taxes + return { + 'name' => $name, + 'amount' => $amount, + }; + } my $taxable_charged = 0; my @cust_bill_pkg = grep { $taxable_charged += $_ unless ref; ref; } @@ -381,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) { @@ -421,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 ); } } @@ -450,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_taxes')) { + 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 @@ -531,9 +560,11 @@ sub batch_import { /^(\d{4})(\d{2})(\d{2})$/ && ($r="$1/$2/$3"); $r; }; - $column_callbacks[8] = $date_format; + my $trim = sub { my $r = shift; $r =~ s/^\s*//; $r =~ s/\s*$//; $r }; push @column_lengths, qw( 10 1 1 8 8 5 8 8 8 1 2 2 30 8 8 10 2 8 2 1 2 2 ); push @column_lengths, 1 if $format eq 'cch-update'; + push @column_callbacks, $trim foreach (@column_lengths); # 5, 6, 15, 17 esp + $column_callbacks[8] = $date_format; } my $line; @@ -781,13 +812,13 @@ sub batch_import { } -=item process_batch +=item process_batch_import Load a batch import as a queued JSRPC job =cut -sub process_batch { +sub process_batch_import { my $job = shift; my $param = thaw(decode_base64(shift)); @@ -884,10 +915,12 @@ sub process_batch { UNLINK => 0, #meh ) or die "can't open temp file: $!\n"; + my $insert_pattern = ($format eq 'cch-update') ? qr/"I"\s*$/ : qr/I\s*$/; + my $delete_pattern = ($format eq 'cch-update') ? qr/"D"\s*$/ : qr/D\s*$/; while(<$fh>) { my $handle = ''; - $handle = $ifh if $_ =~ /"I"\s*$/; - $handle = $dfh if $_ =~ /"D"\s*$/; + $handle = $ifh if $_ =~ /$insert_pattern/; + $handle = $dfh if $_ =~ /$delete_pattern/; unless ($handle) { $error = "bad input line: $_" unless $handle; last;