enable CardFortress in test database, #71513
[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     #  Mon Dec 15 11:38:34 2003
33     _cdr_date_parser_maker('startddate'), #for example
34     
35     #premade subref factory for decimal minute parsing
36     _cdr_min_parser_maker, #defaults to billsec and duration
37     _cdr_min_parser_maker('fieldname'), #one field
38     _cdr_min_parser_maker(['billsec', 'duration']), #listref for multiple fields
39
40   ],
41
42   #Parse::FixedLength field descriptions & lengths, for type=>'fixedlength' only
43   'fixedlength_format' => [qw(
44     Type:2:1:2
45     Sequence:4:3:6
46   )],
47
48 );
49
50 1;
51
52 __END__
53
54 list of freeside CDR fields, useful ones marked with *
55
56        acctid - primary key
57 *[1]   calldate - Call timestamp (SQL timestamp)
58        clid - Caller*ID with text
59 *      src - Caller*ID number / Source number
60 *      dst - Destination extension
61        dcontext - Destination context
62        channel - Channel used
63        dstchannel - Destination channel if appropriate
64        lastapp - Last application if appropriate
65        lastdata - Last application data
66 *      startdate - Start of call (UNIX-style integer timestamp)
67 *      answerdate - Answer time of call (UNIX-style integer timestamp)
68 *      enddate - End time of call (UNIX-style integer timestamp)
69 *[2]   duration - Total time in system, in seconds
70 *[3]   billsec - Total time call is up, in seconds
71 *[4]   disposition - What happened to the call: ANSWERED, NO ANSWER, BUSY
72        amaflags - What flags to use: BILL, IGNORE etc, specified on a per
73        channel basis like accountcode.
74 *[5]   accountcode - CDR account number to use: account
75        uniqueid - Unique channel identifier
76        userfield - CDR user-defined field
77        cdr_type - CDR type - see FS::cdr_type (Usage = 1, S&E = 7, OC&C = 8)
78 *[6]   charged_party - Service number to be billed
79        upstream_currency - Wholesale currency from upstream
80 *[7]   upstream_price - Wholesale price from upstream
81        upstream_rateplanid - Upstream rate plan ID
82        rated_price - Rated (or re-rated) price
83        distance - km (need units field?)
84        islocal - Local - 1, Non Local = 0
85 *[8]   calltypenum - Type of call - see FS::cdr_calltype
86        description - Description (cdr_type 7&8 only) (used for
87        cust_bill_pkg.itemdesc)
88        quantity - Number of items (cdr_type 7&8 only)
89 *[9]   carrierid - Upstream Carrier ID (see FS::cdr_carrier)
90        upstream_rateid - Upstream Rate ID
91        svcnum - Link to customer service (see FS::cust_svc)
92        freesidestatus - NULL, done (or something)
93
94 [1] Auto-populated from startdate if not present
95 [2] Auto-populated to enddate - startdate on insert if not specified
96 [3] Auto-populated to enddate - answerdate on insert if not specified
97 [4] Package options available to ignore calls without a specific disposition
98 [5] When using 'cdr-charged_party-accountcode' config
99 [6] Auto-populated from src (normal calls) or dst (toll free calls) if not present
100 [7] When using 'upstream_simple' rating method.
101 [8] Set to usage class classnum when using pre-rated CDRs and usage class-based
102     taxation (local/intrastate/interstate/international)
103 [9] If doing settlement charging