9608513188fbf238055ebc7c3c010bf9cb461f20
[freeside.git] / FS / FS / cdr / bell_west.pm
1 package FS::cdr::bell_west;
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'          => 'Bell West',
11   'weight'        => 210,
12   'header'        => 1,     #0 default, set to 1 to ignore the first line
13   'type'          => 'xls', #csv (default), fixedlength or xls
14
15   'import_fields' => [
16
17     # CDR FIELD / REQUIRED / Notes
18
19     # CHG TYPE / No / Internal Code only (no need to import)
20     sub {},
21
22     # ACCOUNT # / No / Internal Number only (no need to import)
23     sub {},
24
25     # DATE / Yes / "DATE"   Excel date format MM/DD/YYYY
26     sub { my($cdr, $date) = @_;
27           $date =~ /^(\d{1,2})\/(\d{1,2})\/(\d\d(\d\d)?)$/
28             or die "unparsable date: $date"; #maybe we shouldn't die...
29           #$cdr->startdate( timelocal(0, 0, 0 ,$2, $1-1, $3) );
30           ($tmp_mday, $tmp_mon, $tmp_year) = ( $2, $1-1, $3 );
31         },
32
33     # CUST NO / Yes / "TIME"    "075959" Text based time
34     # Note: This is really the start time but Bell header says "Cust No" which
35     #       is wrong
36     sub { my($cdr, $time) = @_;
37           #my($sec, $min, $hour, $mday, $mon, $year)= localtime($cdr->startdate);
38           $time =~ /^(\d{1,2}):(\d{1,2}):(\d{1,2})$/
39             or die "unparsable time: $time"; #maybe we shouldn't die...
40           #$cdr->startdate( timelocal($3, $2, $1 ,$mday, $mon, $year) );
41           $cdr->startdate(
42             timelocal($3, $2, $1 ,$tmp_mday, $tmp_mon, $tmp_year)
43           );
44         },
45
46     # BTN / Yes / Main billing number but not DID or real number (I guess put in SRC field)
47     'src',
48
49     # ORIG CITY / No / We will use your Freeside rating and description name
50     'channel',
51
52     # TERM / YES / All calls should be billed, however all calls are missing "1+" and "011+" & DIR ASST = "411"
53     'dst',
54
55     # TERM CITY / No / We will use your Freeside rating and description name
56     'dstchannel',
57
58     # WTN / Yes / Bill to number (I guess put in "charged_party")
59     'charged_party',
60
61     # CODE / Yes / Account Code (security) and we need on invoice (suggestions ?)
62     'accountcode',
63
64     # PROV/COUNTRY / No / We will use your Freeside rating and description name
65     # (but use this to add "011" for "International" calls)
66     sub { my( $cdr, $prov ) = @_;
67           my $pre = ( $prov =~ /^\s*International\s*/i ) ? '011' : '1';
68           $cdr->dst( $pre. $cdr->dst ) unless $cdr->dst =~ /^$pre/;
69         },
70
71     # CALL TYPE / Possibly / Not sure if you need this to determine correct billing method ?
72     # DDD normal call (Direct Dial Dsomething? ="LD"?)
73     # TF  Toll Free
74     #     (toll free dst# should be sufficient to rate)
75     # DAT Directory AssisTance
76     #     (dst# 411 "area code" should be sufficient to rate)
77     # DNS (Another sort of directory assistance?... only one record with
78     #      "8195551212" in the dst#)
79     'dcontext', #probably don't need... map to cdr_type?  calltypenum?
80
81     # DURATION  Yes     Units = seconds
82     'billsec', #need to trim .00 ?
83
84     # AMOUNT CHARGED    No      Will use Freeside rating and description name
85     sub { my( $cdr, $amount) = @_;
86           $amount =~ s/^\$//;
87           $cdr->upstream_price( $amount );
88         },
89
90   ],
91
92 );
93
94 1;
95
96 __END__
97
98 CHG TYPE        (unused)
99 ACCOUNT #       (unused)
100
101 DATE            startdate (+ CUST NO)
102 CUST NO         (startdate time)
103                 - Start of call (UNIX-style integer timestamp)
104
105 BTN            *src - Caller*ID number / Source number
106 ORIG CITY       channel - Channel used
107 TERM #         *dst - Destination extension
108 TERM CITY       dstchannel - Destination channel if appropriate
109 WTN            *charged_party - Service number to be billed
110 CODE           *accountcode - CDR account number to use: account
111
112 PROV/COUNTRY    (used to prefix TERM # w/ 1 or 011)
113
114 CALL TYPE       dcontext - Destination context
115 DURATION       *billsec - Total time call is up, in seconds
116 AMOUNT CHARGED *upstream_price - Wholesale price from upstream
117