diff options
author | ivan <ivan> | 2008-12-31 22:04:46 +0000 |
---|---|---|
committer | ivan <ivan> | 2008-12-31 22:04:46 +0000 |
commit | ec2059f7847d99e9218d97df988c8d68c7afcf55 (patch) | |
tree | e76d13f9de289a1d7d89eb8df923634ae3383593 | |
parent | b1a95fab76cca9fd65072b1c4852d8aebcb650ea (diff) |
finish up working bell_west CDR format, RT#4403
-rw-r--r-- | FS/FS/Record.pm | 8 | ||||
-rw-r--r-- | FS/FS/cdr/bell_west.pm | 16 |
2 files changed, 18 insertions, 6 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index a44ef8b69..f0b2efe90 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1569,6 +1569,11 @@ sub batch_import { eval "use Spreadsheet::ParseExcel;"; die $@ if $@; + eval "use DateTime::Format::Excel;"; + #for now, just let the error be thrown if it is used, since only CDR + # formats bill_west and troop use it, not other excel-parsing things + #die $@ if $@; + my $excel = Spreadsheet::ParseExcel::Workbook->new->Parse($filename); $parser = $excel->{Worksheet}[0]; #first sheet @@ -1642,7 +1647,7 @@ sub batch_import { #&{$field}(\%hash, $value); push @later, $field, $value; } else { - $hash{$field} = $value if length($value); + $hash{$field} = $value if defined($value) && length($value); } } @@ -1664,6 +1669,7 @@ sub batch_import { return "can't insert record". ( $line ? " for $line" : '' ). ": $error"; } + $row++; $imported++; if ( $job && time - $min_sec > $last ) { #progress bar diff --git a/FS/FS/cdr/bell_west.pm b/FS/FS/cdr/bell_west.pm index 960851318..4c3899bbf 100644 --- a/FS/FS/cdr/bell_west.pm +++ b/FS/FS/cdr/bell_west.pm @@ -24,10 +24,16 @@ use FS::cdr qw( _cdr_date_parser_maker _cdr_min_parser_maker ); # DATE / Yes / "DATE" Excel date format MM/DD/YYYY sub { my($cdr, $date) = @_; - $date =~ /^(\d{1,2})\/(\d{1,2})\/(\d\d(\d\d)?)$/ - or die "unparsable date: $date"; #maybe we shouldn't die... - #$cdr->startdate( timelocal(0, 0, 0 ,$2, $1-1, $3) ); - ($tmp_mday, $tmp_mon, $tmp_year) = ( $2, $1-1, $3 ); + + #$date =~ /^(\d{1,2})\/(\d{1,2})\/(\d\d(\d\d)?)$/ + # or die "unparsable date: $date"; #maybe we shouldn't die... + ##$cdr->startdate( timelocal(0, 0, 0 ,$2, $1-1, $3) ); + #($tmp_mday, $tmp_mon, $tmp_year) = ( $2, $1-1, $3 ); + + my $datetime = DateTime::Format::Excel->parse_datetime( $date ); + $tmp_mon = $datetime->mon_0; + $tmp_mday = $datetime->mday; + $tmp_year = $datetime->year; }, # CUST NO / Yes / "TIME" "075959" Text based time @@ -35,7 +41,7 @@ use FS::cdr qw( _cdr_date_parser_maker _cdr_min_parser_maker ); # is wrong sub { my($cdr, $time) = @_; #my($sec, $min, $hour, $mday, $mon, $year)= localtime($cdr->startdate); - $time =~ /^(\d{1,2}):(\d{1,2}):(\d{1,2})$/ + $time =~ /^(\d{2})(\d{2})(\d{2})$/ or die "unparsable time: $time"; #maybe we shouldn't die... #$cdr->startdate( timelocal($3, $2, $1 ,$mday, $mon, $year) ); $cdr->startdate( |