[freeside-commits] branch master updated. 35ac50b0ff66fc78aaa11baf8ae0199280645b96

Ivan ivan at 420.am
Fri Sep 1 09:35:18 PDT 2017


The branch, master has been updated
       via  35ac50b0ff66fc78aaa11baf8ae0199280645b96 (commit)
       via  d32566e41c62a65a07a0c1978468583c78d96516 (commit)
      from  cfe0406764d057feeea74b676acc08917fa23f26 (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 35ac50b0ff66fc78aaa11baf8ae0199280645b96
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Aug 31 17:14:36 2017 -0700

    recover customer locations from history, RT#77268

diff --git a/bin/recover-cust_location b/bin/recover-cust_location
new file mode 100755
index 0000000..6318eb3
--- /dev/null
+++ b/bin/recover-cust_location
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use FS::UID qw( adminsuidsetup );
+use FS::Record qw( qsearchs );
+use FS::h_cust_location;
+use FS::cust_location;
+
+adminsuidsetup shift or &usage;
+my $start = shift or &usage;
+my $end = shift or &usage;
+
+for my $locationnum ( $start .. $end ) {
+
+  my $h_cust_location = qsearchs({
+    'table'     => 'h_cust_location',  
+    'hashref'   => { 'locationnum' => $locationnum, },
+    'extra_sql' => " AND ( history_action = 'insert' OR history_action = 'replace_new' )",
+    'order_by'  => 'ORDER BY historynum DESC LIMIT 1',
+  })
+    or die "h_cust_location for $locationnum not found\n";
+
+  warn "recovering cust_locaiton $locationnum\n";
+  my $cust_location = new FS::cust_location { $h_cust_location->hash };
+  my $error = $cust_location->insert;
+  die $error if $error;
+
+}
+
+sub usage {
+  die "Usage: recover-cust_location username start_locationnum end_locationnum\n";
+}

commit d32566e41c62a65a07a0c1978468583c78d96516
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Aug 31 12:43:01 2017 -0700

    saving the rebill script from #77140 in case we need something similar in the future

diff --git a/bin/cust_main-email_and_rebill b/bin/cust_main-email_and_rebill
new file mode 100644
index 0000000..dea1319
--- /dev/null
+++ b/bin/cust_main-email_and_rebill
@@ -0,0 +1,73 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Date::Parse;
+use FS::UID qw( adminsuidsetup );
+use FS::Record qw( qsearchs );
+use FS::cust_pkg;
+use FS::msg_template;
+
+adminsuidsetup shift or die 'Usage: cust_main-email_and_rebill username\n';
+
+my $DRY_RUN = 1;
+my $msgnum = 17;
+
+my $sep1 = str2time('9/1/2017');
+my $aug15 = str2time('8/15/2017') + 1802;
+
+my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
+  or die "unknown msg_template $msgnum\n";
+
+while (<>) {
+  chomp;
+  my $pkgnum = $_;
+
+  #find the package
+  my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum'=>$pkgnum } )
+    or die "pkgnum $pkgnum not found\n";
+
+  #reset its next bill date back to sep 1
+  $cust_pkg->set('bill', $sep1);
+  unless ( $DRY_RUN ) {
+    warn "updating cust_pkg $pkgnum bill to $sep1\n";
+    my $error = $cust_pkg->replace;
+    die $error if $error;
+  } else {
+    warn "DRY RUN: would update cust_pkg $pkgnum bill to $sep1\n";
+  }
+
+  #customer
+  my $cust_main = $cust_pkg->cust_main;
+  my $custnum = $cust_main->custnum;
+
+  #send the custoemr a notice
+  unless ( $DRY_RUN ) {
+    warn "emailing msg_template $msgnum to customer $custnum\n";
+    $msg_template->send( 'cust_main' => $cust_main,
+                         'object'    => $cust_main,
+                       );
+  } else {
+    warn "DRY RUN: emailing msg_template $msgnum to customer $custnum\n";
+  }
+
+  #bill the package
+  unless ( $DRY_RUN ) {
+    warn "billing customer $custnum for package $pkgnum as of $sep1\n";
+    $cust_main->bill( 'time'         => $sep1,
+                      'invoice_time' => $aug15,
+                      'pkg_list'     => [ $cust_pkg ],
+                    );
+  } else {
+    warn "DRY RUN: billing customer $custnum for package $pkgnum as of $sep1\n";
+  }
+
+  #something about removing their pending batch payment??
+  #hmm, there doesn't appear to be anything in a batch
+  #dating the invoices aug 15th will ensure payments for them are batched
+
+  #events will take care of the rest...
+
+}
+
+1;

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

Summary of changes:
 bin/cust_main-email_and_rebill |   73 ++++++++++++++++++++++++++++++++++++++++
 bin/recover-cust_location      |   33 ++++++++++++++++++
 2 files changed, 106 insertions(+)
 create mode 100644 bin/cust_main-email_and_rebill
 create mode 100755 bin/recover-cust_location




More information about the freeside-commits mailing list