From a3083358ecc9b9b7f9294847cbea30652b48d8e8 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 8 Apr 2011 01:00:37 +0000 Subject: [PATCH] torrus: default to "preceding" behavior, RT#10574 --- FS/FS/cust_main/Billing.pm | 4 ++-- FS/FS/part_pkg/cdr_termination.pm | 2 +- FS/FS/part_pkg/flat.pm | 7 ++++++- FS/FS/part_pkg/torrus_Common.pm | 2 ++ FS/FS/part_pkg/torrus_bw_percentile.pm | 1 - FS/FS/part_pkg/torrus_bw_usage.pm | 1 - FS/FS/part_pkg/voip_cdr.pm | 2 +- FS/FS/part_pkg/voip_inbound.pm | 2 +- 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm index 3b9f0c94c..b710f3326 100644 --- a/FS/FS/cust_main/Billing.pm +++ b/FS/FS/cust_main/Billing.pm @@ -1019,11 +1019,11 @@ sub _make_lines { 'freq' => $part_pkg->freq, }; - if ( $part_pkg->option('recur_temporality', 1) eq 'preceding' ) { + if ( $part_pkg->recur_temporality eq 'preceding' ) { $cust_bill_pkg->sdate( $hash{last_bill} ); $cust_bill_pkg->edate( $sdate - 86399 ); #60s*60m*24h-1 $cust_bill_pkg->edate( $time ) if $options{cancel}; - } else { #if ( $part_pkg->option('recur_temporality', 1) eq 'upcoming' ) { + } else { #if ( $part_pkg->recur_temporality eq 'upcoming' ) { $cust_bill_pkg->sdate( $sdate ); $cust_bill_pkg->edate( $cust_pkg->bill ); #$cust_bill_pkg->edate( $time ) if $options{cancel}; diff --git a/FS/FS/part_pkg/cdr_termination.pm b/FS/FS/part_pkg/cdr_termination.pm index 840da8224..3723629aa 100644 --- a/FS/FS/part_pkg/cdr_termination.pm +++ b/FS/FS/part_pkg/cdr_termination.pm @@ -103,7 +103,7 @@ sub calc_recur { 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 ); # termination calculations diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm index 89de551b1..04f4951c5 100644 --- a/FS/FS/part_pkg/flat.pm +++ b/FS/FS/part_pkg/flat.pm @@ -123,7 +123,7 @@ sub calc_recur { my $last_bill = $cust_pkg->get('last_bill'); #->last_bill falls back to setup return 0 - if $self->option('recur_temporality', 1) eq 'preceding' && $last_bill == 0; + if $self->recur_temporality eq 'preceding' && $last_bill == 0; my $charge = $self->base_recur($cust_pkg, $sdate); if ( my $cutoff_day = $self->cutoff_day($cust_pkg) ) { @@ -209,6 +209,11 @@ sub can_discount { $self->freq =~ /^\d+$/ && $self->freq > 0; } +sub recur_temporality { + my $self = shift; + $self->option('recur_temporality', 1); +} + sub usage_valuehash { my $self = shift; map { $_, $self->option($_) } diff --git a/FS/FS/part_pkg/torrus_Common.pm b/FS/FS/part_pkg/torrus_Common.pm index 2eda725f7..d0dc9d14d 100644 --- a/FS/FS/part_pkg/torrus_Common.pm +++ b/FS/FS/part_pkg/torrus_Common.pm @@ -7,6 +7,8 @@ our %info = ( 'disabled' => 1 ); #torrus_Common not a usable price plan directly our $DEBUG = 1; +sub recur_temporality { 'preceding'; } + sub price_info { my $self = shift; my $str = $self->SUPER::price_info; diff --git a/FS/FS/part_pkg/torrus_bw_percentile.pm b/FS/FS/part_pkg/torrus_bw_percentile.pm index 16be62786..d8798995b 100644 --- a/FS/FS/part_pkg/torrus_bw_percentile.pm +++ b/FS/FS/part_pkg/torrus_bw_percentile.pm @@ -10,7 +10,6 @@ our %info = ( 'weight' => 54.5, #:/ 'inherit_fields' => [ 'flat', 'global_Mixin' ], 'fields' => { - #'recur_temporality' => { 'hidden' => 1, 'value' => 'preceding' }, #XXX do 'recur_temporality' => { 'disabled' => 1 }, 'sync_bill_date' => { 'disabled' => 1 }, 'cutoff_day' => { 'disabled' => 1 }, diff --git a/FS/FS/part_pkg/torrus_bw_usage.pm b/FS/FS/part_pkg/torrus_bw_usage.pm index 5a2dd36a0..12912b3ba 100644 --- a/FS/FS/part_pkg/torrus_bw_usage.pm +++ b/FS/FS/part_pkg/torrus_bw_usage.pm @@ -10,7 +10,6 @@ our %info = ( 'weight' => 54.7, #:/ 'inherit_fields' => [ 'flat', 'global_Mixin' ], 'fields' => { - #'recur_temporality' => { 'hidden' => 1, 'value' => 'preceding' }, #XXX do 'recur_temporality' => { 'disabled' => 1 }, 'sync_bill_date' => { 'disabled' => 1 }, 'cutoff_day' => { 'disabled' => 1 }, diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index cd1be355f..3b1648c86 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -318,7 +318,7 @@ sub calc_usage { 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'); diff --git a/FS/FS/part_pkg/voip_inbound.pm b/FS/FS/part_pkg/voip_inbound.pm index 36efad1ae..e3e6faaf7 100644 --- a/FS/FS/part_pkg/voip_inbound.pm +++ b/FS/FS/part_pkg/voip_inbound.pm @@ -202,7 +202,7 @@ sub calc_usage { 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 $spool_cdr = $cust_pkg->cust_main->spool_cdr; -- 2.11.0