summaryrefslogtreecommitdiff
path: root/FS/FS/part_pkg/recur_Common.pm
diff options
context:
space:
mode:
authorcvs2git <cvs2git>2010-11-05 19:05:57 +0000
committercvs2git <cvs2git>2010-11-05 19:05:57 +0000
commitaaf8baf3662e16e9414de236a39f8801a8c41b01 (patch)
tree2cda603e4311b3e80f79b93d9bcce3a7c7c2d053 /FS/FS/part_pkg/recur_Common.pm
parent995a145c931164347683071c95c6754379d36604 (diff)
parent9b2de4257b6a2877434008188e52b8ef71ff339d (diff)
This commit was manufactured by cvs2svn to create branch
'FREESIDE_2_1_BRANCH'.
Diffstat (limited to 'FS/FS/part_pkg/recur_Common.pm')
-rw-r--r--FS/FS/part_pkg/recur_Common.pm55
1 files changed, 32 insertions, 23 deletions
diff --git a/FS/FS/part_pkg/recur_Common.pm b/FS/FS/part_pkg/recur_Common.pm
index 8ed9eb6..7614d7a 100644
--- a/FS/FS/part_pkg/recur_Common.pm
+++ b/FS/FS/part_pkg/recur_Common.pm
@@ -4,9 +4,9 @@ use strict;
use vars qw( @ISA %info %recur_method );
use Tie::IxHash;
use Time::Local;
-use FS::part_pkg::prorate;
+use FS::part_pkg::flat;
-@ISA = qw(FS::part_pkg::prorate);
+@ISA = qw(FS::part_pkg::flat);
%info = ( 'disabled' => 1 ); #recur_Common not a usable price plan directly
@@ -16,6 +16,11 @@ tie %recur_method, 'Tie::IxHash',
'subscription' => 'Charge the full fee for the first partial period (selectable billing date)',
;
+sub base_recur {
+ my $self = shift;
+ $self->option('recur_fee', 1) || 0;
+}
+
sub calc_recur_Common {
my $self = shift;
my($cust_pkg, $sdate, $details, $param ) = @_; #only need $sdate & $param
@@ -25,36 +30,40 @@ sub calc_recur_Common {
if ( $param->{'increment_next_bill'} ) {
my $recur_method = $self->option('recur_method', 1) || 'anniversary';
-
- if ( $recur_method eq 'prorate' ) {
-
- $charges = $self->SUPER::calc_recur(@_);
+
+ $charges = $self->base_recur;
- } else {
-
- $charges = $self->option('recur_fee');
-
- if ( $recur_method eq 'subscription' ) {
-
- my $cutoff_day = $self->option('cutoff_day', 1) || 1;
- my ($day, $mon, $year) = ( localtime($$sdate) )[ 3..5 ];
+ if ( $recur_method eq 'prorate' ) {
+ my $cutoff_day = $self->option('cutoff_day') || 1;
+ $charges = $self->calc_prorate(@_, $cutoff_day);
+ }
+ 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);
+ }
+ }
+ elsif ( $recur_method eq 'subscription' ) {
- if ( $day < $cutoff_day ) {
- if ( $mon == 0 ) { $mon=11; $year--; }
- else { $mon--; }
- }
+ my $cutoff_day = $self->option('cutoff_day', 1) || 1;
+ my ($day, $mon, $year) = ( localtime($$sdate) )[ 3..5 ];
- $$sdate = timelocal(0, 0, 0, $cutoff_day, $mon, $year);
+ if ( $day < $cutoff_day ) {
+ if ( $mon == 0 ) { $mon=11; $year--; }
+ else { $mon--; }
+ }
- }#$recur_method eq 'subscription'
+ $$sdate = timelocal(0, 0, 0, $cutoff_day, $mon, $year);
- $charges -= $self->calc_discount( $cust_pkg, $sdate, $details, $param );
+ }#$recur_method eq 'subscription'
- }#$recur_method eq 'prorate'
+ $charges -= $self->calc_discount( $cust_pkg, $sdate, $details, $param );
}#increment_next_bill
- $charges;
+ return $charges;
}