don't abort upgrade if a customer doesn't have an echeck cust_main.paytype. if it...
authorIvan Kohler <ivan@freeside.biz>
Fri, 27 Oct 2017 23:34:13 +0000 (16:34 -0700)
committerIvan Kohler <ivan@freeside.biz>
Fri, 27 Oct 2017 23:34:13 +0000 (16:34 -0700)
FS/FS/cust_main.pm

index 2b21cf1..d71ade0 100644 (file)
@@ -5773,15 +5773,17 @@ sub _upgrade_data { #class method
       # at the time we do this, also migrate paytype into cust_pay_batch
       # so that batches that are open before the migration can still be 
       # processed
-      my @cust_pay_batch = qsearch('cust_pay_batch', {
-          'custnum' => $cust_main->custnum,
-          'payby'   => 'CHEK',
-          'paytype' => '',
-      });
-      foreach my $cust_pay_batch (@cust_pay_batch) {
-        $cust_pay_batch->set('paytype', $cust_main->get('paytype'));
-        my $error = $cust_pay_batch->replace;
-        die "$error (setting cust_pay_batch.paytype)" if $error;
+      if ( $cust_main->get('paytype') ) {
+        my @cust_pay_batch = qsearch('cust_pay_batch', {
+            'custnum' => $cust_main->custnum,
+            'payby'   => 'CHEK',
+            'paytype' => '',
+        });
+        foreach my $cust_pay_batch (@cust_pay_batch) {
+          $cust_pay_batch->set('paytype', $cust_main->get('paytype'));
+          my $error = $cust_pay_batch->replace;
+          die "$error (setting cust_pay_batch.paytype)" if $error;
+        }
       }
 
       $cust_main->complimentary('Y') if $cust_main->payby eq 'COMP';