1 package FS::cdr::amcom;
4 use base qw( FS::cdr );
8 my ($tmp_mday, $tmp_mon, $tmp_year);
18 #listref of what to do with each field from the CDR, in order
21 sub { # 1. Field Type (must be "DCR", yes, "DCR")
22 my ($cdr, $field, $conf, $hashref) = @_;
23 $hashref->{skiprow} = 1 unless $field eq 'DCR';
25 '', # 2. BWGroupID (centrex group)
26 '', # 3. BWGroupNumber
27 'uniqueid', # 4. Record ID
28 'dcontext', # 5. Call Category (LOCAL, NATIONAL, FREECALL, MOBILE)
29 sub { # 6. Start Date (DDMMYYYY
30 my ($cdr, $date) = @_;
31 $date =~ /^(\d{2})(\d{2})(\d{4})$/
32 or die "unparseable date: $date";
33 ($tmp_mday, $tmp_mon, $tmp_year) = ($1, $2, $3);
35 sub { # 7. Start Time (HHMMSS)
36 my ($cdr, $time) = @_;
37 $time =~ /^(\d{2})(\d{2})(\d{2})$/
38 or die "unparseable time: $time";
39 my $dt = DateTime->new(
47 $cdr->set('startdate', $dt->epoch);
49 sub { # 8. Duration (seconds, 3 decimals)
50 my ($cdr, $seconds) = @_;
51 $cdr->set('duration', sprintf('%.0f', $seconds));
52 $cdr->set('billsec', sprintf('%.0f', $seconds));
54 'src', # 9. Calling Number
55 'dst', # 10. Called Number
56 'upstream_src_regionname', # 11. Calling Party Zone
57 'upstream_dst_regionname', # 12. Called Party Zone
58 'upstream_price', # 13. Call Cost
59 '', # 14. Call Cost 2 (seems to be the same?)
60 '', # 15. Service Provider ID
61 ('') x 4, # 16-20. Reserved fields