Fixes issue 21940: If there is a register without payment date
authorJavier Etxarri <javier.echarri@openbravo.com>
Tue, 29 Jan 2013 16:49:25 +0100
changeset 19500 ec8b28e3c0c0
parent 19499 f9caef056ea9
child 19501 81295cf8b1e8
Fixes issue 21940: If there is a register without payment date
the payment report shows NPE error
modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReportDao.java
--- a/modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReportDao.java	Tue Jan 29 16:07:40 2013 +0100
+++ b/modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReportDao.java	Tue Jan 29 16:49:25 2013 +0100
@@ -636,14 +636,16 @@
               .getPaymentDetails().getFinPayment().getPaymentMethod().getIdentifier());
 
           // payment
-          FieldProviderFactory.setField(
-              data[i],
-              "PAYMENT",
-              dateFormat.format(FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment()
-                  .getPaymentDate())
-                  + " - "
-                  + FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment()
-                      .getDocumentNo());
+          FieldProviderFactory
+              .setField(
+                  data[i],
+                  "PAYMENT",
+                  ((FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment()
+                      .getPaymentDate() != null) ? dateFormat.format(FIN_PaymentScheduleDetail[i]
+                      .getPaymentDetails().getFinPayment().getPaymentDate()) : "Null")
+                      + " - "
+                      + FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment()
+                          .getDocumentNo());
           // payment description
           FieldProviderFactory.setField(data[i], "PAYMENT_DESC", FIN_PaymentScheduleDetail[i]
               .getPaymentDetails().getFinPayment().getDescription());
@@ -651,11 +653,13 @@
           FieldProviderFactory.setField(data[i], "PAYMENT_ID", FIN_PaymentScheduleDetail[i]
               .getPaymentDetails().getFinPayment().getId().toString());
           // payment_date
-          FieldProviderFactory.setField(
-              data[i],
-              "PAYMENT_DATE",
-              dateFormat.format(FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment()
-                  .getPaymentDate()));
+          FieldProviderFactory
+              .setField(
+                  data[i],
+                  "PAYMENT_DATE",
+                  (FIN_PaymentScheduleDetail[i].getPaymentDetails().getFinPayment()
+                      .getPaymentDate() != null) ? dateFormat.format(FIN_PaymentScheduleDetail[i]
+                      .getPaymentDetails().getFinPayment().getPaymentDate()) : "Null");
           // payment_docNo
           FieldProviderFactory.setField(data[i], "PAYMENT_DOCNO", FIN_PaymentScheduleDetail[i]
               .getPaymentDetails().getFinPayment().getDocumentNo());
@@ -1843,8 +1847,9 @@
     FieldProviderFactory.setField(data, "PLANNED_DSO", String.valueOf(plannedDSO));
     // currentDSO
     if (fIN_PaymentScheduleDetail.getPaymentDetails() != null) {
-      currentDSO = (fIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment().getPaymentDate()
-          .getTime() - invoicedDate.getTime())
+      currentDSO = (((fIN_PaymentScheduleDetail.getPaymentDetails().getFinPayment()
+          .getPaymentDate() != null) ? fIN_PaymentScheduleDetail.getPaymentDetails()
+          .getFinPayment().getPaymentDate().getTime() : 0) - invoicedDate.getTime())
           / milisecDayConv;
     } else {
       currentTime = System.currentTimeMillis();