summaryrefslogtreecommitdiff
path: root/FS/FS/part_pkg_taxrate.pm
diff options
context:
space:
mode:
authorjeff <jeff>2008-11-19 14:56:00 +0000
committerjeff <jeff>2008-11-19 14:56:00 +0000
commitf32fab28c5cea2b5619c9b1d5cc6e3fe7beef126 (patch)
tree0e069e7e490d9d102a5ee0379788d824326e3b83 /FS/FS/part_pkg_taxrate.pm
parent7c9c69a6e85094310f437d01877b79b3d5c845db (diff)
support for cch fixed format
Diffstat (limited to 'FS/FS/part_pkg_taxrate.pm')
-rw-r--r--FS/FS/part_pkg_taxrate.pm22
1 files changed, 18 insertions, 4 deletions
diff --git a/FS/FS/part_pkg_taxrate.pm b/FS/FS/part_pkg_taxrate.pm
index 6267d7a..1563621 100644
--- a/FS/FS/part_pkg_taxrate.pm
+++ b/FS/FS/part_pkg_taxrate.pm
@@ -6,6 +6,7 @@ use Date::Parse;
use FS::UID qw(dbh);
use FS::Record qw( qsearch qsearchs );
use FS::part_pkg_taxproduct;
+use FS::Misc qw(csv_from_fixed);
@ISA = qw(FS::Record);
@@ -175,12 +176,25 @@ sub batch_import {
my @fields;
my $hook;
+ my @column_lengths = ();
+ my @column_callbacks = ();
+ 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");
+ $r;
+ };
+ $column_callbacks[16] = $date_format;
+ push @column_lengths, qw( 28 25 2 1 10 4 30 3 100 2 2 2 2 1 2 2 8 1 );
+ push @column_lengths, 1 if $format eq 'cch-update';
+ }
+
my $line;
my ( $count, $last, $min_sec ) = (0, time, 5); #progressbar
- if ( $job ) {
- $count++
- while ( defined($line=<$fh>) );
- seek $fh, 0, 0;
+ if ( $job || scalar(@column_callbacks) ) {
+ my $error =
+ csv_from_fixed(\$fh, \$count, \@column_lengths, \@column_callbacks);
+ return $error if $error;
}
if ( $format eq 'cch' || $format eq 'cch-update' ) {