[freeside-commits] freeside/FS/FS/part_pkg flat.pm, 1.59, 1.60 prorate.pm, 1.25, 1.26 prorate_Mixin.pm, 1.10, 1.11 recur_Common.pm, 1.9, 1.10

Ivan,,, ivan at wavetail.420.am
Mon Mar 14 16:39:16 PDT 2011


Update of /home/cvs/cvsroot/freeside/FS/FS/part_pkg
In directory wavetail.420.am:/tmp/cvs-serv6047

Modified Files:
	flat.pm prorate.pm prorate_Mixin.pm recur_Common.pm 
Log Message:
fix prorates & recurring fees with recur_Common-using packages, RT#11993

Index: prorate_Mixin.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/prorate_Mixin.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -d -r1.10 -r1.11
--- prorate_Mixin.pm	19 Jan 2011 00:41:00 -0000	1.10
+++ prorate_Mixin.pm	14 Mar 2011 23:39:14 -0000	1.11
@@ -50,7 +50,7 @@
 sub calc_prorate {
   my $self  = shift;
   my ($cust_pkg, $sdate, $details, $param) = @_;
-  my $cutoff_day = $self->cutoff_day($cust_pkg) or return; #die?
+  my $cutoff_day = $self->cutoff_day or die "no cutoff_day"; #($cust_pkg)
 
   my $charge = $self->base_recur($cust_pkg, $sdate) || 0;
   if ( $cutoff_day ) {
@@ -90,6 +90,17 @@
   return $charge;
 }
 
+=item cutoff_day
+
+Returns the value of the "cutoff_day" option, or 1.
+
+=cut
+
+sub cutoff_day {
+  my $self = shift;
+  $self->option('cutoff_day', 1) || 1;
+}
+
 =item prorate_setup CUST_PKG SDATE
 
 Set up the package.  This only has an effect if prorate_defer_bill is 

Index: prorate.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/prorate.pm,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -w -d -r1.25 -r1.26
--- prorate.pm	19 Jan 2011 00:41:00 -0000	1.25
+++ prorate.pm	14 Mar 2011 23:39:14 -0000	1.26
@@ -38,11 +38,6 @@
   'weight' => 20,
 );
 
-sub cutoff_day {
-  my $self = shift;
-  $self->option('cutoff_day', 1) || 1;
-}
-
 sub calc_recur {
   my $self = shift;
   return $self->calc_prorate(@_) - $self->calc_discount(@_);

Index: flat.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/flat.pm,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -w -d -r1.59 -r1.60
--- flat.pm	14 Mar 2011 22:43:01 -0000	1.59
+++ flat.pm	14 Mar 2011 23:39:14 -0000	1.60
@@ -126,7 +126,7 @@
     if $self->option('recur_temporality', 1) eq 'preceding' && $last_bill == 0;
 
   my $charge = $self->base_recur($cust_pkg, $sdate);
-  if ( my $cutoff_day = $self->cutoff_day($cust_pkg) ) {
+  if ( my $cutoff_day = $self->flat_cutoff_day($cust_pkg) ) {
     $charge = $self->calc_prorate(@_);
   }
   elsif ( $param->{freq_override} ) {
@@ -140,7 +140,7 @@
   return sprintf('%.2f', $charge - $discount);
 }
 
-sub cutoff_day {
+sub flat_cutoff_day {
   my $self = shift;
   my $cust_pkg = shift;
   if ( $self->option('sync_bill_date',1) ) {

Index: recur_Common.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/recur_Common.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -d -r1.9 -r1.10
--- recur_Common.pm	9 Feb 2011 05:22:50 -0000	1.9
+++ recur_Common.pm	14 Mar 2011 23:39:14 -0000	1.10
@@ -1,12 +1,10 @@
 package FS::part_pkg::recur_Common;
 
 use strict;
-use vars qw( @ISA %info %recur_method );
+use base qw( FS::part_pkg::flat );
+use vars qw( %info %recur_method );
 use Tie::IxHash;
 use Time::Local;
-use FS::part_pkg::flat;
-
- at ISA = qw(FS::part_pkg::flat);
 
 %info = ( 'disabled' => 1 ); #recur_Common not a usable price plan directly
 
@@ -35,20 +33,22 @@
     $charges += $param->{'override_charges'} if $param->{'override_charges'};
 
     if ( $recur_method eq 'prorate' ) {
+
       my $cutoff_day = $self->option('cutoff_day') || 1;
       $charges = $self->calc_prorate(@_, $cutoff_day);
       $charges += $param->{'override_charges'} if $param->{'override_charges'};
-    }
-    elsif ( $recur_method eq 'anniversary' and 
+
+    } elsif ( $recur_method eq 'anniversary' and 
             $self->option('sync_bill_date',1) ) {
+
       my $next_bill = $cust_pkg->cust_main->next_bill_date;
       if ( defined($next_bill) ) {
         my $cutoff_day = (localtime($next_bill))[3];
         $charges = $self->calc_prorate(@_, $cutoff_day);
         $charges += $param->{'override_charges'} if $param->{'override_charges'};
       }
-    } 
-    elsif ( $recur_method eq 'subscription' ) {
+
+    } elsif ( $recur_method eq 'subscription' ) {
 
       my $cutoff_day = $self->option('cutoff_day', 1) || 1;
       my ($day, $mon, $year) = ( localtime($$sdate) )[ 3..5 ];
@@ -60,7 +60,7 @@
 
       $$sdate = timelocal(0, 0, 0, $cutoff_day, $mon, $year);
 
-    }#$recur_method eq 'subscription'
+    }#$recur_method
 
     $charges -= $self->calc_discount( $cust_pkg, $sdate, $details, $param );
 



More information about the freeside-commits mailing list