# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1561983291 -19800
#      Mon Jul 01 17:44:51 2019 +0530
# Node ID 4811c80ae54e04a3ea7c7490a641810551fc93bc
# Parent  26060c0f2662e017d42ac35e09bb78e0084d2bf1
Related to issue 41203 : Invoice Payment schedule should be validated before creating payment terms

diff -r 26060c0f2662 -r 4811c80ae54e src/org/openbravo/retail/posterminal/utility/InvoiceUtils.java
--- a/src/org/openbravo/retail/posterminal/utility/InvoiceUtils.java	Mon Jul 01 14:47:28 2019 +0530
+++ b/src/org/openbravo/retail/posterminal/utility/InvoiceUtils.java	Mon Jul 01 17:44:51 2019 +0530
@@ -744,6 +744,10 @@
   }
 
   public void createPaymentTerms(Order order, Invoice invoice) {
+    if (invoice.getFINPaymentScheduleList() == null
+        || invoice.getFINPaymentScheduleList().isEmpty()) {
+      return;
+    }
     final FIN_PaymentSchedule paymentSchedule = order.getFINPaymentScheduleList().get(0);
     final FIN_PaymentSchedule paymentScheduleInvoice = invoice.getFINPaymentScheduleList().get(0);
     final OBCriteria<FIN_PaymentScheduleDetail> remainingPSDCriteria = OBDal.getInstance()
