[freeside-commits] freeside/FS/FS/part_pkg voip_tiered.pm, 1.1.2.4, 1.1.2.5 voip_cdr.pm, 1.123.2.8, 1.123.2.9
Mark Wells
mark at wavetail.420.am
Tue Dec 20 18:57:09 PST 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/part_pkg
In directory wavetail.420.am:/tmp/cvs-serv19053/FS/FS/part_pkg
Modified Files:
Tag: FREESIDE_2_3_BRANCH
voip_tiered.pm voip_cdr.pm
Log Message:
separate CDR summary by rate table, #15535
Index: voip_cdr.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/voip_cdr.pm,v
retrieving revision 1.123.2.8
retrieving revision 1.123.2.9
diff -u -w -d -r1.123.2.8 -r1.123.2.9
--- voip_cdr.pm 19 Dec 2011 22:51:32 -0000 1.123.2.8
+++ voip_cdr.pm 21 Dec 2011 02:57:07 -0000 1.123.2.9
@@ -427,6 +427,7 @@
my $seconds = '';
my $weektime = '';
my $regionname = '';
+ my $ratename = '';
my $classnum = '';
my $countrycode;
my $number;
@@ -514,8 +515,9 @@
? $cust_pkg->part_pkg->option('accountcode_tollfree_ratenum')
: '';
- my $intrastate_ratenum = $cust_pkg->part_pkg->option('accountcode_tollfree_ratenum');
+ my $intrastate_ratenum = $cust_pkg->part_pkg->option('intrastate_ratenum');
if ( $intrastate_ratenum && !$cdr->is_tollfree ) {
+ $ratename = 'Interstate'; #until proven otherwise
# this is relatively easy only because:
# -assume all numbers are valid NANP numbers NOT in a fully-qualified format
# -disregard toll-free
@@ -532,9 +534,12 @@
$srcprefix = qsearchs('rate_prefix', { 'countrycode' => '1',
'npa' => $1,
}) || '';
- $eff_ratenum = $intrastate_ratenum if ($srcprefix && $dstprefix
+ if ($srcprefix && $dstprefix
&& $srcprefix->state && $dstprefix->state
- && $srcprefix->state eq $dstprefix->state);
+ && $srcprefix->state eq $dstprefix->state) {
+ $eff_ratenum = $intrastate_ratenum;
+ $ratename = 'Intrastate'; # XXX possibly just use the ratename?
+ }
}
$eff_ratenum ||= $ratenum;
@@ -787,7 +792,6 @@
}
} #if(there is a rate_detail)
-
#if ( $charge > 0 ) {
# generate a detail record for every call; filter out $charge = 0
# later.
@@ -821,6 +825,8 @@
regionname => $regionname,
};
}
+ $call_details->{'ratename'} = $ratename;
+
push @invoice_details_sort, [ $call_details, $cdr->calldate_unix ];
#} $charge > 0
@@ -998,9 +1004,12 @@
my $self = shift;
my $svc_x = shift;
my $invoice_details = shift || [];
- my $count = scalar(@$invoice_details);
- return () if !$count;
- my $sum_detail = {
+ return () if !@$invoice_details;
+ my $details_by_rate = {};
+ # combine the entire set of CDRs
+ foreach ( @$invoice_details ) {
+ my $d = $_->[0];
+ my $sum = $details_by_rate->{ $d->{ratename} } ||= {
amount => 0,
format => 'C',
classnum => '', #XXX
@@ -1008,25 +1017,32 @@
phonenum => $svc_x->phonenum,
accountcode => '', #XXX
startdate => '', #XXX
- regionnam => '',
+ regionname => '',
+ count => 0,
};
- # combine the entire set of CDRs
- foreach ( @$invoice_details ) {
- $sum_detail->{amount} += $_->[0]{amount};
- $sum_detail->{duration} += $_->[0]{duration};
+ $sum->{amount} += $d->{amount};
+ $sum->{duration} += $d->{duration};
+ $sum->{count}++;
}
+ my @details;
+ foreach my $ratename ( sort keys(%$details_by_rate) ) {
+ my $sum = $details_by_rate->{$ratename};
+ next if $sum->{count} == 0;
my $total_cdr = FS::cdr->new({
- 'billsec' => $sum_detail->{duration},
- 'src' => $sum_detail->{phonenum},
+ 'billsec' => $sum->{duration},
+ 'src' => $sum->{phonenum},
});
- $sum_detail->{detail} = $total_cdr->downstream_csv(
+ $sum->{detail} = $total_cdr->downstream_csv(
format => $self->option('output_format'),
- seconds => $sum_detail->{duration},
- charge => sprintf('%.2f',$sum_detail->{amount}),
- phonenum => $sum_detail->{phonenum},
- count => $count,
+ seconds => $sum->{duration},
+ charge => sprintf('%.2f',$sum->{amount}),
+ ratename => $ratename,
+ phonenum => $sum->{phonenum},
+ count => $sum->{count},
);
- return $sum_detail;
+ push @details, $sum;
+ }
+ @details;
}
# and whether cust_bill should show a detail line for the service label
Index: voip_tiered.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/voip_tiered.pm,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -w -d -r1.1.2.4 -r1.1.2.5
--- voip_tiered.pm 19 Dec 2011 22:51:32 -0000 1.1.2.4
+++ voip_tiered.pm 21 Dec 2011 02:57:07 -0000 1.1.2.5
@@ -98,6 +98,7 @@
my %options = (
'disable_src' => $self->option('disable_src'),
'default_prefix' => $self->option('default_prefix'),
+ 'cdrtypenum' => $self->option('use_cdrtypenum'),
'status' => '',
'for_update' => 1,
); # $last_bill, $$sdate )
More information about the freeside-commits
mailing list