summaryrefslogtreecommitdiff
path: root/FS/FS/cdr/voip_innovations.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-07-23 10:56:09 -0700
committerMark Wells <mark@freeside.biz>2013-07-23 10:56:09 -0700
commit0778b67fa9c0b1de217d589bf4a717299c376a78 (patch)
treec35fda9c664e10b2b6c1adea9370520a0b7a051b /FS/FS/cdr/voip_innovations.pm
parent55753aaf5b1189c06a99fe5e0791fc33316df06f (diff)
VoIP Innovations CDR format and import script, #23646
Diffstat (limited to 'FS/FS/cdr/voip_innovations.pm')
-rw-r--r--FS/FS/cdr/voip_innovations.pm70
1 files changed, 70 insertions, 0 deletions
diff --git a/FS/FS/cdr/voip_innovations.pm b/FS/FS/cdr/voip_innovations.pm
new file mode 100644
index 0000000..29dffea
--- /dev/null
+++ b/FS/FS/cdr/voip_innovations.pm
@@ -0,0 +1,70 @@
+package FS::cdr::voip_innovations;
+
+use strict;
+use base qw( FS::cdr );
+use vars qw( %info );
+use FS::cdr qw( _cdr_date_parser_maker _cdr_min_parser_maker );
+
+%info = (
+ 'name' => 'VoIP Innovations',
+ 'weight' => 540,
+ 'header' => 1,
+ 'type' => 'csv',
+ 'sep_char' => ';',
+
+ 'import_fields' => [
+ # CallType
+ sub { my($cdr, $type) = @_;
+ # DNIS and ANI are the same columns regardless of direction,
+ # so all we need to assign is the IP address
+ if ($type =~ /^term/i) {
+ $cdr->dst_ip_addr( $cdr->get('ipaddr') );
+ } else {
+ $cdr->src_ip_addr( $cdr->get('ipaddr') );
+ }
+ # also strip the leading '1' or '+1' from src/dst
+ foreach (qw(src dst)) {
+ my $num = $cdr->get($_);
+ $num =~ s/^\+?1//;
+ $cdr->set($_, $num);
+ }
+ },
+ # StartTime
+ _cdr_date_parser_maker('startdate'),
+ # StopTime
+ _cdr_date_parser_maker('enddate'),
+ # CallDuration
+ sub { my($cdr, $duration) = @_;
+ $cdr->duration(sprintf('%.0f',$duration));
+ },
+ # BillDuration (granularized)
+ sub { my($cdr, $billsec) = @_;
+ $cdr->billsec(sprintf('%.0f',$billsec));
+ },
+ # CallMinimum, CallIncrement (used to granularize BillDuration)
+ '', '',
+ # BasePrice
+ '',
+ # CallPrice
+ 'upstream_price',
+ # TransactionId (seems not to be meaningful to us)
+ '',
+ # CustomerIP
+ 'ipaddr', # will go to src or dst addr, depending
+ # ANI
+ 'src',
+ # ANIState
+ '', # would be really useful for classifying inter/intrastate calls,
+ # except we don't use it
+ # DNIS
+ 'dst',
+ # LRN (Local Routing Number of the destination)
+ '',
+ # DNISState, DNISLATA, DNISOCN
+ '', '', '',
+ # OrigTier, TermRateDeck
+ '', '', # these are upstream rate plans, but they're not numeric
+ ],
+);
+
+1;