summaryrefslogtreecommitdiff
path: root/FS/FS/cdr.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2014-03-13 15:24:53 -0700
committerMark Wells <mark@freeside.biz>2014-03-13 15:24:53 -0700
commit8e3646075dfae1246f287ba3384eb34a83c67b08 (patch)
tree495e93d3a722e26eef8d71eb1a2d0bf969459df2 /FS/FS/cdr.pm
parent4549ed888d5cf6e89d8795fbbc7d58eebee73d7f (diff)
make region group included minutes work again, probably fallout from #5738
Diffstat (limited to 'FS/FS/cdr.pm')
-rw-r--r--FS/FS/cdr.pm53
1 files changed, 29 insertions, 24 deletions
diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm
index 0fdcbdf..583e728 100644
--- a/FS/FS/cdr.pm
+++ b/FS/FS/cdr.pm
@@ -577,25 +577,19 @@ sub parse_number {
Rates this CDR according and sets the status to 'rated'.
-Available options are: part_pkg, svcnum, single_price_included_minutes, region_group, region_group_included_minutes.
+Available options are: part_pkg, svcnum, plan_included_min,
+detail_included_min_hashref.
part_pkg is required.
If svcnum is specified, will also associate this CDR with the specified svcnum.
-single_price_included_minutes is requried for single_price price plans
-(otherwise unused/ignored). It should be set to a scalar reference of the
-number of included minutes and will be decremented by the rated minutes of this
+plan_included_min should be set to a scalar reference of the number of
+included minutes and will be decremented by the rated minutes of this
CDR.
-region_group_included_minutes is required for prefix price plans which have
-included minutes (otherwise unused/ignored). It should be set to a scalar
-reference of the number of included minutes and will be decremented by the
-rated minutes of this CDR.
-
-region_group_included_minutes_hashref is required for prefix price plans which
-have included minues (otherwise unused/ignored). It should be set to an empty
-hashref at the start of a month's rating and then preserved across CDRs.
+detail_included_min_hashref should be set to an empty hashref at the
+start of a month's rating and then preserved across CDRs.
=cut
@@ -897,20 +891,19 @@ sub rate_prefix {
$seconds += $charge_sec;
if ( $rate_detail->min_included ) {
- # the old, kind of deprecated way to do this
- my $included_min = $opt{'region_group_included_min_hashref'} || {};
+ # the old, kind of deprecated way to do this:
+ #
+ # The rate detail itself has included minutes. We MUST have a place
+ # to track them.
+ my $included_min = $opt{'detail_included_min_hashref'}
+ or die "unable to rate CDR: rate detail has included minutes, but ".
+ "no detail_included_min_hashref provided.\n";
# by default, set the included minutes for this region/time to
# what's in the rate_detail
$included_min->{$regionnum}{$ratetimenum} = $rate_detail->min_included
unless exists $included_min->{$regionnum}{$ratetimenum};
- # the way that doesn't work
- #my $region_group = ($part_pkg->option_cacheable('min_included') || 0) > 0;
-
- #${$opt{region_group_included_min}} -= $minutes
- # if $region_group && $rate_detail->region_group;
-
if ( $included_min->{$regionnum}{$ratetimenum} >= $minutes ) {
$charge_sec = 0;
$included_min->{$regionnum}{$ratetimenum} -= $minutes;
@@ -918,6 +911,18 @@ sub rate_prefix {
$charge_sec -= ($included_min->{$regionnum}{$ratetimenum} * 60);
$included_min->{$regionnum}{$ratetimenum} = 0;
}
+ } elsif ( ${ $opt{'plan_included_min'} } > 0 ) {
+ # The package definition has included minutes, but only for in-group
+ # rate details. Decrement them if this is an in-group call.
+ if ( $rate_detail->region_group ) {
+ if ( ${ $opt{'plan_included_min'} } >= $minutes ) {
+ $charge_sec = 0;
+ ${ $opt{'plan_included_min'} } -= $minutes;
+ } else {
+ $charge_sec -= (${ $opt{'plan_included_min'} } * 60);
+ ${ $opt{'plan_included_min'} } = 0;
+ }
+ }
} else {
# the new way!
my $applied_min = $cust_pkg->apply_usage(
@@ -1020,12 +1025,12 @@ sub rate_single_price {
my $charge_min = $minutes;
- ${$opt{single_price_included_min}} -= $minutes;
- if ( ${$opt{single_price_included_min}} > 0 ) {
+ ${$opt{plan_included_min}} -= $minutes;
+ if ( ${$opt{plan_included_min}} > 0 ) {
$charge_min = 0;
} else {
- $charge_min = 0 - ${$opt{single_price_included_min}};
- ${$opt{single_price_included_min}} = 0;
+ $charge_min = 0 - ${$opt{plan_included_min}};
+ ${$opt{plan_included_min}} = 0;
}
my $charge =