diff options
author | levinse <levinse> | 2011-04-13 00:35:43 +0000 |
---|---|---|
committer | levinse <levinse> | 2011-04-13 00:35:43 +0000 |
commit | 7b3528faa2b4f056a142747445a9de682f878d72 (patch) | |
tree | 1536a0afa7e4fa55739152488814568fa1da75ff | |
parent | 3714fa41c5306981c9f500df13eea52c72d82545 (diff) |
fix region group billing, RT8951
-rw-r--r-- | FS/FS/Schema.pm | 1 | ||||
-rw-r--r-- | FS/FS/part_pkg/voip_cdr.pm | 9 | ||||
-rw-r--r-- | FS/FS/rate_detail.pm | 3 | ||||
-rw-r--r-- | httemplate/edit/rate_detail.html | 5 |
4 files changed, 16 insertions, 2 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index f1814b3d5..c9775fca8 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -2551,6 +2551,7 @@ sub tables_hashref { 'ratetimenum', 'int', 'NULL', '', '', '', 'classnum', 'int', 'NULL', '', '', '', 'cdrtypenum', 'int', 'NULL', '', '', '', + 'region_group', 'char', 'NULL', 1, '', '', ], 'primary_key' => 'ratedetailnum', 'unique' => [ [ 'ratenum', 'orig_regionnum', 'dest_regionnum' ] ], diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 3b1648c86..2e165cd49 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -681,16 +681,21 @@ sub calc_usage { $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, diff --git a/FS/FS/rate_detail.pm b/FS/FS/rate_detail.pm index 918134a3a..f3ee84c74 100644 --- a/FS/FS/rate_detail.pm +++ b/FS/FS/rate_detail.pm @@ -59,6 +59,8 @@ inherits from FS::Record. The following fields are currently supported: =item cdrtypenum - CDR type (see L<FS::cdr_type>) if any for this rate +=item region_group - Group in region group for rate plan + =back =head1 METHODS @@ -133,6 +135,7 @@ sub check { || $self->ut_number('sec_granularity') || $self->ut_foreign_keyn('classnum', 'usage_class', 'classnum' ) + || $self->ut_enum('region_group', [ '', 'Y' ]) ; return $error if $error; diff --git a/httemplate/edit/rate_detail.html b/httemplate/edit/rate_detail.html index 19378209e..d0b85095b 100644 --- a/httemplate/edit/rate_detail.html +++ b/httemplate/edit/rate_detail.html @@ -7,6 +7,7 @@ 'dest_prefixes_short' => 'Prefix(es)', 'rate_time_name' => 'Time period', 'min_included' => 'Included minutes/calls', + 'region_group' => 'Region Group', 'conn_charge' => 'Connection charge', 'conn_sec' => 'For', 'min_charge' => 'Charge per minute/call', @@ -22,6 +23,10 @@ { field=>'dest_regionname', type=>'fixed', }, { field=>'dest_prefixes_short', type=>'fixed', }, { field=>'rate_time_name', type=>'fixed', }, + { field => 'region_group', + type => 'checkbox', + value => 'Y', + }, { field=>'min_included', type=>'text', size=>5 }, { field=>'conn_charge', type=>'money', size=>4 }, { field =>'conn_sec', |