start adding package locations, RT#4499
[freeside.git] / eg / cdr_template.pm
1 package FS::cdr::cdr_template;
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'          => 'Example CDR format',
10   'weight'        => 500,
11   'header'        => 0,     #0 default, set to 1 to ignore the first line, or
12                             # to higher numbers to ignore that number of lines
13   'type'          => 'csv', #csv (default), fixedlength or xls
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     #place data directly in the specified field
21     'freeside_cdr_fieldname',
22
23     #subroutine reference
24     sub { my($cdr, $field_data) = @_; 
25           #do something to $field_data
26           $cdr->fieldname($field_data);
27         },
28
29     #premade subref factory for date+time parsing, understands dates like:
30     #  10/31/2007 08:57:24
31     #  2007-10-31 08:57:24.113000000
32     _cdr_date_parser_maker('startddate'), #for example
33     
34     #premade subref factory for decimal minute parsing
35     _cdr_min_parser_maker, #defaults to billsec and duration
36     _cdr_min_parser_maker('fieldname'), #one field
37     _cdr_min_parser_maker(['billsec', 'duration']), #listref for multiple fields
38
39   ],
40
41   #Parse::FixedLength field descriptions & lengths, for type=>'fixedlength' only
42   'fixedlength_format' => [qw(
43     Type:2:1:2
44     Sequence:4:3:6
45   )],
46
47 );
48
49 1;
50
51 __END__
52
53 list of freeside CDR fields, useful ones marked with *
54
55        acctid - primary key
56 *[1]   calldate - Call timestamp (SQL timestamp)
57        clid - Caller*ID with text
58 *      src - Caller*ID number / Source number
59 *      dst - Destination extension
60        dcontext - Destination context
61        channel - Channel used
62        dstchannel - Destination channel if appropriate
63        lastapp - Last application if appropriate
64        lastdata - Last application data
65 *      startdate - Start of call (UNIX-style integer timestamp)
66        answerdate - Answer time of call (UNIX-style integer timestamp)
67 *      enddate - End time of call (UNIX-style integer timestamp)
68 *      duration - Total time in system, in seconds
69 *      billsec - Total time call is up, in seconds
70 *[2]   disposition - What happened to the call: ANSWERED, NO ANSWER, BUSY
71        amaflags - What flags to use: BILL, IGNORE etc, specified on a per
72        channel basis like accountcode.
73 *[3]   accountcode - CDR account number to use: account
74        uniqueid - Unique channel identifier (Unitel/RSLCOM Event ID)
75        userfield - CDR user-defined field
76        cdr_type - CDR type - see FS::cdr_type (Usage = 1, S&E = 7, OC&C = 8)
77 *[4]   charged_party - Service number to be billed
78        upstream_currency - Wholesale currency from upstream
79 *[5]   upstream_price - Wholesale price from upstream
80        upstream_rateplanid - Upstream rate plan ID
81        rated_price - Rated (or re-rated) price
82        distance - km (need units field?)
83        islocal - Local - 1, Non Local = 0
84 *[6]   calltypenum - Type of call - see FS::cdr_calltype
85        description - Description (cdr_type 7&8 only) (used for
86        cust_bill_pkg.itemdesc)
87        quantity - Number of items (cdr_type 7&8 only)
88        carrierid - Upstream Carrier ID (see FS::cdr_carrier)
89        upstream_rateid - Upstream Rate ID
90        svcnum - Link to customer service (see FS::cust_svc)
91        freesidestatus - NULL, done (or something)
92
93 [1] Auto-populated from startdate if not present
94 [2] Package options available to ignore calls without a specific disposition
95 [3] When using 'cdr-charged_party-accountcode' config
96 [4] Auto-populated from src (normal calls) or dst (toll free calls) if not present
97 [5] When using 'upstream_simple' rating method.
98 [6] Set to usage class classnum when using pre-rated CDRs and usage class-based
99     taxation (local/intrastate/interstate/international)