From: Mark Wells Date: Tue, 25 Mar 2014 22:20:02 +0000 (-0700) Subject: Amcom CDR format, #27946 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=4d29332953549ff3f44cacfe296dee4b09458ad3 Amcom CDR format, #27946 --- diff --git a/FS/FS/cdr/amcom.pm b/FS/FS/cdr/amcom.pm new file mode 100644 index 000000000..5967d7b30 --- /dev/null +++ b/FS/FS/cdr/amcom.pm @@ -0,0 +1,65 @@ +package FS::cdr::amcom; + +use strict; +use base qw( FS::cdr ); +use vars qw( %info ); +use DateTime; + +my ($tmp_mday, $tmp_mon, $tmp_year); + +%info = ( + 'name' => 'Amcom', + 'weight' => 500, + 'header' => 1, + 'type' => 'csv', + 'sep_char' => ',', + 'disabled' => 0, + + #listref of what to do with each field from the CDR, in order + 'import_fields' => [ + + sub { # 1. Field Type (must be "DCR", yes, "DCR") + my ($cdr, $field, $conf, $hashref) = @_; + $hashref->{skiprow} = 1 unless $field eq 'DCR'; + }, + '', # 2. BWGroupID (centrex group) + '', # 3. BWGroupNumber + 'uniqueid', # 4. Record ID + 'dcontext', # 5. Call Category (LOCAL, NATIONAL, FREECALL, MOBILE) + sub { # 6. Start Date (DDMMYYYY + my ($cdr, $date) = @_; + $date =~ /^(\d{2})(\d{2})(\d{4})$/ + or die "unparseable date: $date"; + ($tmp_mday, $tmp_mon, $tmp_year) = ($1, $2-1, $3); + }, + sub { # 7. Start Time (HHMMSS) + my ($cdr, $time) = @_; + $time =~ /^(\d{2})(\d{2})(\d{2})$/ + or die "unparseable time: $time"; + my $dt = DateTime->new( + year => $tmp_year, + month => $tmp_mon, + day => $tmp_mday, + hour => $1, + minute => $2, + second => $3, + ); + $cdr->set('startdate', $dt->epoch); + }, + sub { # 8. Duration (seconds, 3 decimals) + my ($cdr, $seconds) = @_; + $cdr->set('duration', sprintf('%.0f', $seconds)); + $cdr->set('billsec', sprintf('%.0f', $seconds)); + }, + 'src', # 9. Calling Number + 'dst', # 10. Called Number + 'upstream_src_regionname', # 11. Calling Party Zone + 'upstream_dst_regionname', # 12. Called Party Zone + 'upstream_price', # 13. Call Cost + '', # 14. Call Cost 2 (seems to be the same?) + '', # 15. Service Provider ID + ('') x 4, # 16-20. Reserved fields + ], +); + +1;