fix TeleAPI import (what kind of crack was Christopher smoking that he couldn't fix...
[freeside.git] / FS / FS / cdr / voip_innovations.pm
1 package FS::cdr::voip_innovations;
2
3 use strict;
4 use base qw( FS::cdr );
5 use vars qw( %info );
6 use FS::cdr qw( _cdr_date_parser_maker _cdr_min_parser_maker );
7
8 %info = (
9   'name'          => 'VoIP Innovations',
10   'weight'        => 540,
11   'header'        => 1,
12   'type'          => 'csv',
13   'sep_char'      => ';',
14
15   'import_fields' => [
16     # CallType
17     sub { my($cdr, $type) = @_;
18           # DNIS and ANI are the same columns regardless of direction,
19           # so all we need to assign is the IP address
20           if ($type =~ /^term/i) {
21             $cdr->dst_ip_addr( $cdr->get('ipaddr') );
22           } else {
23             $cdr->src_ip_addr( $cdr->get('ipaddr') );
24           }
25           # also strip the leading '1' or '+1' from src/dst
26           foreach (qw(src dst)) {
27             my $num = $cdr->get($_);
28             $num =~ s/^\+?1//;
29             $cdr->set($_, $num);
30           }
31         },
32     # StartTime
33     _cdr_date_parser_maker('startdate'),
34     # StopTime
35     _cdr_date_parser_maker('enddate'),
36     # CallDuration
37     sub { my($cdr, $duration) = @_;
38           $cdr->duration(sprintf('%.0f',$duration));
39         },
40     # BillDuration (granularized)
41     sub { my($cdr, $billsec) = @_;
42           $cdr->billsec(sprintf('%.0f',$billsec));
43         },
44     # CallMinimum, CallIncrement (used to granularize BillDuration)
45     '', '',
46     # BasePrice
47     '',
48     # CallPrice
49     'upstream_price',
50     # TransactionId (seems not to be meaningful to us)
51     '',
52     # CustomerIP
53     'ipaddr', # will go to src or dst addr, depending
54     # ANI
55     'src',
56     # ANIState
57     '', # would be really useful for classifying inter/intrastate calls, 
58         # except we don't use it
59     # DNIS
60     'dst',
61     # LRN (Local Routing Number of the destination)
62     '',
63     # DNISState, DNISLATA, DNISOCN
64     '', '', '',
65     # OrigTier, TermRateDeck
66     '', '', # these are upstream rate plans, but they're not numeric
67   ],
68 );
69
70 1;