'shortname' => 'VoIP/telco CDR rating (standard)',
'inherit_fields' => [ 'global_Mixin' ],
'fields' => {
+ 'suspend_bill' => { 'name' => 'Continue recurring billing while suspended',
+ 'type' => 'checkbox',
+ },
#false laziness w/flat.pm
'recur_temporality' => { 'name' => 'Charge recurring fee for period',
'type' => 'select',
'select_key' => 'ratenum',
'select_label' => 'ratename',
},
+
+ 'intrastate_ratenum' => { 'name' => 'Optional alternate intrastate rate plan',
+ 'type' => 'select',
+ 'select_table' => 'rate',
+ 'select_key' => 'ratenum',
+ 'select_label' => 'ratename',
+ 'disable_empty' => 0,
+ 'empty_label' => '',
+ },
'min_included' => { 'name' => 'Minutes included when using the "single price per minute" rating method or when using the "prefix" rating method ("region group" billing)',
},
recur_method cutoff_day
add_full_period
cdr_svc_method
- rating_method ratenum min_charge min_included
- sec_granularity
+ rating_method ratenum intrastate_ratenum
+ min_charge min_included
+ sec_granularity
ignore_unrateable
default_prefix
disable_src
411_rewrite
output_format usage_mandate summarize_usage usage_section
bill_every_call bill_inactive_svcs
- count_available_phones
+ count_available_phones suspend_bill
)
],
'weight' => 40,
my $last_bill = $cust_pkg->get('last_bill'); #->last_bill falls back to setup
return 0
- if $self->option('recur_temporality', 1) eq 'preceding'
+ if $self->recur_temporality eq 'preceding'
&& ( $last_bill eq '' || $last_bill == 0 );
my $ratenum = $cust_pkg->part_pkg->option('ratenum');
my $eff_ratenum = $cdr->is_tollfree('accountcode')
? $cust_pkg->part_pkg->option('accountcode_tollfree_ratenum')
: '';
+
+ my $intrastate_ratenum = $cust_pkg->part_pkg->option('accountcode_tollfree_ratenum');
+ if ( $intrastate_ratenum && !$cdr->is_tollfree ) {
+ # this is relatively easy only because:
+ # -assume all numbers are valid NANP numbers NOT in a fully-qualified format
+ # -disregard toll-free
+ # -disregard private or unknown numbers
+ # -there is exactly one record in rate_prefix for a given NPANXX
+ # -default to interstate if we can't find one or both of the prefixes
+ my $dstprefix = $cdr->dst;
+ $dstprefix =~ /^(\d{6})/;
+ $dstprefix = qsearchs('rate_prefix', { 'countrycode' => '1',
+ 'npa' => $1,
+ }) || '';
+ my $srcprefix = $cdr->src;
+ $srcprefix =~ /^(\d{6})/;
+ $srcprefix = qsearchs('rate_prefix', { 'countrycode' => '1',
+ 'npa' => $1,
+ }) || '';
+ $eff_ratenum = $intrastate_ratenum if ($srcprefix && $dstprefix
+ && $srcprefix->state && $dstprefix->state
+ && $srcprefix->state eq $dstprefix->state);
+ }
+
$eff_ratenum ||= $ratenum;
$rate = qsearchs('rate', { 'ratenum' => $eff_ratenum })
or die "ratenum $eff_ratenum not found!";
$seconds += $charge_sec;
- $region_group_included_min -= $minutes if $region_group;
+ $region_group_included_min -= $minutes
+ if $region_group && $rate_detail->region_group;
$included_min{$regionnum}{$ratetimenum} -= $minutes;
- if ( $region_group_included_min <= 0
+ if ( ($region_group_included_min <= 0 || !$rate_detail->region_group)
&& $included_min{$regionnum}{$ratetimenum} <= 0 ) {
my $charge_min = 0 - $included_min{$regionnum}{$ratetimenum}; #XXX should preserve
#(display?) this
$included_min{$regionnum}{$ratetimenum} = 0;
$charge += ($rate_detail->min_charge * $charge_min); #still not rounded
}
+ elsif( $region_group_included_min > 0 && $region_group
+ && $rate_detail->region_group ) {
+ $included_min{$regionnum}{$ratetimenum} = 0
+ }
# choose next rate_detail
$rate_detail = $rate->dest_detail({ 'countrycode' => $countrycode,
$charge,
$classnum,
$phonenum,
+ $cdr->accountcode,
$seconds,
$regionname,
];
$charge,
$classnum,
$phonenum,
+ $cdr->accountcode,
$seconds,
$regionname,
];