per-package flags to override package def level suspend_bill flag, RT#18376
authorIvan Kohler <ivan@freeside.biz>
Mon, 9 Jul 2012 05:43:27 +0000 (22:43 -0700)
committerIvan Kohler <ivan@freeside.biz>
Mon, 9 Jul 2012 05:43:27 +0000 (22:43 -0700)
FS/FS/cust_main/Billing.pm
FS/FS/cust_main/Packages.pm
FS/FS/cust_pkg.pm
httemplate/misc/cancel_pkg.html
httemplate/misc/process/cancel_pkg.html
httemplate/view/cust_main/packages/status.html

index 0a557fc..665662a 100644 (file)
@@ -958,7 +958,10 @@ sub _make_lines {
   my @recur_discounts = ();
   my $sdate;
   if (     ! $cust_pkg->start_date
-       and ( ! $cust_pkg->susp || $part_pkg->option('suspend_bill', 1) )
+       and ( ! $cust_pkg->susp || $cust_pkg->option('suspend_bill',1)
+                               || ( $part_pkg->option('suspend_bill', 1) )
+                                     && ! $cust_pkg->option('no_suspend_bill',1)
+                                  )
        and
             ( $part_pkg->freq ne '0' && ( $cust_pkg->bill || 0 ) <= day_end($time) )
          || ( $part_pkg->plan eq 'voip_cdr'
index 06331d3..316dede 100644 (file)
@@ -406,7 +406,11 @@ sub billing_pkgs {
   my $self = shift;
   grep { my $part_pkg = $_->part_pkg;
          $part_pkg->freq ne '' && $part_pkg->freq ne '0'
-           && ( ! $_->susp || $part_pkg->option('suspend_bill', 1) );
+           && ( ! $_->susp || $_->option('suspend_bill',1)
+                           || ( $part_pkg->option('suspend_bill', 1)
+                                  && ! $_->option('no_suspend_bill',1)
+                              )
+              );
        }
        $self->ncancelled_pkgs;
 }
index 855accc..4b458de 100644 (file)
@@ -1041,8 +1041,13 @@ sub suspend {
     $hash{'resume'} = $resume_date;
   }
 
+  $options{options} ||= {};
+
   my $new = new FS::cust_pkg ( \%hash );
-  $error = $new->replace( $self, options => { $self->options } );
+  $error = $new->replace( $self, options => { $self->options,
+                                              %{ $options{options} },
+                                            }
+                        );
   if ( $error ) {
     $dbh->rollback if $oldAutoCommit;
     return $error;
index 4b5df86..42cc56d 100755 (executable)
 &>
 % }
 
-% if ( ( $method eq 'adjourn' or $method eq 'suspend' ) and 
+% if ( $method eq 'adjourn' || $method eq 'suspend' ) {
+    <TR><TD COLSPAN=2>
+%   if ( $part_pkg->option('suspend_bill', 1) ) {
+      <& /elements/checkbox.html, name=>'no_suspend_bill', value=>'Y' &>
+      Disable recurring billing while suspended
+%   } else {
+      <& /elements/checkbox.html, name=>'suspend_bill', value=>'Y' &>
+      Continue recurring billing while suspended
+%   }
+    </TD></TR>
+% }
+
+% if ( ( $method eq 'adjourn' || $method eq 'suspend' ) and 
 %      $curuser->access_right('Unsuspend customer package') )  { #later?
 %   my $resume_date = $cgi->param('error') 
 %                     ? str2time($cgi->param('resume_date'))
index 662a776..4f8e11b 100755 (executable)
@@ -49,10 +49,15 @@ if ($method eq 'expire' || $method eq 'adjourn' || $method eq 'resume'){
   $method = 'unsuspend' if $method eq 'resume';
 }
 
-my $resume_date;
+my $resume_date = '';
+my $options = '';
 if ( $method eq 'suspend' ) { #or 'adjourn'
   $resume_date = parse_datetime($cgi->param('resume_date'))
     if $cgi->param('resume_date');
+
+  $options = { map scalar($cgi->param($_)),
+                 suspend_bill no_suspend_bill
+             };
 }
 
 my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} );
@@ -73,7 +78,9 @@ if ( $method ne 'unsuspend' ) { #i.e. 'resume'
 
 my $error = $cust_pkg->$method( 'reason'      => $reasonnum,
                                 'date'        => $date,
-                                'resume_date' => $resume_date );
+                                'resume_date' => $resume_date,
+                                'options'     => $options,
+                              );
 
 if ($error) {
   $cgi->param('error', $error);
index 28df9da..47ef1bc 100644 (file)
 
     <% pkg_status_row_changed( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
     <% pkg_status_row_if( $cust_pkg, $last_bill_or_renewed, 'last_bill', %opt, curuser=>$curuser ) %>
-%   if ( $part_pkg->option('suspend_bill', 1) ) {
+%   if ( $cust_pkg->option('suspend_bill', 1)
+%        || ( $part_pkg->option('suspend_bill', 1)
+%               && ! $cust_pkg->option('no_suspend_bill',1)
+%           )
+%      )
+%   {
       <% pkg_status_row_if( $cust_pkg, emt('Next bill'), 'bill', %opt, curuser=>$curuser ) %>
 %   }
     <% pkg_status_row_if( $cust_pkg, emt('Will resume'), 'resume', %opt, curuser=>$curuser ) %>