RT# 81608 Improved error msg for Bill Now
authorMitch Jackson <mitch@freeside.biz>
Thu, 8 Nov 2018 19:12:13 +0000 (14:12 -0500)
committerMitch Jackson <mitch@freeside.biz>
Thu, 8 Nov 2018 19:15:06 +0000 (14:15 -0500)
Update Bill Now to throw an appropriate error
message to user if they try to use Bill Now
on a customer with pending package expiration

FS/FS/cust_main.pm

index fb4b153..cc0e83f 100644 (file)
@@ -5429,7 +5429,13 @@ sub process_bill_and_collect {
   $param->{'fatal'} = 1; # runs from job queue, will be caught
   $param->{'retry'} = 1;
 
   $param->{'fatal'} = 1; # runs from job queue, will be caught
   $param->{'retry'} = 1;
 
-  $cust_main->bill_and_collect( %$param );
+  local $@;
+  eval { $cust_main->bill_and_collect( %$param) };
+  if ( $@ ) {
+    die $@ =~ /cancel_pkgs cannot be run inside a transaction/
+      ? "Bill Now unavailable for customer with pending package expiration\n"
+      : $@;
+  }
 }
 
 =item pending_invoice_count
 }
 
 =item pending_invoice_count