X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcdr%2Famcom.pm;h=697a6827f33bced2432364aec76bcc41c2b32cd3;hb=bdc278d2271d688195fe2fa4621c3d65b72c0639;hp=43e6afd60a1548ad8e84e1143929d8eaef3bf093;hpb=956df0bc6383ed0513d4dd00668f3b24c42ba1e4;p=freeside.git diff --git a/FS/FS/cdr/amcom.pm b/FS/FS/cdr/amcom.pm index 43e6afd60..697a6827f 100644 --- a/FS/FS/cdr/amcom.pm +++ b/FS/FS/cdr/amcom.pm @@ -2,9 +2,9 @@ package FS::cdr::amcom; use strict; use base qw( FS::cdr ); -use vars qw( %info ); +use vars qw( %info %cdrtypes); use DateTime; -use FS::Record qw( qsearchs ); +use FS::Record qw( qsearch ); use FS::cdr_type; my ($tmp_mday, $tmp_mon, $tmp_year); @@ -16,6 +16,12 @@ my ($tmp_mday, $tmp_mon, $tmp_year); 'type' => 'csv', 'sep_char' => ',', 'disabled' => 0, + 'header_buffer' => sub { + + %cdrtypes = ( map { $_->cdrtypename => $_->cdrtypenum } + qsearch('cdr_type', {}) + ); + }, #listref of what to do with each field from the CDR, in order 'import_fields' => [ @@ -27,16 +33,17 @@ my ($tmp_mday, $tmp_mon, $tmp_year); 'accountcode',# 2. BWGroupID (centrex group) sub { # 3. BWGroupNumber my ($cdr, $field) = @_; #, $conf, $hashref) = @_; - $cdr->charged_party($field) - if $cdr->accountcode eq '' && $field =~ /^(1800|1300)/; + + if ($cdr->accountcode eq '' && $field =~ /^(1800|1300)/){ + $cdr->charged_party($field); + $cdr->accountcode($field); + } }, 'uniqueid', # 4. Record ID sub { # 5. Call Category (LOCAL, NATIONAL, FREECALL, MOBILE) my ($cdr, $data) = @_; $data ||= 'none'; - - my $cdr_type = qsearchs('cdr_type', { 'cdrtypename' => $data } ); - $cdr->set('cdrtypenum', $cdr_type->cdrtypenum) if $cdr_type; + $cdr->cdrtypenum($cdrtypes{$data} || ''); $cdr->set('dcontext', $data); }, sub { # 6. Start Date (DDMMYYYY