X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fprorate_Mixin.pm;h=ed532ee1240c614b8afb5a0be773ae7cea8fbe58;hb=86119e342d95f16b799043e9cf66230d015c37de;hp=a60858b3724d88b8a39c200b76518ab68f49f7b5;hpb=4117c20f85ce085d7dd42b8970ce9c65b95d7e27;p=freeside.git diff --git a/FS/FS/part_pkg/prorate_Mixin.pm b/FS/FS/part_pkg/prorate_Mixin.pm index a60858b37..ed532ee12 100644 --- a/FS/FS/part_pkg/prorate_Mixin.pm +++ b/FS/FS/part_pkg/prorate_Mixin.pm @@ -48,7 +48,7 @@ sub calc_prorate { my $charge = $self->option('recur_fee') || 0; my $cutoff_day; - if( $self->option('sync_bill_date') ) { + if( $self->option('sync_bill_date',1) ) { my $next_bill = $cust_pkg->cust_main->next_bill_date; if( defined($next_bill) and $next_bill != $$sdate ) { $cutoff_day = (localtime($next_bill))[3]; @@ -80,12 +80,19 @@ sub calc_prorate { $mstart = timelocal(0,0,0,$cutoff_day,$mon == 0 ? 11 : $mon - 1,$year-($mon==11)); } - + + # next bill date will be figured as $$sdate + one period $$sdate = $mstart; my $permonth = $self->option('recur_fee', 1) / $self->freq; my $months = ( ( $self->freq - 1 ) + ($mend-$mnow) / ($mend-$mstart) ); - + + if ( $self->option('add_full_period',1) ) { + # charge a full period in addition to the partial month + $months += $self->freq; + $$sdate = $self->add_freq($mstart); + } + $param->{'months'} = $months; $charge = sprintf('%.2f', $permonth * $months); }