summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2019-03-25 12:36:14 -0400
committerChristopher Burger <burgerc@freeside.biz>2019-03-25 12:36:14 -0400
commit6c0e57a800a9691f9b585fdbb8fac3f01b6edf47 (patch)
tree2a59d69e188038194fd36de71ca1e7f70d514967 /FS/FS
parentf1d04f65cbacc2d5f4a286ef2a4c3f1b6b3943c2 (diff)
RT# 82992 - Added new cdr import format ThinQ
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/cdr/thinq.pm62
1 files changed, 62 insertions, 0 deletions
diff --git a/FS/FS/cdr/thinq.pm b/FS/FS/cdr/thinq.pm
new file mode 100644
index 0000000..cbe0aa7
--- /dev/null
+++ b/FS/FS/cdr/thinq.pm
@@ -0,0 +1,62 @@
+package FS::cdr::thinq;
+
+use strict;
+use vars qw( @ISA %info $tmp_mon $tmp_mday $tmp_year );
+use base qw( FS::cdr );
+use Time::Local;
+use Date::Parse;
+
+@ISA = qw(FS::cdr);
+
+%info = (
+ 'name' => 'ThinQ',
+ 'weight' => 13,
+ 'type' => 'csv',
+ 'header' => 1,
+ 'disabled' => 0, #0 default, set to 1 to disable
+
+
+ 'import_fields' => [
+
+ # Date (YYYY-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...
+ ($tmp_mday, $tmp_mon, $tmp_year) = ( $4, $3-1, $1 );
+ },
+
+ # Time (HH:MM:SS )
+ 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 ,$tmp_mday, $tmp_mon, $tmp_year)
+ );
+ },
+
+ 'carrierid', # carrier_id
+ 'src', # from_ani
+ skip(5), # from_lrn
+ # from_lata
+ # from_ocn
+ # from_state
+ # from_rc
+ 'dst', # to_did
+ 'channel', # thing_tier
+ 'userfield', # callid
+ 'accountcode', # account_id
+ skip(2), # tf_profile
+ # dest_type
+ 'dst_ip_addr', # dest
+ skip(1), # rate
+ 'billsec', # billsec
+ skip(1), #total_charge
+ ], ## end import
+
+); ## end info
+
+sub skip { map { undef } (1..$_[0]) }
+
+1;
+
+__END__