summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/Record.pm14
-rw-r--r--FS/FS/cust_main.pm1
-rw-r--r--FS/FS/part_pkg_taxrate.pm4
-rw-r--r--FS/FS/tax_rate.pm16
4 files changed, 20 insertions, 15 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index 2540dd399..7dea7cbc3 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -312,13 +312,13 @@ sub qsearch {
if ( $type =~ /(int|(big)?serial)/i && $value =~ /^\d+(\.\d+)?$/ ) {
$TYPE = SQL_INTEGER;
- #DBD::Pg 1.49: Cannot bind ... unknown sql_type 6
- #} elsif ( ( $type =~ /(numeric)/i && $value =~ /^[+-]?\d+(\.\d+)?$/)
- # || ( $type =~ /(real|float4)/i
- # && $value =~ /[-+]?\d*\.?\d+([eE][-+]?\d+)?/
- # )
- # ) {
- # $TYPE = SQL_FLOAT;
+ #DBD::Pg 1.49: Cannot bind ... unknown sql_type 6 with SQL_FLOAT
+ } elsif ( ( $type =~ /(numeric)/i && $value =~ /^[+-]?\d+(\.\d+)?$/)
+ || ( $type =~ /(real|float4)/i
+ && $value =~ /[-+]?\d*\.?\d+([eE][-+]?\d+)?/
+ )
+ ) {
+ $TYPE = SQL_DECIMAL;
}
if ( $DEBUG > 2 ) {
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index e7b34459c..b4f7f8cd9 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -37,6 +37,7 @@ use FS::cust_credit;
use FS::cust_refund;
use FS::part_referral;
use FS::cust_main_county;
+use FS::cust_tax_location;
use FS::agent;
use FS::cust_main_invoice;
use FS::cust_credit_bill;
diff --git a/FS/FS/part_pkg_taxrate.pm b/FS/FS/part_pkg_taxrate.pm
index 5ef887da4..6267d7a44 100644
--- a/FS/FS/part_pkg_taxrate.pm
+++ b/FS/FS/part_pkg_taxrate.pm
@@ -150,7 +150,7 @@ sub check {
|| $self->ut_text('country')
|| $self->ut_foreign_keyn('taxclassnumtaxed', 'tax_class', 'taxclassnum')
|| $self->ut_foreign_key('taxclassnum', 'tax_class', 'taxclassnum')
- || $self->ut_numbern('effective_date')
+ || $self->ut_snumbern('effdate')
|| $self->ut_enum('taxable', [ 'Y', '' ])
;
return $error if $error;
@@ -271,8 +271,6 @@ sub batch_import {
}
$hash->{'effdate'} = str2time($hash->{'effdate'});
-
- $hash->{'effdate'} = str2time($hash->{'effdate'});
$hash->{'country'} = 'US'; # CA is available
delete($hash->{'taxable'}) if ($hash->{'taxable'} eq 'N');
diff --git a/FS/FS/tax_rate.pm b/FS/FS/tax_rate.pm
index 0601032ee..4769b32ab 100644
--- a/FS/FS/tax_rate.pm
+++ b/FS/FS/tax_rate.pm
@@ -199,7 +199,7 @@ sub check {
|| $self->ut_textn('data_vendor')
|| $self->ut_textn('location')
|| $self->ut_foreign_key('taxclassnum', 'tax_class', 'taxclassnum')
- || $self->ut_numbern('effective_date')
+ || $self->ut_snumbern('effective_date')
|| $self->ut_float('tax')
|| $self->ut_floatn('excessrate')
|| $self->ut_money('taxbase')
@@ -642,6 +642,8 @@ sub batch_import {
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
+ my $hashref = $insert{$_};
+ $line = join(", ", map { "$_ => ". $hashref->{$_} } keys(%$hashref) );
return "can't insert tax_rate for $line: $error";
}
@@ -667,13 +669,15 @@ sub batch_import {
#join(" ", map { "$_ => ". $old->{$_} } @fields);
join(" ", map { "$_ => ". $old->{$_} } keys(%$old) );
}
- my $new = new FS::tax_rate( $insert{$_} );
+ my $new = new FS::tax_rate({ $old->hash, %{$insert{$_}}, 'manual' => '' });
$new->taxnum($old->taxnum);
my $error = $new->replace($old);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
- return "can't insert tax_rate for $line: $error";
+ my $hashref = $insert{$_};
+ $line = join(", ", map { "$_ => ". $hashref->{$_} } keys(%$hashref) );
+ return "can't replace tax_rate for $line: $error";
}
$imported++;
@@ -703,7 +707,9 @@ sub batch_import {
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
- return "can't insert tax_rate for $line: $error";
+ my $hashref = $delete{$_};
+ $line = join(", ", map { "$_ => ". $hashref->{$_} } keys(%$hashref) );
+ return "can't delete tax_rate for $line: $error";
}
$imported++;
@@ -831,7 +837,7 @@ sub process_batch {
unlink $file or warn "Can't delete $file: $!";
}
- $error = "No DETAIL supplied"
+ $error ||= "No DETAIL supplied"
unless ($files{detail});
open my $fh, "< $dir/". $files{detail}
or $error ||= "Can't open DETAIL file: $!";