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