fix TeleAPI import (what kind of crack was Christopher smoking that he couldn't fix...
[freeside.git] / FS / FS / cdr / netsapiens.pm
1 package FS::cdr::netsapiens;
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'          => 'NetSapiens',
10   'weight'        => 160,
11   'header'        => 1,     #0 default, set to 1 to ignore the first line, or
12                             # to higher numbers to ignore that number of lines
13   'type'          => 'csv',
14   'sep_char'      => ',',   #for csv, defaults to ,
15   'disabled'      => 0,     #0 default, set to 1 to disable
16
17   'import_fields' => [
18
19     sub { my ($cdr, $direction) = @_;
20           if ($direction =~ /^t/) { # 'origination'
21             # leave src and dst as they are
22           } elsif ($direction =~ /^o/) {
23             my ($local, $remote) = ($cdr->src, $cdr->dst);
24             $cdr->set('dst', $local);
25             $cdr->set('src', $remote);
26           }
27         },
28     '', #Domain
29     '', #user
30     'src', #local party (src/dst, based on direction)
31     _cdr_date_parser_maker('startdate'),
32     _cdr_date_parser_maker('answerdate'),
33     sub { my ($cdr, $duration) = @_;
34           $cdr->set('duration', $duration);
35           $cdr->set('billsec',  $duration);
36           $cdr->set('enddate',  $duration + $cdr->answerdate)
37             if $cdr->answerdate;
38         },
39     'dst', #remote party
40     sub { my ($cdr, $dialednum) = @_;
41         $cdr->set('dst',$dialednum) if $dialednum =~ /^(\+?1)?8(8|([02-7])\3)/;
42         }, #dialed number
43     'uniqueid', #CallID (timestamp + '-' +  32 char hex string)
44     '',
45     '',
46     'disposition',
47   ],
48
49 );
50
51 1;