summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/cdr.pm24
-rw-r--r--FS/FS/cdr/asterisk.pm1
-rw-r--r--FS/FS/cdr/genband.pm1
-rw-r--r--FS/FS/cdr/genband_meetme.pm1
-rw-r--r--FS/FS/cdr/nextone.pm1
-rw-r--r--FS/FS/cdr/openser.pm1
-rw-r--r--FS/FS/cdr/simple.pm17
-rw-r--r--FS/FS/cdr/simple2.pm51
-rw-r--r--FS/FS/cdr/taqua.pm1
-rw-r--r--FS/FS/cdr/unitel.pm1
10 files changed, 88 insertions, 11 deletions
diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm
index 3b5579ca3..b7310fe9c 100644
--- a/FS/FS/cdr.pm
+++ b/FS/FS/cdr.pm
@@ -15,7 +15,7 @@ use FS::cdr_carrier;
use FS::cdr_upstream_rate;
@ISA = qw(FS::Record);
-@EXPORT_OK = qw( _cdr_date_parser_maker );
+@EXPORT_OK = qw( _cdr_date_parser_maker _cdr_min_parser_maker );
$DEBUG = 0;
@@ -547,8 +547,24 @@ sub import_formats {
%import_formats;
}
-sub _cdr_date_parser_maker {
+sub _cdr_min_parser_maker {
my $field = shift;
+ my @fields = ref($field) ? @$field : ($field);
+ return sub {
+ my( $cdr, $min ) = @_;
+ my $sec = eval { _cdr_min_parse($min) };
+ die "error parsing seconds for @fields from $min minutes: $@\n" if $@;
+ $cdr->$_($sec) foreach @fields;
+ };
+}
+
+sub _cdr_min_parse {
+ my $min = shift;
+ sprintf('%.0f', $min * 60 );
+}
+
+sub _cdr_date_parser_maker {
+ my $field = shift || [qw( billsec duration )];
return sub {
my( $cdr, $date ) = @_;
#$cdr->$field( _cdr_date_parse($date) );
@@ -613,11 +629,11 @@ sub batch_import {
if ( $type eq 'csv' ) {
eval "use Text::CSV_XS;";
die $@ if $@;
- my $parser = new Text::CSV_XS;
+ $parser = new Text::CSV_XS;
} elsif ( $type eq 'fixedlength' ) {
eval "use Parse::FixedLength;";
die $@ if $@;
- my $parser = new Parse::FixedLength $info->{'fixedlength_format'};
+ $parser = new Parse::FixedLength $info->{'fixedlength_format'};
} else {
die "Unknown CDR format type $type for format $format\n";
}
diff --git a/FS/FS/cdr/asterisk.pm b/FS/FS/cdr/asterisk.pm
index c6879622a..8b29642ea 100644
--- a/FS/FS/cdr/asterisk.pm
+++ b/FS/FS/cdr/asterisk.pm
@@ -1,5 +1,6 @@
package FS::cdr::asterisk;
+use strict;
use vars qw(@ISA %info);
use FS::cdr qw(_cdr_date_parser_maker);
diff --git a/FS/FS/cdr/genband.pm b/FS/FS/cdr/genband.pm
index a50995089..298625bf4 100644
--- a/FS/FS/cdr/genband.pm
+++ b/FS/FS/cdr/genband.pm
@@ -1,5 +1,6 @@
package FS::cdr::genband;
+use strict;
use vars qw(@ISA %info);
use FS::cdr qw(_cdr_date_parser_maker);
diff --git a/FS/FS/cdr/genband_meetme.pm b/FS/FS/cdr/genband_meetme.pm
index b4414ab22..d87dd8fbf 100644
--- a/FS/FS/cdr/genband_meetme.pm
+++ b/FS/FS/cdr/genband_meetme.pm
@@ -1,5 +1,6 @@
package FS::cdr::genband_meetme;
+use strict;
use vars qw(@ISA %info);
use FS::cdr qw(_cdr_date_parser_maker);
diff --git a/FS/FS/cdr/nextone.pm b/FS/FS/cdr/nextone.pm
index e8ef0d4d2..0e31456cd 100644
--- a/FS/FS/cdr/nextone.pm
+++ b/FS/FS/cdr/nextone.pm
@@ -1,5 +1,6 @@
package FS::cdr::nextone;
+use strict;
use vars qw(@ISA %info);
use FS::cdr qw(_cdr_date_parser_maker);
diff --git a/FS/FS/cdr/openser.pm b/FS/FS/cdr/openser.pm
index 1c2796ef4..87fb82251 100644
--- a/FS/FS/cdr/openser.pm
+++ b/FS/FS/cdr/openser.pm
@@ -1,5 +1,6 @@
package FS::cdr::openser;
+use strict;
use vars qw(@ISA %info);
use FS::cdr qw(_cdr_date_parser_maker);
diff --git a/FS/FS/cdr/simple.pm b/FS/FS/cdr/simple.pm
index ab1e3eab5..b923405d1 100644
--- a/FS/FS/cdr/simple.pm
+++ b/FS/FS/cdr/simple.pm
@@ -1,7 +1,9 @@
package FS::cdr::simple;
-use vars qw(@ISA %info);
-use FS::cdr;
+use strict;
+use vars qw( @ISA %info $tmp_mon $tmp_mday $tmp_year );
+use Time::Local;
+use FS::cdr qw(_cdr_min_parser_maker);
@ISA = qw(FS::cdr);
@@ -37,11 +39,12 @@ use FS::cdr;
'dst',
# Duration
- sub { my($cdr, $min) = @_;
- my $sec = sprintf('%.0f', $min * 60 );
- $cdr->billsec( $sec );
- $cdr->duration( $sec );
- },
+ _cdr_min_parser_maker, #( [qw( billsec duration)] ),
+ #sub { my($cdr, $min) = @_;
+ # my $sec = sprintf('%.0f', $min * 60 );
+ # $cdr->billsec( $sec );
+ # $cdr->duration( $sec );
+ # },
],
);
diff --git a/FS/FS/cdr/simple2.pm b/FS/FS/cdr/simple2.pm
new file mode 100644
index 000000000..a4b5fdb29
--- /dev/null
+++ b/FS/FS/cdr/simple2.pm
@@ -0,0 +1,51 @@
+package FS::cdr::simple2;
+
+use strict;
+use vars qw( @ISA %info $tmp_mon $tmp_mday $tmp_year );
+use Time::Local;
+use FS::cdr qw(_cdr_min_parser_maker);
+
+@ISA = qw(FS::cdr);
+
+%info = (
+ 'name' => 'Simple (Prerated)',
+ 'weight' => 25,
+ 'header' => 1,
+ 'import_fields' => [
+ sub {}, #TEXT_TIME (redundant w/Time)
+ sub {}, #Blank
+ 'src', #Calling.
+
+ #Date (YY/MM/DD)
+ sub { my($cdr, $date) = @_;
+ $date =~ /^(\d\d(\d\d)?)\/(\d{1,2})\/(\d{1,2})$/
+ or die "unparsable date: $date"; #maybe we shouldn't die...
+ #$cdr->startdate( timelocal(0, 0, 0 ,$3, $2-1, $1) );
+ ($tmp_mday, $tmp_mon, $tmp_year) = ( $3, $2-1, $1 );
+ },
+
+ #Time
+ sub { my($cdr, $time) = @_;
+ $time =~ /^(\d{1,2}):(\d{1,2}):(\d{1,2})$/
+ or die "unparsable time: $time"; #maybe we shouldn't die...
+ #$cdr->startdate( timelocal($3, $2, $1 ,$mday, $mon, $year) );
+ $cdr->startdate(
+ timelocal($3, $2, $1 ,$tmp_mday, $tmp_mon, $tmp_year)
+ );
+ },
+
+ 'dst', #Dest
+ 'userfield', #? #DestinationDesc
+
+ #Min
+ _cdr_min_parser_maker, #( [qw( billsec duration)] ),
+
+ sub {}, #Rate XXX do something w/this, informationally???
+ 'upstream_price', #Total
+
+ 'accountcode', #ServCode
+ 'description', #Service_Type
+ ],
+);
+
+
diff --git a/FS/FS/cdr/taqua.pm b/FS/FS/cdr/taqua.pm
index 587d97d01..bdbac1327 100644
--- a/FS/FS/cdr/taqua.pm
+++ b/FS/FS/cdr/taqua.pm
@@ -1,5 +1,6 @@
package FS::cdr::taqua;
+use strict;
use vars qw(@ISA %info);
use FS::cdr qw(_cdr_date_parser_maker);
diff --git a/FS/FS/cdr/unitel.pm b/FS/FS/cdr/unitel.pm
index 74d0840db..df34a57c1 100644
--- a/FS/FS/cdr/unitel.pm
+++ b/FS/FS/cdr/unitel.pm
@@ -1,5 +1,6 @@
package FS::cdr::unitel;
+use strict;
use vars qw(@ISA %info);
use FS::cdr;