import torrus 1.0.9
[freeside.git] / FS / FS / cdr / troop.pm
1 package FS::cdr::troop;
2
3 use strict;
4 use base qw( FS::cdr );
5 use vars qw( %info  $tmp_mon $tmp_mday $tmp_year );
6 use Time::Local;
7 #use FS::cdr qw( _cdr_date_parser_maker _cdr_min_parser_maker );
8
9 %info = (
10   'name'          => 'Troop',
11   'weight'        => 220,
12   'header'        => 2,
13   'type'          => 'xls',
14
15   'import_fields' => [
16
17     # CDR FIELD / REQUIRED / Notes
18
19     # / No / CDR sequence number
20     sub {},
21
22     # WTN / Yes
23     'charged_party',
24
25     # Account Code / Yes / Account Code (security) and we need on invoice
26     'accountcode',
27
28     # DT / Yes / "DATE"   Excel
29     # XXX false laziness w/bell_west.pm
30     sub { my($cdr, $date) = @_;
31
32           my $datetime = DateTime::Format::Excel->parse_datetime( $date );
33           $tmp_mon  = $datetime->mon_0;
34           $tmp_mday = $datetime->mday;
35           $tmp_year = $datetime->year;
36         },
37
38     # Time / Yes / "TIME"  excel
39     sub { my($cdr, $time) = @_;
40           #my($sec, $min, $hour, $mday, $mon, $year)= localtime($cdr->startdate);
41
42           #$sec = $time * 86400;
43           my $sec = int( $time * 86400 + .5);
44
45           #$cdr->startdate( timelocal($3, $2, $1 ,$mday, $mon, $year) );
46           $cdr->startdate(
47             timelocal(0, 0, 0, $tmp_mday, $tmp_mon, $tmp_year) + $sec
48           );
49         },
50
51
52     # Dur. / Yes / Units = seconds
53     'billsec',
54
55     # OVS Type / Maybe / add "011" to international calls
56     # N = DOM LD / normal
57     # Z = INTL LD
58     # O = INTL LD
59     # others...?
60     sub { my($cdr, $ovs) = @_;
61           my $pre = ( $ovs =~ /^\s*[OZ]\s*$/i ) ? '011' : '1';
62           $cdr->dst( $pre. $cdr->dst ) unless $cdr->dst =~ /^$pre/;
63         },
64
65     # Number / YES
66     'src',
67
68     # City / No
69     'channel',
70
71     # Prov/State / No / We will use your Freeside rating and description name
72     sub { my($cdr, $state) = @_;
73           $cdr->channel( $cdr->channel. ", $state" )
74             if $state;
75         },
76
77     # Number / Yes
78     'dst',
79
80     # City / No
81     'dstchannel',
82
83     # Prov/State / No / We will use your Freeside rating and description name
84     sub { my($cdr, $state) = @_;
85           $cdr->dstchannel( $cdr->dstchannel. ", $state" )
86             if $state;
87         },
88
89     # OVS / Maybe 
90     # Would help to add "011" to international calls (if you are willing)
91     # (using ovs above)
92     sub { my($cdr, $ovs) = @_;
93           my @ignore = ( 'BELL', 'CANADA', 'UNITED STATES', );
94           $cdr->dstchannel( $cdr->dstchannel. ", $ovs" )
95             if $ovs && ! grep { $ovs =~ /^\s*$_\s*$/ } @ignore;
96         },
97
98     # CC Ind. / No / Does show if Calling card but should not be required
99     #'N' or 'E'
100     sub {},
101
102     # Call Charge / No / Bell billing info and is not required
103     'upstream_price',
104
105     # Account # / No / Bell billing info and is not required
106     sub {},
107
108     # Net Charge / No / Bell billing info and is not required
109     sub {},
110
111     # Surcharge / No / Taxes and is not required
112     sub {},
113
114     # GST / No / Taxes and is not required
115     sub {},
116
117     # PST / No / Taxes and is not required
118     sub {},
119
120     # HST / No / Taxes and is not required
121     sub {},
122     
123   ],
124
125 );
126
127 1;
128