[freeside-commits] branch FREESIDE_3_BRANCH updated. caaba136dc662ca8a5b4a221fac238b89945332a

Mark Wells mark at 420.am
Tue Sep 16 21:57:02 PDT 2014


The branch, FREESIDE_3_BRANCH has been updated
       via  caaba136dc662ca8a5b4a221fac238b89945332a (commit)
      from  4dcbb6b380dfd036cc06e4d7002cbda17d29f23a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit caaba136dc662ca8a5b4a221fac238b89945332a
Author: Mark Wells <mark at freeside.biz>
Date:   Tue Sep 16 21:55:13 2014 -0700

    improve unsuspend behavior for packages on hold, #28508

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 3d7ffe7..b6fa81d 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -4053,13 +4053,6 @@ and customer address. Include units.',
   },
 
   {
-    'key'         => 'disable_setup_suspended_pkgs',
-    'section'     => 'billing',
-    'description' => 'Disables charging of setup fees for suspended packages.',
-    'type'        => 'checkbox',
-  },
-
-  {
     'key'         => 'password-generated-allcaps',
     'section'     => 'password',
     'description' => 'Causes passwords automatically generated to consist entirely of capital letters',
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index 734d61a..3e50b11 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -3165,7 +3165,7 @@ sub scalar_sql {
   defined($scalar) ? $scalar : '';
 }
 
-=item count [ WHERE ]
+=item count [ WHERE [, PLACEHOLDER ...] ]
 
 Convenience method for the common case of "SELECT COUNT(*) FROM table", 
 with optional WHERE.  Must be called as method on a class with an 
@@ -3178,7 +3178,7 @@ sub count {
   my $table = $self->table or die 'count called on object of class '.ref($self);
   my $sql = "SELECT COUNT(*) FROM $table";
   $sql .= " WHERE $where" if $where;
-  $self->scalar_sql($sql);
+  $self->scalar_sql($sql, @_);
 }
 
 =back
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index e1d3caa..c0d8dbe 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -2149,14 +2149,27 @@ sub cust_contact {
 =item unsuspend
 
 Unsuspends all unflagged suspended packages (see L</unflagged_suspended_pkgs>
-and L<FS::cust_pkg>) for this customer.  Always returns a list: an empty list
-on success or a list of errors.
+and L<FS::cust_pkg>) for this customer, except those on hold.
+
+Returns a list: an empty list on success or a list of errors.
 
 =cut
 
 sub unsuspend {
   my $self = shift;
-  grep { $_->unsuspend } $self->suspended_pkgs;
+  grep { ($_->get('setup')) && $_->unsuspend } $self->suspended_pkgs;
+}
+
+=item release_hold
+
+Unsuspends all suspended packages in the on-hold state (those without setup 
+dates) for this customer. 
+
+=cut
+
+sub release_hold {
+  my $self = shift;
+  grep { (!$_->setup) && $_->unsuspend } $self->suspended_pkgs;
 }
 
 =item suspend
diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm
index 6191eb8..2c41ecb 100644
--- a/FS/FS/cust_main/Billing.pm
+++ b/FS/FS/cust_main/Billing.pm
@@ -1088,6 +1088,16 @@ sub _make_lines {
   my $unitsetup = 0;
   my @setup_discounts = ();
   my %setup_param = ( 'discounts' => \@setup_discounts );
+  # Conditions for setting setup date and charging the setup fee:
+  # - this is not a recurring-only billing run
+  # - and the package is not currently being canceled
+  # - and, unless we're specifically told otherwise via 'resetup':
+  #   - it doesn't already HAVE a setup date
+  #   - or a start date in the future
+  #   - and it's not suspended
+  #
+  # The last condition used to check the "disable_setup_suspended" option but 
+  # that's obsolete. We now never set the setup date on a suspended package.
   if (     ! $options{recurring_only}
        and ! $options{cancel}
        and ( $options{'resetup'}
@@ -1095,12 +1105,8 @@ sub _make_lines {
                   && ( ! $cust_pkg->start_date
                        || $cust_pkg->start_date <= $cmp_time
                      )
-                  && ( ! $conf->exists('disable_setup_suspended_pkgs')
-                       || ( $conf->exists('disable_setup_suspended_pkgs') &&
-                            ! $cust_pkg->getfield('susp')
-                          )
-                     )
-                )
+                  && ( ! $cust_pkg->getfield('susp') )
+              )
            )
      )
   {
diff --git a/httemplate/misc/cust_main-unsuspend.cgi b/httemplate/misc/cust_main-unsuspend.cgi
index eb4a2c8..e8ac8d3 100755
--- a/httemplate/misc/cust_main-unsuspend.cgi
+++ b/httemplate/misc/cust_main-unsuspend.cgi
@@ -34,6 +34,10 @@ if($cgi->param('now_or_later')) {
   if($resume) {
     #warn "setting resume dates on custnum#$custnum\n";
     my @pkgs = $cust_main->suspended_pkgs;
+    if (!$cgi->param('release_hold')) {
+      # then avoid packages that are on hold
+      @pkgs = grep { $_->get('setup') } @pkgs;
+    }
     @errors = grep {$_} map { $_->unsuspend(
       'date'    => $resume,
     ) } @pkgs;
@@ -42,9 +46,13 @@ if($cgi->param('now_or_later')) {
     @errors = ("error parsing adjourn date: ".$cgi->param('adjourn'));
   }
 }
-else {
+else { # unsuspending now
   warn "unsuspending $cust_main";
   @errors = $cust_main->unsuspend;
+
+  if ( $cgi->param('release_hold') ) {
+    push @errors, $cust_main->release_hold;
+  }
 }
 my $error = join(' / ', @errors) if scalar(@errors);
 
diff --git a/httemplate/misc/unsuspend_cust.html b/httemplate/misc/unsuspend_cust.html
index 600eb26..4555a58 100644
--- a/httemplate/misc/unsuspend_cust.html
+++ b/httemplate/misc/unsuspend_cust.html
@@ -7,8 +7,7 @@
 
  <P ALIGN="center"><B><% mt('Unsuspend this customer?') |h %></B>
 
-<TABLE BORDER="0" CELLSPACING="2"
-STYLE="margin-left:auto; margin-right:auto">
+<TABLE BORDER="0" CELLSPACING="2" STYLE="margin-left:auto; margin-right:auto">
 <TR>
   <TD ALIGN="right">
     <INPUT TYPE="radio" NAME="now_or_later" VALUE="0" onclick="toggle(false)" CHECKED />
@@ -26,6 +25,21 @@ STYLE="margin-left:auto; margin-right:auto">
     }  &>
   </TD>
 </TR>
+% if ( $on_hold_pkgs > 0 ) {
+<TR>
+  <TD ALIGN="right">
+    <INPUT TYPE="checkbox" NAME="release_hold" VALUE="1" CHECKED \
+    <% $susp_pkgs == 0 ? 'DISABLED' : '' %> />
+
+  </TD>
+  <TD ALIGN="left">
+    <% emt('Activate [quant,_1,on-hold package,on-hold packages]', $on_hold_pkgs) %>
+  </TD>
+</TR>
+% }
+% if ( $susp_pkgs == 0 ) { # then always release holds, or this will do nothing
+  <INPUT TYPE="hidden" NAME="release_hold" VALUE="1">
+% }
 </TABLE>
 <SCRIPT type="text/javascript">
 function toggle(val) {
@@ -64,5 +78,13 @@ my $cust_main = qsearchs( {
 } );
 die "No customer # $custnum" unless $cust_main;
 
+my $susp_pkgs = FS::cust_pkg->count(
+  FS::cust_pkg->susp_sql . " AND custnum = ?", $custnum
+);
+
+my $on_hold_pkgs = FS::cust_pkg->count(
+  FS::cust_pkg->on_hold_sql . " AND custnum = ?", $custnum
+);
+
 </%init>
 
diff --git a/httemplate/view/cust_main/packages/status.html b/httemplate/view/cust_main/packages/status.html
index 9bd0079..339c2ab 100644
--- a/httemplate/view/cust_main/packages/status.html
+++ b/httemplate/view/cust_main/packages/status.html
@@ -48,7 +48,8 @@
 %
 %   if ( $cust_pkg->get('susp') ) { #suspended or on hold
 %
-%     if ( $cust_pkg->order_date eq $cust_pkg->get('susp') ) { #status: on hold
+%     #if ( $cust_pkg->order_date eq $cust_pkg->get('susp') ) { # inconsistent with FS::cust_pkg::status
+%     if ( ! $cust_pkg->setup ) { #status: on hold
 
         <% pkg_status_row( $cust_pkg, emt('On Hold'), '', 'color'=>'7E0079', %opt ) %>
 

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm                                  |    7 -------
 FS/FS/Record.pm                                |    4 ++--
 FS/FS/cust_main.pm                             |   19 ++++++++++++++---
 FS/FS/cust_main/Billing.pm                     |   18 ++++++++++------
 httemplate/misc/cust_main-unsuspend.cgi        |   10 ++++++++-
 httemplate/misc/unsuspend_cust.html            |   26 ++++++++++++++++++++++--
 httemplate/view/cust_main/packages/status.html |    3 ++-
 7 files changed, 65 insertions(+), 22 deletions(-)




More information about the freeside-commits mailing list