fix TeleAPI import (what kind of crack was Christopher smoking that he couldn't fix...
[freeside.git] / FS / FS / cdr / enswitch_calling_name.pm
1 package FS::cdr::enswitch_calling_name;
2 use base qw( FS::cdr );
3
4 use strict;
5 use vars qw( %info $tmp_mon $tmp_mday $tmp_year );
6 use FS::Record qw( qsearchs );
7 use FS::cdr_type;
8
9 %info = (
10   'name'          => 'Enswitch with calling name',
11   'weight'        => 515,
12   'header'        => 2,
13   'type'          => 'csv',
14   'import_fields' => [
15     'dcontext',     #Status
16     'startdate',    #Start, already a unix timestamp
17     skip(2),        #Start date, Start time
18     'enddate',      #End
19     skip(6),        #End date, End time
20                     #Calling customer, Calling type
21     'src',          #Calling number     
22     skip(1),        #Called type
23
24     sub { my ($cdr, $dst) = @_; 
25         $dst =~ s/\*//g;
26         $cdr->set('dst', $dst);
27     },              #Called number
28
29     skip(14),       #Destination customer, Destination type
30                     #Destination number
31                     #Destination group ID, Destination group name,
32                     #Inbound calling type,
33                     #Inbound calling number,
34                     #Inbound called type,
35                     #Inbound called number,
36                     #Inbound destination type, Inbound destination number,
37     sub { my ($cdr, $data) = @_;
38         $data ||= 'none';
39
40         my $cdr_type = qsearchs('cdr_type', { 'cdrtypename' => $data } );
41         $cdr->set('cdrtypenum', $cdr_type->cdrtypenum) if $cdr_type; 
42                 } , #Outbound calling type,
43
44       skip(11),     #Outbound calling number,
45                     #Outbound called type, Outbound called number,
46                     #Outbound destination type, Outbound destination number,
47                     #Internal calling type, Internal calling number,
48                     #Internal called type, Internal called number,
49                     #Internal destination type, Internal destination number
50     'duration',     #Total seconds
51     skip(1),        #Ring seconds
52     'billsec',      #Billable seconds
53     skip(2),        #Cost
54                     #Cost including taxes
55     'accountcode',  #Billing customer
56     skip(3),        #Billing customer name, Billing type, Billing reference
57   ],
58 );
59
60 sub skip { map {''} (1..$_[0]) }
61
62 1;