[freeside-commits] branch master updated. 88904ee5a5529f7e80811f1e68216c92b028e7e9

Mark Wells mark at 420.am
Thu Sep 8 14:02:36 PDT 2016


The branch, master has been updated
       via  88904ee5a5529f7e80811f1e68216c92b028e7e9 (commit)
      from  e76f288a3495e4e58ff0c80eb9acbef91943311c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 88904ee5a5529f7e80811f1e68216c92b028e7e9
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Sep 8 14:00:19 2016 -0700

    CallPlus CDR format, #72264

diff --git a/FS/FS/cdr/callplus.pm b/FS/FS/cdr/callplus.pm
new file mode 100644
index 0000000..fa6c799
--- /dev/null
+++ b/FS/FS/cdr/callplus.pm
@@ -0,0 +1,60 @@
+package FS::cdr::callplus;
+use base qw( FS::cdr );
+
+use strict;
+use vars qw( %info );
+use FS::Record qw( qsearchs );
+use Time::Local 'timelocal';
+
+# Date format in the Date/Time col: "13/07/2016 2:40:32 p.m."
+# d/m/y H:M:S, leading zeroes stripped, 12-hour with "a.m." or "p.m.".
+# There are also separate d/m/y and 24-hour time columns, but parsing
+# those separately is hard (DST issues).
+
+%info = (
+  'name'          => 'CallPlus',
+  'weight'        => 610,
+  'header'        => 1,
+  'type'          => 'csv',
+  'import_fields' => [
+    'uniqueid',           # ID
+    '',                   # Billing Group (charged_party?)
+    'src',                # Origin Number
+    'dst',                # Destination Number
+    '',                   # Description (seems to be dest caller id?)
+    '',                   # Status
+    '',                   # Terminated
+    '',                   # Date
+    '',                   # Time
+    sub {                 # Date/Time
+      # this format overlaps one of the existing parser cases, so give it
+      # its own special parser
+      my ($cdr, $value) = @_;
+      $value =~ m[^(\d{1,2})/(\d{1,2})/(\d{4}) (\d{1,2}):(\d{2}):(\d{2}) (a\.m\.|p\.m\.)$]
+        or die "unparseable date: $value";
+      my ($day, $mon, $year, $hour, $min, $sec) = ( $1, $2, $3, $4, $5, $6 );
+      $hour = $hour % 12;
+      if ($7 eq 'p.m.') {
+        $hour = 12;
+      }
+      $cdr->set('startdate',
+                timelocal($sec, $min, $hour, $day, $mon-1, $year)
+               );
+    },
+    sub {                 # Call Length (seconds)
+      my ($cdr, $value) = @_;
+      $cdr->set('duration', $value);
+      $cdr->set('billsec', $value);
+    },
+    sub {                 # Call Cost (NZD)
+      my ($cdr,$value) = @_;
+      $value =~ s/^\$//;
+      $cdr->upstream_price($value);
+    },
+    skip(4),              # Smartcode, Smartcode Description, Type, SubType
+  ],
+);
+
+sub skip { map {''} (1..$_[0]) }
+
+1;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cdr/callplus.pm |   60 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 FS/FS/cdr/callplus.pm




More information about the freeside-commits mailing list