backup the schema for tables we don't need the data from. RT#85959
[freeside.git] / FS / FS / cdr / u4.pm
1 package FS::cdr::u4;
2
3 use strict;
4 use vars qw(@ISA %info);
5 use FS::cdr qw(_cdr_date_parser_maker);
6
7 @ISA = qw(FS::cdr);
8
9 # About the ANI/DNIS/*Number columns:
10 # For inbound calls, ANI appears to be the true source number.
11 # Usually ANI = TermNumber in that case.  (Case 1a.)
12 # In a few inbound CDRs, ANI = OrigNumber, the BillToNumber is also 
13 # the DialedNumber and DNIS (and always an 800 number), and the TermNumber 
14 # is a different number.  (Case 2; rare.)
15 #
16 # For outbound calls, DNIS is always empty.  The TermNumber appears to
17 # be the true destination.  The DialedNumber may be empty (Case 1b), or
18 # equal the TermNumber (Case 3), or be a different number (Case 4; this 
19 # probably shows routing to a different destination).
20 #
21 # How we are handling them:
22 # Case 1a (inbound): src = ANI, dst = BillToNumber
23 # Case 1b (outbound): src = BillToNumber, dst = ANI
24 # Case 2: src = ANI, dst = DialedNumber, dst_term = TermNumber
25 # Case 3: src = BillToNumber, dst = DialedNumber
26 # Case 4: src = BillToNumber, dst = DialedNumber, dst_term = TermNumber
27
28 %info = (
29   'name'          => 'U4',
30   'weight'        => 490,
31   'type'          => 'fixedlength',
32   'fixedlength_format' => [qw(
33     CDRType:3:1:3
34     MasterAccountID:12:4:15
35     SubAccountID:12:16:27
36     BillToNumber:18:28:45
37     AccountCode:12:46:57
38     CallDateStartTime:14:58:71
39     TimeOfDay:1:72:72
40     CalculatedSeconds:12:73:84
41     City:30:85:114
42     State:2:115:116
43     Country:40:117:156
44     Charges:21:157:177
45     CallDirection:1:178:178
46     CallIndicator:1:179:179
47     ReportIndicator:1:180:180
48     ANI:10:181:190
49     DNIS:10:191:200
50     PIN:16:201:216
51     OrigNumber:10:217:226
52     TermNumber:10:227:236
53     DialedNumber:18:237:254
54     DisplayNumber:18:255:272
55     RecordSource:1:273:273
56     LECInfoDigits:2:274:275
57     OrigNPA:4:276:279
58     OrigNXX:5:280:284
59     OrigLATA:3:285:287
60     OrigZone:1:288:288
61     OrigCircuit:12:289:300
62     OrigTrunkGroupCLLI:12:301:312
63     TermNPA:4:313:316
64     TermNXX:5:317:321
65     TermLATA:3:322:324
66     TermZone:1:325:325
67     TermCircuit:12:326:337
68     TermTrunkGroupCLLI:12:338:349
69     TermOCN:5:350:354
70   )],
71   # at least that's how they're defined in the spec we have.
72   # the real CDRs have several differences.
73   'import_fields' => [
74     '',               #CDRType (for now always 'V')
75     '',               #MasterAccountID
76     '',               #SubAccountID
77     'charged_party',  #BillToNumber
78     'accountcode',    #AccountCode
79     _cdr_date_parser_maker('startdate'),
80                       #CallDateTime
81     '',               #TimeOfDay (always 'S')
82     sub {             #CalculatedSeconds
83       my($cdr, $sec) = @_;
84       $cdr->duration($sec);
85       $cdr->billsec($sec);
86     },
87     '',               #City
88     '',               #State
89     '',               #Country
90     'upstream_price', #Charges
91     sub {             #CallDirection
92       my ($cdr, $dir) = @_;
93       $cdr->set('direction', $dir);
94       if ( $dir eq 'O' ) {
95         $cdr->set('src', $cdr->charged_party);
96       } elsif ( $dir eq 'I' ) {
97         $cdr->set('dst', $cdr->charged_party);
98       }
99     },
100     '',               #CallIndicator  #calltype?
101     '',               #ReportIndicator
102     sub {             #ANI
103       # For inbound calls, this is the source.
104       # For outbound calls it's sometimes the destination but TermNumber 
105       # is more reliable.
106       my ($cdr, $number) = @_;
107       if ( $cdr->direction eq 'I' ) {
108         $cdr->set('src', $number);
109       }
110     },
111     '',               #DNIS
112     '',               #PIN
113     '',               #OrigNumber
114     sub {             #TermNumber
115       # For outbound calls, this is the terminal destination (after call 
116       # routing).  It's sometimes also the dialed destination (Case 1b and 3).
117       my ($cdr, $number) = @_;
118       if ( $cdr->direction eq 'O' ) {
119         $cdr->set('dst_term', $number);
120         $cdr->set('dst', $number); # change this later if Case 4
121       }
122     },
123     sub {             #DialedNumber
124       my ($cdr, $number) = @_;
125       # For outbound calls, this is the destination before any call routing,
126       # and should be used for billing.  Except when it's null; then use 
127       # the TermNumber.
128       if ( $cdr->direction eq 'O' and $number =~ /\d/ ) {
129         # Case 4
130         $cdr->set('dst', $number);
131       }
132     },
133
134     '',               #DisplayNumber
135     '',               #RecordSource
136     '',               #LECInfoDigits
137     ('') x 13,
138   ],
139 );
140
141 # Case 1a (inbound): src = ANI, dst = BillToNumber
142 # Case 1b (outbound): src = BillToNumber, dst = TermNumber
143 # Case 2: src = ANI, dst = DialedNumber, dst_term = TermNumber
144 # Case 3: src = BillToNumber, dst = TermNumber
145 # Case 4: src = BillToNumber, dst = DialedNumber, dst_term = TermNumber
146
147 1;