RT# 82992 - Added new cdr import format ThinQ
[freeside.git] / FS / FS / cdr / thinq.pm
1 package FS::cdr::thinq;
2
3 use strict;
4 use vars qw( @ISA %info $tmp_mon $tmp_mday $tmp_year );
5 use base qw( FS::cdr );
6 use Time::Local;
7 use Date::Parse;
8
9 @ISA = qw(FS::cdr);
10
11 %info = (
12   'name'          => 'ThinQ',
13   'weight'        => 13,
14   'type'          => 'csv',
15   'header'        => 1,
16   'disabled'      => 0,     #0 default, set to 1 to disable
17
18
19   'import_fields' => [
20
21     # Date (YYYY-MM-DD)
22     sub { my($cdr, $date) = @_;
23           $date =~ /^(\d\d(\d\d)?)\-(\d{1,2})\-(\d{1,2})$/
24             or die "unparsable date: $date"; #maybe we shouldn't die...
25           ($tmp_mday, $tmp_mon, $tmp_year) = ( $4, $3-1, $1 );
26         },
27
28     # Time (HH:MM:SS )
29     sub { my($cdr, $time) = @_;
30           $time =~ /^(\d{1,2}):(\d{1,2}):(\d{1,2})$/
31             or die "unparsable time: $time"; #maybe we shouldn't die...
32           $cdr->startdate(
33             timelocal($3, $2, $1 ,$tmp_mday, $tmp_mon, $tmp_year)
34           );
35         },
36
37     'carrierid',         # carrier_id
38     'src',               # from_ani
39      skip(5),            # from_lrn
40                                      # from_lata
41                                      # from_ocn
42                                      # from_state
43                                      # from_rc
44     'dst',               # to_did
45     'channel',           # thing_tier
46     'userfield',         # callid
47     'accountcode',       # account_id
48      skip(2),            # tf_profile
49                                      # dest_type
50     'dst_ip_addr',       # dest
51      skip(1),              # rate
52     'billsec',           # billsec
53      skip(1),              #total_charge
54   ],  ## end import
55
56 );      ## end info
57
58 sub skip { map { undef } (1..$_[0]) }
59
60 1;
61
62 __END__