X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fdetail_format%2Fsum_duration_prefix.pm;h=cd7bbe3cc9d41c93c22617137ae6302fc85b0a3b;hb=c6782ab85ea83e0c78d85b8975985aac9d467f9d;hp=0db62b2b16020abeef8978b590bc8596881b698c;hpb=0e256e7b9dcc00dedacf499b92bd1c945248a3b9;p=freeside.git diff --git a/FS/FS/detail_format/sum_duration_prefix.pm b/FS/FS/detail_format/sum_duration_prefix.pm index 0db62b2b1..cd7bbe3cc 100644 --- a/FS/FS/detail_format/sum_duration_prefix.pm +++ b/FS/FS/detail_format/sum_duration_prefix.pm @@ -2,7 +2,7 @@ package FS::detail_format::sum_duration_prefix; use strict; use vars qw( $DEBUG ); -use parent qw(FS::detail_format); +use base qw(FS::detail_format); use List::Util qw(sum); $DEBUG = 0; @@ -25,7 +25,10 @@ sub append { my $self = shift; my $prefixes = ($self->{prefixes} ||= {}); 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; @@ -41,11 +44,14 @@ sub append { # but interstate-ness should be symmetric, yes? if A places an # interstate call to B, then B receives an interstate call from A. my $subtotal = $prefixes->{$prefix}{$cdr->rated_ratename} - or die "unknown rated_ratename '" .$cdr->rated_ratename. - "' in CDR #".$cdr->acctid."\n"; + or next; + # silently skip calls that are neither interstate nor intrastate + #or die "unknown rated_ratename '" .$cdr->rated_ratename. + # "' 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'; } } @@ -68,7 +74,7 @@ sub finish { $prefix, map({ $_->{count}, - (int($_->{duration}/60) . ' min'), + sprintf('%.01f min', $_->{duration}/60), } @subtotals ), $self->money_char . sprintf('%.02f',$total_amount), );