add suspend_bill package option to more pkgparts, RT10586
[freeside.git] / FS / FS / part_pkg / prorate_Mixin.pm
index 3e4ec06..6d0c2da 100644 (file)
@@ -50,19 +50,19 @@ day arrives.
 sub calc_prorate {
   my ($self, $cust_pkg, $sdate, $details, $param, $cutoff_day) = @_;
   die "no cutoff_day" unless $cutoff_day;
+  die "can't prorate non-monthly package\n" if $self->freq =~ /\D/;
 
   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 +86,6 @@ sub calc_prorate {
 
     $param->{'months'} = $months;
     $charge = sprintf('%.2f', $permonth * $months);
-  #}
 
   return $charge;
 }