1 package FS::cdr::telstra;
4 use vars qw( @ISA %info $tmp_mon $tmp_mday $tmp_year );
8 # Telstra LinxOnline eBill format
21 'name' => 'Telstra LinxOnline',
24 'type' => 'fixedlength',
25 # Wholesale Usage Information Record format
26 'fixedlength_format' => [ qw(
27 InterfaceRecordType:3:1:3
28 ServiceProviderCode:3:4:6
30 ProductBillingIdentifier:8:31:38
31 BillingElementCode:8:39:46
32 InvoiceArrangementID:10:47:56
33 ServiceArrangementID:10:57:66
34 FullNationalNumber:29:67:95
35 OriginatingNumber:25:96:120
36 DestinationNumber:25:121:145
37 OriginatingDateTime:18:146:163
39 UnitQuantityDuration:27:176:202
40 CallTypeCode:3:203:205
43 DistanceRangeCode:4:222:225
44 ClosedUserGroupID:5:226:230
45 ReversalChargeIndicator:1:231:231
46 1900CallDescription:30:232:261
51 sub { # InterfaceRecordType: skip everything except usage records
52 my ($cdr, $field, $conf, $param) = @_;
53 $param->{skiprow} = 1 if !exists($cdr_type_of{$field});
56 skip(1), # service provider code
57 'uniqueid', # event file instance, sequence number, bill file ID
58 # together these form a unique record ID
59 skip(4), # product billing identifier, billing element, invoice
60 # arrangement, service arrangement
61 parse_phonenum('charged_party'),
62 # "This is the billable number and represents the
63 # service number transferred to the Service Provider as a
64 # result of Product Redirection."
65 parse_phonenum('src'), # OriginatingNumber
66 parse_phonenum('dst'), # DestinationNumber
67 sub { # OriginatingDate and OriginatingTime, two fields in the spec
68 my ($cdr, $date) = @_;
69 $date =~ /^(\d{4})(\d{2})(\d{2})\s*(\d{2}):(\d{2}):(\d{2})$/
70 or die "unparseable date: $date";
71 $cdr->startdate(timelocal($6, $5, $4, $3, $2-1, $1));
74 sub { # UnitOfMeasure, Quantity, CallDuration, three fields
75 my ($cdr, $field, $conf, $param) = @_;
76 my ($unit, $qty, $dur) = ($field =~ /^(.{5})(.{13})(.{9})$/);
77 $qty = $qty / 100000; # five decimal places
78 if( $unit =~ /^SEC/ ) {
82 elsif( $unit =~ /^6SEC/ ) {
83 $cdr->billsec($qty*6);
84 $cdr->duration($qty*6);
86 elsif( $unit =~ /^MIN/ ) {
87 $cdr->billsec($qty*60);
88 $cdr->duration($qty*60);
91 # For now, ignore units that don't convert to time
92 $param->{skiprow} = 1;
95 skip(2), # CallTypeCode, RecordType
97 my ($cdr, $price) = @_;
98 $cdr->upstream_price($price / 10000000);
111 my ($cdr, $data) = @_;
113 my ($type) = ($data =~ /^(.)/); #network service type
115 # domestic number: area code length, then 10-digit number (maybe
116 # padded with spaces), then extension info if it's the FNN/billable
118 ($phonenum) = ($data =~ /^.\d(.{0,10})/);
119 $phonenum =~ s/\s//g;
121 elsif ($type eq 'O') {
122 # international number: country code length, then 15-digit number
123 ($phonenum) = ($data =~ /^.\d(.{0,15})/);
126 # other, take 18 characters
127 ($phonenum) = ($data =~ /^.(.{0,18})/);
129 $cdr->setfield($field, $phonenum);