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 'accountcode',# 2. BWGroupID (centrex group)
26 sub { # 3. BWGroupNumber
27 my ($cdr, $field) = @_; #, $conf, $hashref) = @_;
28 $cdr->charged_party($field)
29 if $cdr->accountcode eq '' && $field =~ /^(1800|1300)/;
31 'uniqueid', # 4. Record ID
32 'dcontext', # 5. Call Category (LOCAL, NATIONAL, FREECALL, MOBILE)
33 sub { # 6. Start Date (DDMMYYYY
34 my ($cdr, $date) = @_;
35 $date =~ /^(\d{2})(\d{2})(\d{4})$/
36 or die "unparseable date: $date";
37 ($tmp_mday, $tmp_mon, $tmp_year) = ($1, $2, $3);
39 sub { # 7. Start Time (HHMMSS)
40 my ($cdr, $time) = @_;
41 $time =~ /^(\d{2})(\d{2})(\d{2})$/
42 or die "unparseable time: $time";
43 my $dt = DateTime->new(
52 $cdr->set('startdate', $dt->epoch);
54 sub { # 8. Duration (seconds, 3 decimals)
55 my ($cdr, $seconds) = @_;
56 $cdr->set('duration', sprintf('%.0f', $seconds));
57 $cdr->set('billsec', sprintf('%.0f', $seconds));
59 'src', # 9. Calling Number
60 'dst', # 10. Called Number
61 'upstream_src_regionname', # 11. Calling Party Zone
62 'upstream_dst_regionname', # 12. Called Party Zone
63 'upstream_price', # 13. Call Cost
64 '', # 14. Call Cost 2 (seems to be the same?)
65 '', # 15. Service Provider ID
66 ('') x 4, # 16-20. Reserved fields