X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fdetail_format%2Fsum_duration_prefix.pm;h=3c33dc163fdddc67d0caefd80c6ae2300dd11dfb;hb=f4daf7e8c831fe126dc3fd1d6d0db5ee3b46d602;hp=19b6648f8dd061e6803d2f6f1c9e546568871fce;hpb=57fe641524a2e3057f577074b26ab75b24534bbc;p=freeside.git diff --git a/FS/FS/detail_format/sum_duration_prefix.pm b/FS/FS/detail_format/sum_duration_prefix.pm index 19b6648f8..3c33dc163 100644 --- a/FS/FS/detail_format/sum_duration_prefix.pm +++ b/FS/FS/detail_format/sum_duration_prefix.pm @@ -24,8 +24,12 @@ my $prefix_length = 6; 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; @@ -47,7 +51,10 @@ sub append { # "' 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; } } @@ -70,7 +77,7 @@ sub finish { $prefix, map({ $_->{count}, - (int($_->{duration}/60) . ' min'), + sprintf('%.01f min', $_->{duration}/60), } @subtotals ), $self->money_char . sprintf('%.02f',$total_amount), ); @@ -87,6 +94,7 @@ sub finish { 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 }