[freeside-commits] branch master updated. 6c853dd55563ae035c1bf17695d3cb2ad3452110

Mark Wells mark at 420.am
Tue May 31 12:48:11 PDT 2016


The branch, master has been updated
       via  6c853dd55563ae035c1bf17695d3cb2ad3452110 (commit)
       via  099cd9cd6b789ad0ee4ce7d9ac8721ccce69b8dd (commit)
      from  10b49cdbb4b4290f82ef08a035a84747b8cd2211 (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 6c853dd55563ae035c1bf17695d3cb2ad3452110
Author: Mark Wells <mark at freeside.biz>
Date:   Tue May 31 12:39:50 2016 -0700

    typo

diff --git a/httemplate/elements/tr-select-cust-part_pkg.html b/httemplate/elements/tr-select-cust-part_pkg.html
index 6244b6c..f4af405 100644
--- a/httemplate/elements/tr-select-cust-part_pkg.html
+++ b/httemplate/elements/tr-select-cust-part_pkg.html
@@ -86,7 +86,7 @@
   </TR>
 
 % } else { # so that the rest of the page works correctly
-  <INPUT TYPE="hidden" ID="classnum" NAME="classnum" VALUE="-1`">
+  <INPUT TYPE="hidden" ID="classnum" NAME="classnum" VALUE="-1">
 % }
 
 <TR>

commit 099cd9cd6b789ad0ee4ce7d9ac8721ccce69b8dd
Author: Mark Wells <mark at freeside.biz>
Date:   Tue May 31 12:39:43 2016 -0700

    fix change_later vs. new package locations, #42397

diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 1cc8235..d15eb89 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -2537,6 +2537,16 @@ sub change_later {
     return "start_date $date is in the past";
   }
 
+  # If the user entered a new location, set it up now.
+  if ( $opt->{'cust_location'} ) {
+    $error = $opt->{'cust_location'}->find_or_insert;
+    if ( $error ) {
+      $dbh->rollback if $oldAutoCommit;
+      return "creating location record: $error";
+    }
+    $opt->{'locationnum'} = $opt->{'cust_location'}->locationnum;
+  }
+
   if ( $self->change_to_pkgnum ) {
     my $change_to = FS::cust_pkg->by_key($self->change_to_pkgnum);
     my $new_pkgpart = $opt->{'pkgpart'}
diff --git a/FS/t/suite/07-pkg_change_location.t b/FS/t/suite/07-pkg_change_location.t
new file mode 100755
index 0000000..6744f78
--- /dev/null
+++ b/FS/t/suite/07-pkg_change_location.t
@@ -0,0 +1,82 @@
+#!/usr/bin/perl
+
+=head2 DESCRIPTION
+
+Test scheduling a package location change through the UI, then billing
+on the day of the scheduled change.
+
+=cut
+
+use Test::More tests => 6;
+use FS::Test;
+use Date::Parse 'str2time';
+use Date::Format 'time2str';
+use Test::MockTime qw(set_fixed_time);
+use FS::cust_pkg;
+my $FS = FS::Test->new;
+my $error;
+
+# set up a customer with an active package
+my $cust = $FS->new_customer('Future location change');
+$error = $cust->insert;
+my $pkg = FS::cust_pkg->new({pkgpart => 2});
+$error ||= $cust->order_pkg({ cust_pkg => $pkg });
+my $date = str2time('2016-04-01');
+set_fixed_time($date);
+$error ||= $cust->bill_and_collect;
+BAIL_OUT($error) if $error;
+
+# get the form
+my %args = ( pkgnum  => $pkg->pkgnum,
+             pkgpart => $pkg->pkgpart,
+             locationnum => -1);
+$FS->post('/misc/change_pkg.cgi', %args);
+my $form = $FS->form('OrderPkgForm');
+
+# Schedule the package change two days from now.
+$date += 86400*2;
+my $date_str = time2str('%x', $date);
+
+my %params = (
+  start_date              => $date_str,
+  delay                   => 1,
+  address1                => int(rand(1000)) . ' Changed Street',
+  city                    => 'New City',
+  state                   => 'CA',
+  zip                     => '90001',
+  country                 => 'US',
+);
+
+diag "requesting location change to $params{address1}";
+
+foreach (keys %params) {
+  $form->value($_, $params{$_});
+}
+$FS->post($form);
+ok( $FS->error eq '' , 'form posted' );
+if ( ok( $FS->page =~ m[location.reload], 'location change accepted' )) {
+  #nothing
+} else {
+  $FS->post($FS->redirect);
+  BAIL_OUT( $FS->error);
+}
+# check that the package change is set
+$pkg = $pkg->replace_old;
+my $new_pkgnum = $pkg->change_to_pkgnum;
+ok( $new_pkgnum, 'package change is scheduled' );
+
+# run it and check that the package change happened
+diag("billing customer on $date_str");
+set_fixed_time($date);
+my $error = $cust->bill_and_collect;
+BAIL_OUT($error) if $error;
+
+$pkg = $pkg->replace_old;
+ok($pkg->get('cancel'), "old package is canceled");
+my $new_pkg = $FS->qsearchs('cust_pkg', { pkgnum => $new_pkgnum });
+ok($new_pkg->setup, "new package is active");
+ok($new_pkg->cust_location->address1 eq $params{'address1'}, "new location is correct")
+  or diag $new_pkg->cust_location->address1;
+
+1;
+

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

Summary of changes:
 FS/FS/cust_pkg.pm                                |   10 +++
 FS/t/suite/07-pkg_change_location.t              |   82 ++++++++++++++++++++++
 httemplate/elements/tr-select-cust-part_pkg.html |    2 +-
 3 files changed, 93 insertions(+), 1 deletion(-)
 create mode 100755 FS/t/suite/07-pkg_change_location.t




More information about the freeside-commits mailing list