From 68a77749fe796c41c650fae2fd3b8e9bb6baa2fb Mon Sep 17 00:00:00 2001
From: "christophe.dehen@openbravo.com" <christophe.dehen@openbravo.com>
Date: Mon, 21 Sep 2020 15:50:50 +0200
Subject: [PATCH] Fix NullPointer when you have a ticket without payment

---
 .../erpCommon/businessUtility/ReplaceOrderExecutor.java    | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/org/openbravo/erpCommon/businessUtility/ReplaceOrderExecutor.java b/src/org/openbravo/erpCommon/businessUtility/ReplaceOrderExecutor.java
index f76e1db14c..135dd26afe 100644
--- a/src/org/openbravo/erpCommon/businessUtility/ReplaceOrderExecutor.java
+++ b/src/org/openbravo/erpCommon/businessUtility/ReplaceOrderExecutor.java
@@ -877,8 +877,11 @@ class ReplaceOrderExecutor extends CancelAndReplaceUtils {
       // Get the payment schedule of the new order to check the outstanding amount, could
       // have been automatically paid on C_ORDER_POST if is automatically invoiced and the
       // payment method of the financial account is configured as 'Automatic Receipt'
-      final BigDecimal newOutstandingAmount = getPaymentScheduleOfOrder(newOrder)
-          .getOutstandingAmount();
+      FIN_PaymentSchedule ps = getPaymentScheduleOfOrder(newOrder);
+      BigDecimal newOutstandingAmount = BigDecimal.ZERO;
+      if (ps != null) {
+        newOutstandingAmount = ps.getOutstandingAmount();
+      }
       final BigDecimal newPaidAmount = lastOrder ? paidAmount
           : paidAmount.min(newOutstandingAmount);
       final boolean createPayments = areTriggersDisabled(jsonOrder)
-- 
GitLab

