[freeside-commits] freeside/FS/FS part_pkg_taxrate.pm, 1.10, 1.11 tax_rate.pm, 1.25, 1.26
Jeff Finucane,420,,
jeff at wavetail.420.am
Sun May 17 21:56:17 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv16726
Modified Files:
part_pkg_taxrate.pm tax_rate.pm
Log Message:
handle dates before 1970
Index: part_pkg_taxrate.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg_taxrate.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- part_pkg_taxrate.pm 23 Apr 2009 20:31:26 -0000 1.10
+++ part_pkg_taxrate.pm 18 May 2009 04:56:15 -0000 1.11
@@ -3,6 +3,8 @@
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 @@
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 @@
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');
Index: tax_rate.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/tax_rate.pm,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- tax_rate.pm 13 May 2009 22:27:42 -0000 1.25
+++ tax_rate.pm 18 May 2009 04:56:15 -0000 1.26
@@ -5,6 +5,8 @@
%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 @@
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 @@
$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) );
More information about the freeside-commits
mailing list