This commit was manufactured by cvs2svn to create tag 'freeside_2_1_1'.
[freeside.git] / FS / FS / part_pkg / recur_Common.pm
index 71f3af7..ec17c16 100644 (file)
@@ -1,13 +1,15 @@
 package FS::part_pkg::recur_Common;
 
 use strict;
-use vars qw( @ISA %recur_method );
+use vars qw( @ISA %info %recur_method );
 use Tie::IxHash;
 use Time::Local;
 use FS::part_pkg::prorate;
 
 @ISA = qw(FS::part_pkg::prorate);
 
+%info = ( 'disabled' => 1 ); #recur_Common not a usable price plan directly
+
 tie %recur_method, 'Tie::IxHash',
   'anniversary'  => 'Charge the recurring fee at the frequency specified above',
   'prorate'      => 'Charge a prorated fee the first time (selectable billing date)',
@@ -24,11 +26,12 @@ sub calc_recur_Common {
 
     my $recur_method = $self->option('recur_method', 1) || 'anniversary';
                   
-    if ( $recur_method eq 'prorate' ) {
-
-      $charges = $self->SUPER::calc_recur(@_);
-
-    } else {
+    if ( $recur_method eq 'prorate' 
+        or ($recur_method eq 'anniversary' and $self->option('sync_bill_date',1))
+      ) {
+      $charges = $self->calc_prorate(@_);
+    } 
+    else {
 
       $charges = $self->option('recur_fee');
 
@@ -45,12 +48,12 @@ sub calc_recur_Common {
         $$sdate = timelocal(0, 0, 0, $cutoff_day, $mon, $year);
 
       }#$recur_method eq 'subscription'
+    $charges -= $self->calc_discount( $cust_pkg, $sdate, $details, $param );
 
-    }#$recur_method eq 'prorate'
-
+    }#$recur_method eq 'prorate' or ...
   }#increment_next_bill
 
-  $charges;
+  return $charges;
 
 }