X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fprorate_Mixin.pm;h=78a089313ecd574dbb68a972b4acc7c8aa60e4e9;hb=fdb9aecd3c4bcaef6f13becbe209e7cd7475204b;hp=75dbe5cf8fa9db6e08e8018bbe3ba70cbf8d5638;hpb=5fdd19665fb7c0ad425a99d3dbf9ad7e27fbf44a;p=freeside.git diff --git a/FS/FS/part_pkg/prorate_Mixin.pm b/FS/FS/part_pkg/prorate_Mixin.pm index 75dbe5cf8..78a089313 100644 --- a/FS/FS/part_pkg/prorate_Mixin.pm +++ b/FS/FS/part_pkg/prorate_Mixin.pm @@ -1,10 +1,9 @@ package FS::part_pkg::prorate_Mixin; use strict; -use vars qw(@ISA %info); -use Time::Local qw(timelocal); +use vars qw( %info ); +use Time::Local qw( timelocal ); -@ISA = qw(FS::part_pkg); %info = ( 'disabled' => 1, # define all fields that are referenced in this code @@ -99,8 +98,12 @@ sub calc_prorate { my $months = ( ( $self->freq - 1 ) + ($mend-$mnow) / ($mend-$mstart) ); # add a full period if currently billing for a partial period - if ( ( $self->option('add_full_period',1) - or $self->option('prorate_defer_bill',1) ) # necessary + # or periods up to freq_override if billing for an override interval + if ( ($param->{'freq_override'} || 0) > 1 ) { + $months += $param->{'freq_override'} - 1; + } + elsif ( ( $self->option('add_full_period',1) + or $self->option('prorate_defer_bill',1) ) and $months < $self->freq ) { $months += $self->freq; $$sdate = $self->add_freq($mstart); @@ -128,10 +131,12 @@ sub prorate_setup { and $cutoff_day ) { my ($mnow, $mend, $mstart) = $self->_endpoints($sdate, $cutoff_day); - # if today is the cutoff day, set the next bill to right now instead - # of waiting a month. + # If today is the cutoff day, set the next bill and setup both to + # midnight today, so that the customer will be billed normally for a + # month starting today. if ( $mnow - $mstart < 86400 ) { - $cust_pkg->bill($mnow); + $cust_pkg->setup($mstart); + $cust_pkg->bill($mstart); } else { $cust_pkg->bill($mend);