summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorjeff <jeff>2009-05-18 04:56:15 +0000
committerjeff <jeff>2009-05-18 04:56:15 +0000
commitf6dd863ff944a162b2f135e820c7932b2615e332 (patch)
tree5c100c0b580ab3a4066cb5da813b294ae37d7fb6 /FS
parent63f161eddc1d6a832ef07a43e1bc232770f5f598 (diff)
handle dates before 1970
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/part_pkg_taxrate.pm11
-rw-r--r--FS/FS/tax_rate.pm12
2 files changed, 19 insertions, 4 deletions
diff --git a/FS/FS/part_pkg_taxrate.pm b/FS/FS/part_pkg_taxrate.pm
index bc1047ee2..5a1e7baa9 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,7 +288,12 @@ 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'} );
+ $hash->{'effdate'} = $dt ? $dt->epoch : '';
+
$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 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) );