Fixed bug 25723 Is impossible to reconcile a transaction that it doesn't have a payment
authorSandra Huguet <sandra.huguet@openbravo.com>
Thu, 13 Feb 2014 13:30:22 +0100
changeset 22010 303f6522150c
parent 22009 b6dad5dc6d68
child 22011 e2e4ee246202
Fixed bug 25723 Is impossible to reconcile a transaction that it doesn't have a payment
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ReconciliationProcess.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ReconciliationProcess.java	Mon Feb 10 18:40:25 2014 +0530
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ReconciliationProcess.java	Thu Feb 13 13:30:22 2014 +0100
@@ -110,25 +110,26 @@
 
         Boolean invoicePaidold = false;
         for (FIN_FinaccTransaction finacctransaction : reconciliation.getFINFinaccTransactionList()) {
-          for (FIN_PaymentDetail pd : finacctransaction.getFinPayment().getFINPaymentDetailList()) {
-            for (FIN_PaymentScheduleDetail psd : pd.getFINPaymentScheduleDetailList()) {
-              invoicePaidold = psd.isInvoicePaid();
-              if (!invoicePaidold) {
-                if ((FIN_Utility.invoicePaymentStatus(finacctransaction.getFinPayment()
-                    .getPaymentMethod(), reconciliation.getAccount(), finacctransaction
-                    .getFinPayment().isReceipt()).equals(finacctransaction.getFinPayment()
-                    .getStatus()))) {
-                  psd.setInvoicePaid(true);
-                }
-                if (psd.isInvoicePaid()) {
-                  FIN_Utility.updatePaymentAmounts(psd);
+          if (finacctransaction.getFinPayment() != null) {
+            for (FIN_PaymentDetail pd : finacctransaction.getFinPayment().getFINPaymentDetailList()) {
+              for (FIN_PaymentScheduleDetail psd : pd.getFINPaymentScheduleDetailList()) {
+                invoicePaidold = psd.isInvoicePaid();
+                if (!invoicePaidold) {
+                  if ((FIN_Utility.invoicePaymentStatus(finacctransaction.getFinPayment()
+                      .getPaymentMethod(), reconciliation.getAccount(), finacctransaction
+                      .getFinPayment().isReceipt()).equals(finacctransaction.getFinPayment()
+                      .getStatus()))) {
+                    psd.setInvoicePaid(true);
+                  }
+                  if (psd.isInvoicePaid()) {
+                    FIN_Utility.updatePaymentAmounts(psd);
+                  }
                 }
               }
             }
+            FIN_Utility.updateBusinessPartnerCredit(finacctransaction.getFinPayment());
           }
-          FIN_Utility.updateBusinessPartnerCredit(finacctransaction.getFinPayment());
         }
-
         // ***********************
         // Reactivate Reconciliation
         // ***********************
@@ -162,21 +163,23 @@
         Boolean invoicePaidold = false;
 
         for (FIN_FinaccTransaction finacctransaction : reconciliation.getFINFinaccTransactionList()) {
-          for (FIN_PaymentDetail pd : finacctransaction.getFinPayment().getFINPaymentDetailList()) {
-            for (FIN_PaymentScheduleDetail psd : pd.getFINPaymentScheduleDetailList()) {
-              invoicePaidold = psd.isInvoicePaid();
-              if (invoicePaidold) {
-                if (FIN_Utility.invoicePaymentStatus(
-                    finacctransaction.getFinPayment().getPaymentMethod(),
-                    reconciliation.getAccount(), finacctransaction.getFinPayment().isReceipt())
-                    .equals(finacctransaction.getFinPayment().getStatus())) {
-                  boolean restore = (FIN_Utility.seqnumberpaymentstatus(finacctransaction
-                      .getFinPayment().getStatus())) <= (FIN_Utility
-                      .seqnumberpaymentstatus(FIN_Utility.invoicePaymentStatus(finacctransaction
-                          .getFinPayment().getPaymentMethod(), reconciliation.getAccount(),
-                          finacctransaction.getFinPayment().isReceipt())));
-                  if (restore) {
-                    FIN_Utility.restorePaidAmounts(psd);
+          if (finacctransaction.getFinPayment() != null) {
+            for (FIN_PaymentDetail pd : finacctransaction.getFinPayment().getFINPaymentDetailList()) {
+              for (FIN_PaymentScheduleDetail psd : pd.getFINPaymentScheduleDetailList()) {
+                invoicePaidold = psd.isInvoicePaid();
+                if (invoicePaidold) {
+                  if (FIN_Utility.invoicePaymentStatus(
+                      finacctransaction.getFinPayment().getPaymentMethod(),
+                      reconciliation.getAccount(), finacctransaction.getFinPayment().isReceipt())
+                      .equals(finacctransaction.getFinPayment().getStatus())) {
+                    boolean restore = (FIN_Utility.seqnumberpaymentstatus(finacctransaction
+                        .getFinPayment().getStatus())) <= (FIN_Utility
+                        .seqnumberpaymentstatus(FIN_Utility.invoicePaymentStatus(finacctransaction
+                            .getFinPayment().getPaymentMethod(), reconciliation.getAccount(),
+                            finacctransaction.getFinPayment().isReceipt())));
+                    if (restore) {
+                      FIN_Utility.restorePaidAmounts(psd);
+                    }
                   }
                 }
               }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java	Mon Feb 10 18:40:25 2014 +0530
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java	Thu Feb 13 13:30:22 2014 +0100
@@ -1382,6 +1382,9 @@
   }
 
   public static void updateBusinessPartnerCredit(FIN_Payment payment) {
+    if (payment == null) {
+      return;
+    }
     // When credit is used (consumed) we compensate so_creditused as this amount is already
     // included in the payment details. Credit consumed should not affect to so_creditused
     if (payment.getGeneratedCredit().compareTo(BigDecimal.ZERO) == 0