X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Ftax_rate.pm;h=887c9af2c827a97063f4862caff3133e71cf34ec;hb=c6ba0fa6271880599ce3d60dcd23de248526f0b8;hp=80a0f4b113fd4d5f876782f3c5225432ecc1b6f2;hpb=794a4505360fec404e2b9d5c6daf79f750186bfe;p=freeside.git diff --git a/FS/FS/tax_rate.pm b/FS/FS/tax_rate.pm index 80a0f4b11..887c9af2c 100644 --- a/FS/FS/tax_rate.pm +++ b/FS/FS/tax_rate.pm @@ -5,6 +5,8 @@ use vars qw( @ISA $DEBUG $me %tax_unittypes %tax_maxtypes %tax_basetypes %tax_authorities %tax_passtypes %GetInfoType ); use Date::Parse; +use DateTime; +use DateTime::Format::Strptime; use Storable qw( thaw ); use IO::File; use File::Temp; @@ -586,7 +588,7 @@ sub batch_import { if ( $format eq 'cch-fixed' || $format eq 'cch-fixed-update' ) { $format =~ s/-fixed//; my $date_format = sub { my $r=''; - /^(\d{4})(\d{2})(\d{2})$/ && ($r="$1/$2/$3"); + /^(\d{4})(\d{2})(\d{2})$/ && ($r="$3/$2/$1"); $r; }; my $trim = sub { my $r = shift; $r =~ s/^\s*//; $r =~ s/\s*$//; $r }; @@ -617,7 +619,13 @@ sub batch_import { $hash->{'actionflag'} ='I' if ($hash->{'data_vendor'} eq 'cch'); $hash->{'data_vendor'} ='cch'; - $hash->{'effective_date'} = str2time($hash->{'effective_date'}); + my $parser = new DateTime::Format::Strptime( pattern => "%m/%d/%Y", + time_zone => 'floating', + ); + my $dt = $parser->parse_datetime( $hash->{'effective_date'} ); + $hash->{'effective_date'} = $dt ? $dt->epoch : ''; + + $hash->{$_} = sprintf("%.2f", $hash->{$_}) foreach qw( taxbase taxmax ); my $taxclassid = join(':', map{ $hash->{$_} } qw(taxtype taxcat) );