[freeside-commits] freeside/FS/FS/part_pkg prorate.pm, 1.27, 1.28 prorate_Mixin.pm, 1.12, 1.13 recur_Common.pm, 1.10, 1.11
Mark Wells
mark at wavetail.420.am
Tue Mar 15 16:32:20 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/part_pkg
In directory wavetail.420.am:/tmp/cvs-serv4986
Modified Files:
prorate.pm prorate_Mixin.pm recur_Common.pm
Log Message:
continue prorate cleanup, #10630
Index: prorate_Mixin.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/prorate_Mixin.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -w -d -r1.12 -r1.13
--- prorate_Mixin.pm 15 Mar 2011 00:04:30 -0000 1.12
+++ prorate_Mixin.pm 15 Mar 2011 23:32:18 -0000 1.13
@@ -53,16 +53,15 @@
my $charge = $self->base_recur($cust_pkg, $sdate) || 0;
- #if ( $cutoff_day ) {
my $mnow = $$sdate;
# if this is the first bill but the bill date has been set
# (by prorate_defer_bill), calculate from the setup date,
# and append the setup fee to @$details.
- if ( $self->option('prorate_defer_bill')
+ if ( $self->option('prorate_defer_bill',1)
and ! $cust_pkg->getfield('last_bill')
and $cust_pkg->setup ) {
- warn "[calc_prorate] #".$cust_pkg->pkgnum.": running deferred setup\n";
+ #warn "[calc_prorate] #".$cust_pkg->pkgnum.": running deferred setup\n";
$param->{'setup_fee'} = $self->calc_setup($cust_pkg, $$sdate, $details);
$mnow = $cust_pkg->setup;
}
@@ -86,7 +85,6 @@
$param->{'months'} = $months;
$charge = sprintf('%.2f', $permonth * $months);
- #}
return $charge;
}
Index: prorate.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/prorate.pm,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -w -d -r1.27 -r1.28
--- prorate.pm 15 Mar 2011 00:04:30 -0000 1.27
+++ prorate.pm 15 Mar 2011 23:32:18 -0000 1.28
@@ -40,8 +40,12 @@
sub calc_recur {
my $self = shift;
- my $cutoff_day = $self->option('cutoff_day') || 1;
- return $self->calc_prorate(@_, $cutoff_day) - $self->calc_discount(@_);
+ return $self->calc_prorate(@_, $self->cutoff_day) - $self->calc_discount(@_);
+}
+
+sub cutoff_day {
+ my $self = shift;
+ $self->option('cutoff_day') || 1;
}
1;
Index: recur_Common.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/recur_Common.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -d -r1.10 -r1.11
--- recur_Common.pm 14 Mar 2011 23:39:14 -0000 1.10
+++ recur_Common.pm 15 Mar 2011 23:32:18 -0000 1.11
@@ -19,6 +19,18 @@
$self->option('recur_fee', 1) || 0;
}
+sub cutoff_day {
+ # prorate/subscription only; we don't support sync_bill_date here
+ my $self = shift;
+ my $cust_pkg = shift;
+ my $recur_method = $self->option('recur_method',1) || 'anniversary';
+ if ( $recur_method eq 'prorate' or $recur_method eq 'subscription' ) {
+ return $self->option('cutoff_day',1) || 1;
+ } else {
+ return 0;
+ }
+}
+
sub calc_recur_Common {
my $self = shift;
my($cust_pkg, $sdate, $details, $param ) = @_; #only need $sdate & $param
@@ -28,29 +40,18 @@
if ( $param->{'increment_next_bill'} ) {
my $recur_method = $self->option('recur_method', 1) || 'anniversary';
+ my $cutoff_day = $self->cutoff_day($cust_pkg);
$charges = $self->base_recur;
$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
- $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' ) {
- my $cutoff_day = $self->option('cutoff_day', 1) || 1;
my ($day, $mon, $year) = ( localtime($$sdate) )[ 3..5 ];
if ( $day < $cutoff_day ) {
More information about the freeside-commits
mailing list