[freeside-commits] branch master updated. 903a18a39978770c60c6334c9342831be426cec5

Mark Wells mark at 420.am
Wed May 7 23:35:34 PDT 2014


The branch, master has been updated
       via  903a18a39978770c60c6334c9342831be426cec5 (commit)
      from  ba638765b1c8a27e8d1da8074b285a93f4a8241e (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 903a18a39978770c60c6334c9342831be426cec5
Author: Mark Wells <mark at freeside.biz>
Date:   Wed May 7 23:35:28 2014 -0700

    run time-consuming cust_pay upgrade from the job queue, #29017

diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index ca681e6..e3670db 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -899,7 +899,7 @@ sub unapplied_sql {
 use FS::h_cust_pay;
 
 sub _upgrade_data {  #class method
-  my ($class, %opts) = @_;
+  my ($class, %opt) = @_;
 
   warn "$me upgrading $class\n" if $DEBUG;
 
@@ -1013,9 +1013,33 @@ sub _upgrade_data {  #class method
   ###
 
   delete $FS::payby::hash{'COMP'}->{cust_pay}; #quelle kludge
-  $class->_upgrade_otaker(%opts);
+  $class->_upgrade_otaker(%opt);
   $FS::payby::hash{'COMP'}->{cust_pay} = ''; #restore it
 
+  # if we do this anywhere else, it should become an FS::Upgrade method
+  my $num_to_upgrade = $class->count('paybatch is not null');
+  my $num_jobs = FS::queue->count('job = \'FS::cust_pay::process_upgrade_paybatch\' and status != \'failed\'');
+  if ( $num_to_upgrade > 0 ) {
+    warn "Need to migrate paybatch field in $num_to_upgrade payments.\n";
+    if ( $opt{queue} ) {
+      if ( $num_jobs > 0 ) {
+        warn "Upgrade already queued.\n";
+      } else {
+        warn "Scheduling upgrade.\n";
+        my $job = FS::queue->new({ job => 'FS::cust_pay::process_upgrade_paybatch' });
+        $job->insert;
+      }
+    } else {
+      process_upgrade_paybatch();
+    }
+  }
+}
+
+sub process_upgrade_paybatch {
+  my $dbh = dbh;
+  local $FS::payinfo_Mixin::ignore_masked_payinfo = 1;
+  local $FS::UID::AutoCommit = 1;
+
   ###
   # migrate batchnums from the misused 'paybatch' field to 'batchnum'
   ###

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

Summary of changes:
 FS/FS/cust_pay.pm |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)




More information about the freeside-commits mailing list