X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg_taxrate.pm;h=e29c3d0b47c524705358d85ea90525dbcad4e192;hb=dafdfc24616b04a5ff594da31e2cdd03f58634b6;hp=bc1047ee2860cc1b6ebc23ab0ff80a4431eaec49;hpb=ec71691725b6c5211b6967323cbc56a03038385d;p=freeside.git diff --git a/FS/FS/part_pkg_taxrate.pm b/FS/FS/part_pkg_taxrate.pm index bc1047ee2..e29c3d0b4 100644 --- a/FS/FS/part_pkg_taxrate.pm +++ b/FS/FS/part_pkg_taxrate.pm @@ -3,6 +3,8 @@ package FS::part_pkg_taxrate; use strict; use vars qw( @ISA ); use Date::Parse; +use DateTime; +use DateTime::Format::Strptime; use FS::UID qw(dbh); use FS::Record qw( qsearch qsearchs ); use FS::part_pkg_taxproduct; @@ -181,7 +183,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; }; $column_callbacks[16] = $date_format; @@ -286,14 +288,28 @@ sub batch_import { delete($hash->{$_}) foreach @{$map{$item}}; } - $hash->{'effdate'} = str2time($hash->{'effdate'}); + my $parser = new DateTime::Format::Strptime( pattern => "%m/%d/%Y", + time_zone => 'floating', + ); + my $dt = $parser->parse_datetime( $hash->{'effdate'} ); + return "Can't parse effdate ". $hash->{'effdate'}. ': '. $parser->errstr + unless $dt; + $hash->{'effdate'} = $dt->epoch; + $hash->{'country'} = 'US'; # CA is available - delete($hash->{'taxable'}) if ($hash->{'taxable'} eq 'N'); + $hash->{'taxable'} = '' if ($hash->{'taxable'} eq 'N'); if (exists($hash->{actionflag}) && $hash->{actionflag} eq 'D') { delete($hash->{actionflag}); + foreach my $intfield (qw( taxproductnum taxclassnum effdate )) { + if ( $hash->{$intfield} eq '' ) { + return "$intfield is empty in search! -- ". + join(" ", map { "$_ => *". $hash->{$_}. '*' } keys(%$hash) ); + } + } + my $part_pkg_taxrate = qsearchs('part_pkg_taxrate', $hash); unless ( $part_pkg_taxrate ) { if ( $hash->{taxproductnum} ) {