fix TeleAPI import (what kind of crack was Christopher smoking that he couldn't fix...
[freeside.git] / FS / FS / cdr / troop2.pm
1 package FS::cdr::troop2;
2
3 use strict;
4 use base qw( FS::cdr );
5 use vars qw( %info $tmp_mon $tmp_mday $tmp_year $tmp_src_city $tmp_dst_city );
6 use Time::Local;
7 ##use FS::cdr qw( _cdr_date_parser_maker _cdr_min_parser_maker );
8
9 use Data::Dumper;
10
11 %info = (
12   'name' => 'Troop',
13   'weight' => 219,
14   'header' => 1,
15   'type'   => 'xls',
16
17   'import_fields' => [
18
19     'userfield', #account_num  (userfield?)
20
21     # XXX false laziness w/bell_west.pm
22     #call_date
23     sub { my($cdr, $date) = @_;
24
25           my $datetime = DateTime::Format::Excel->parse_datetime( $date );
26           $tmp_mon  = $datetime->mon_0;
27           $tmp_mday = $datetime->mday;
28           $tmp_year = $datetime->year;
29         },
30
31     #call_time
32     sub { my($cdr, $time) = @_;
33           #my($sec, $min, $hour, $mday, $mon, $year)= localtime($cdr->startdate);
34
35           #$sec = $time * 86400;
36           my $sec = int( $time * 86400 + .5);
37
38           #$cdr->startdate( timelocal($3, $2, $1 ,$mday, $mon, $year) );
39           $cdr->startdate(
40             timelocal(0, 0, 0, $tmp_mday, $tmp_mon, $tmp_year) + $sec
41           );
42         },
43
44     'src', #orig_tn
45     'dst', #term_tn
46
47      #call_dur
48     sub { my($cdr, $duration) = @_;
49           $cdr->duration($duration);
50           $cdr->billsec($duration);
51         },
52
53     'clid', #auth_code_ani (clid?)
54
55     'accountcode', #account_code
56
57     #ovs_type
58     # OVS Type / Maybe / add "011" to international calls
59     # N = DOM LD / normal
60     # Z = INTL LD
61     # O = INTL LD
62     # others...?
63     sub { my($cdr, $ovs) = @_;
64           my $pre = ( $ovs =~ /^\s*[OZ]\s*$/i ) ? '011' : '1';
65           $cdr->dst( $pre. $cdr->dst ) unless $cdr->dst =~ /^$pre/;
66         },
67
68     #orig_city
69     sub { (my $cdr, $tmp_src_city) = @_; },
70
71     #orig_prov_state
72     sub { my($cdr, $state) = @_;
73           $cdr->upstream_src_regionname("$tmp_src_city, $state");
74         },
75
76     #term_city
77     sub { (my $cdr, $tmp_dst_city) = @_; },
78
79     #term_prov_state
80     sub { my($cdr, $state) = @_;
81           $cdr->upstream_dst_regionname("$tmp_dst_city, $state");
82         },
83
84     #term_ovs
85     '', #CANADA / UNITED STATES / BELL.  huh.  country or terminating provider?
86
87     '', #cc_ind (what's this?)
88
89     'upstream_price', #call_charge
90
91     #important?
92     '', #creation_date
93     '', #creation_time
94
95     #additional upstream pricing details we don't need?
96     '', #net_charge
97     '', #surcharge
98     '', #gst
99     '', #pst
100     '', #hst
101
102   ],
103
104 );
105
106 1;