grep { $_->part_svc->svcdb eq 'svc_phone' } $cust_pkg->cust_svc
) {
+ my $svc_phone = $cust_svc->svc_x;
foreach my $cdr (
- $cust_svc->get_cdrs_for_update(
+ $svc_phone->get_cdrs(
'disable_src' => $self->option('disable_src'),
'default_prefix' => $self->option('default_prefix'),
+ 'status' => '',
+ 'for_update' => 1,
) # $last_bill, $$sdate )
) {
if ( $DEBUG > 1 ) {
warn "rating call $to_or_from +$countrycode $number\n" if $DEBUG;
$pretty_destnum = "+$countrycode $number";
+ #asterisks here causes inserting the detail to barf, so:
+ $pretty_destnum =~ s/\*//g;
my $rate = qsearchs('rate', { 'ratenum' => $ratenum })
or die "ratenum $ratenum not found!";
# length($cdr->billsec) ? $cdr->billsec : $cdr->duration;
$seconds = $use_duration ? $cdr->duration : $cdr->billsec;
+ $seconds -= $rate_detail->conn_sec;
+ $seconds = 0 if $seconds < 0;
+
$seconds += $granularity - ( $seconds % $granularity )
if $seconds # don't granular-ize 0 billsec calls (bills them)
&& $granularity; # 0 is per call
$included_min{$regionnum} -= $minutes;
+ $charge = sprintf('%.2f', $rate_detail->conn_charge);
+
if ( $included_min{$regionnum} < 0 ) {
my $charge_min = 0 - $included_min{$regionnum}; #XXX should preserve
#(display?) this
$included_min{$regionnum} = 0;
- $charge = sprintf('%.2f', ( $rate_detail->min_charge * $charge_min )
- + 0.00000001 ); #so 1.005 rounds to 1.01
+ $charge += sprintf('%.2f', ($rate_detail->min_charge * $charge_min)
+ + 0.00000001 ); #so 1.005 rounds to 1.01
+ $charge = sprintf('%.2f', $charge);
$charges += $charge;
}