torrus: default to "preceding" behavior, RT#10574
authorivan <ivan>
Fri, 8 Apr 2011 01:00:37 +0000 (01:00 +0000)
committerivan <ivan>
Fri, 8 Apr 2011 01:00:37 +0000 (01:00 +0000)
FS/FS/cust_main/Billing.pm
FS/FS/part_pkg/cdr_termination.pm
FS/FS/part_pkg/flat.pm
FS/FS/part_pkg/torrus_Common.pm
FS/FS/part_pkg/torrus_bw_percentile.pm
FS/FS/part_pkg/torrus_bw_usage.pm
FS/FS/part_pkg/voip_cdr.pm
FS/FS/part_pkg/voip_inbound.pm

index 3b9f0c9..b710f33 100644 (file)
@@ -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};
index 840da82..3723629 100644 (file)
@@ -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
index 89de551..04f4951 100644 (file)
@@ -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($_) }
index 2eda725..d0dc9d1 100644 (file)
@@ -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;
index 16be627..d879899 100644 (file)
@@ -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 },
index 5a2dd36..12912b3 100644 (file)
@@ -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 },
index cd1be35..3b1648c 100644 (file)
@@ -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');
index 36efad1..e3e6faa 100644 (file)
@@ -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;