sub append {
my $self = shift;
my $prefixes = ($self->{prefixes} ||= {});
+ my $acctids = ($self->{acctids} ||= []);
foreach my $cdr (@_) {
- my $phonenum = $self->{inbound} ? $cdr->src : $cdr->dst;
+ my (undef, $phonenum) = $cdr->parse_number(
+ column => ( $self->{inbound} ? 'src' : 'dst' ),
+ );
+
$phonenum =~ /^(\d{$prefix_length})/;
my $prefix = $1 || 'other';
warn "$me appending ".$cdr->dst." to $prefix\n" if $DEBUG;
# "' in CDR #".$cdr->acctid."\n";
$subtotal->{count}++;
$subtotal->{duration} += $object->rated_seconds;
- $subtotal->{amount} += $object->rated_price;
+ $subtotal->{amount} += $object->rated_price
+ if $object->freesidestatus ne 'no-charge';
+
+ push @$acctids, $cdr->acctid;
}
}
$prefix,
map({
$_->{count},
- (int($_->{duration}/60) . ' min'),
+ sprintf('%.01f min', $_->{duration}/60),
} @subtotals ),
$self->money_char . sprintf('%.02f',$total_amount),
);
startdate => '', #could use the earliest startdate in the bunch?
regionname => '', #no, we're using prefix instead
detail => $self->csv->string,
+ acctid => $self->{acctids},
});
} #foreach $prefix
}