559aa2859be70ba234abddf6d678e68ada1056ff
[freeside.git] / FS / FS / cdr / broadsoft.pm
1 package FS::cdr::broadsoft;
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'          => 'Broadsoft',
10   'weight'        => 500,
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   #listref of what to do with each field from the CDR, in order
18   'import_fields' => [
19     
20     skip(2),
21     sub { my($cdr, $data, $conf, $param) = @_;
22           $param->{skiprow} = 1 if lc($data) ne 'normal';
23           '' },                                   #  3: type
24             
25     skip(2),
26     dcontext,                                     #  6: direction
27     trim('src'),                                  #  7: callingNumber
28     skip(1),
29     trim('dst'),                                  #  9: calledNumber
30
31     _cdr_date_parser_maker('startdate'),          # 10: startTime
32     skip(1),
33     sub { my($cdr, $data) = @_;
34           $cdr->disposition(
35             lc($data) eq 'yes' ? 
36             'ANSWERED' : 'NO ANSWER') },          # 12: answerIndicator
37     _cdr_date_parser_maker('answerdate'),         # 13: answerTime
38     _cdr_date_parser_maker('enddate'),            # 14: releaseTime
39     skip(17),
40     accountcode,                                  # 32: group
41   ],
42
43 );
44
45 sub trim {
46   my $fieldname = shift;
47   return sub {
48     my($cdr, $data) = @_;
49     $data =~ s/^\+1//;
50     $cdr->$fieldname($data);
51     ''
52   }
53 }
54
55 sub skip {
56   map { undef } (1..$_[0]);
57 }
58
59 1;
60
61 __END__
62
63 list of freeside CDR fields, useful ones marked with *
64
65            acctid - primary key
66     *[1]   calldate - Call timestamp (SQL timestamp)
67            clid - Caller*ID with text
68 7   *      src - Caller*ID number / Source number
69 9   *      dst - Destination extension
70            dcontext - Destination context
71            channel - Channel used
72            dstchannel - Destination channel if appropriate
73            lastapp - Last application if appropriate
74            lastdata - Last application data
75 10  *      startdate - Start of call (UNIX-style integer timestamp)
76 13         answerdate - Answer time of call (UNIX-style integer timestamp)
77 14  *      enddate - End time of call (UNIX-style integer timestamp)
78     *      duration - Total time in system, in seconds
79     *      billsec - Total time call is up, in seconds
80 12  *[2]   disposition - What happened to the call: ANSWERED, NO ANSWER, BUSY
81            amaflags - What flags to use: BILL, IGNORE etc, specified on a per
82            channel basis like accountcode.
83 4   *[3]   accountcode - CDR account number to use: account
84            uniqueid - Unique channel identifier
85            userfield - CDR user-defined field
86            cdr_type - CDR type - see FS::cdr_type (Usage = 1, S&E = 7, OC&C = 8)
87     *[4]   charged_party - Service number to be billed
88            upstream_currency - Wholesale currency from upstream
89     *[5]   upstream_price - Wholesale price from upstream
90            upstream_rateplanid - Upstream rate plan ID
91            rated_price - Rated (or re-rated) price
92            distance - km (need units field?)
93            islocal - Local - 1, Non Local = 0
94     *[6]   calltypenum - Type of call - see FS::cdr_calltype
95            description - Description (cdr_type 7&8 only) (used for
96            cust_bill_pkg.itemdesc)
97            quantity - Number of items (cdr_type 7&8 only)
98            carrierid - Upstream Carrier ID (see FS::cdr_carrier)
99            upstream_rateid - Upstream Rate ID
100            svcnum - Link to customer service (see FS::cust_svc)
101            freesidestatus - NULL, done (or something)
102
103 [1] Auto-populated from startdate if not present
104 [2] Package options available to ignore calls without a specific disposition
105 [3] When using 'cdr-charged_party-accountcode' config
106 [4] Auto-populated from src (normal calls) or dst (toll free calls) if not present
107 [5] When using 'upstream_simple' rating method.
108 [6] Set to usage class classnum when using pre-rated CDRs and usage class-based
109     taxation (local/intrastate/interstate/international)