[freeside-commits] branch master updated. 2f1d603f47befaef66b15f0c2ae459d5a6fdbe0e

Mark Wells mark at 420.am
Wed Apr 22 14:21:30 PDT 2015


The branch, master has been updated
       via  2f1d603f47befaef66b15f0c2ae459d5a6fdbe0e (commit)
      from  e8e6cb9e129eb20fef8e4fa19239c76b4280cf5f (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 2f1d603f47befaef66b15f0c2ae459d5a6fdbe0e
Author: Mark Wells <mark at freeside.biz>
Date:   Wed Apr 22 14:21:24 2015 -0700

    retain suspend/resume dates across all package changes of any kind, #34406

diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 3e87aad..6b9a846 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -2039,14 +2039,15 @@ sub change {
   }
 
   if ( $keep_dates ) {
-    foreach my $date ( qw(setup bill last_bill susp adjourn cancel expire 
-                          resume start_date contract_end ) ) {
+    foreach my $date ( qw(setup bill last_bill) ) {
       $hash{$date} = $self->getfield($date);
     }
   }
-  # always keep this date, regardless of anything
-  # (the date of the package change is in a different field)
-  $hash{'order_date'} = $self->getfield('order_date');
+  # always keep the following dates
+  foreach my $date (qw(order_date susp adjourn cancel expire resume 
+                    start_date contract_end)) {
+    $hash{$date} = $self->getfield($date);
+  }
 
   # allow $opt->{'locationnum'} = '' to specifically set it to null
   # (i.e. customer default location)
@@ -2082,19 +2083,15 @@ sub change {
     # changed from this package.
     $cust_pkg = $opt->{'cust_pkg'};
 
-    foreach ( qw( pkgnum pkgpart locationnum ) ) {
-      $cust_pkg->set("change_$_", $self->get($_));
+    # follow all the above rules for date changes, etc.
+    foreach (keys %hash) {
+      $cust_pkg->set($_, $hash{$_});
     }
-    $cust_pkg->set('change_date', $time);
-    $cust_pkg->set('start_date', ''); # it's starting now
-    # if we are crediting unused time, then create the new package as a new
-    # package, charge its setup fee, etc. (same as an immediate change)
-    if (! $unused_credit) {
-      foreach my $date ( qw(setup bill last_bill susp adjourn resume 
-                            contract_end ) ) {
-        $cust_pkg->set($date, $self->getfield($date));
-      }
+    # except those that implement the future package change behavior
+    foreach (qw(change_to_pkgnum start_date expire)) {
+      $cust_pkg->set($_, '');
     }
+
     $error = $cust_pkg->replace;
 
   } else {

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

Summary of changes:
 FS/FS/cust_pkg.pm |   29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)




More information about the freeside-commits mailing list