From aa580a443b51010e16d224d6bea102bcb0538e8f Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 8 May 2019 11:36:55 +0200 Subject: [PATCH] IDEMPIERE-3965 Allocation posted with error when multi-currency and immediate accounting --- .../src/org/compiere/model/MPayment.java | 26 ++++++++++++++++--- .../org/compiere/process/DocumentEngine.java | 7 ++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index a9a84d8edd..9ab8374dc3 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -22,6 +22,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Properties; @@ -83,8 +84,10 @@ import org.compiere.util.ValueNamePair; public class MPayment extends X_C_Payment implements DocAction, ProcessCall, PaymentInterface { - - private static final long serialVersionUID = -7179638016937305380L; + /** + * + */ + private static final long serialVersionUID = -6268462097642919346L; /** * Get Payments Of BPartner @@ -2111,6 +2114,16 @@ public class MPayment extends X_C_Payment return DocAction.STATUS_Completed; } // completeIt + /* Save array of documents to process AFTER completing this one */ + ArrayList docsPostProcess = new ArrayList(); + + protected void addDocsPostProcess(PO doc) { + docsPostProcess.add(doc); + } + + public ArrayList getDocsPostProcess() { + return docsPostProcess; + } /** * Set the definite document number after completed @@ -2289,6 +2302,7 @@ public class MPayment extends X_C_Payment // added AdempiereException by zuhri if (!alloc.processIt(DocAction.ACTION_Complete)) throw new AdempiereException(Msg.getMsg(getCtx(), "FailedProcessingDocument") + " - " + alloc.getProcessMsg()); + addDocsPostProcess(alloc); // end added m_processMsg = "@C_AllocationHdr_ID@: " + alloc.getDocumentNo(); return alloc.save(get_TrxName()); @@ -2324,6 +2338,7 @@ public class MPayment extends X_C_Payment // added AdempiereException by zuhri if (!alloc.processIt(DocAction.ACTION_Complete)) throw new AdempiereException(Msg.getMsg(getCtx(), "FailedProcessingDocument") + " - " + alloc.getProcessMsg()); + addDocsPostProcess(alloc); // end added alloc.saveEx(get_TrxName()); m_justCreatedAllocInv = alloc; @@ -2418,10 +2433,12 @@ public class MPayment extends X_C_Payment else { // added Adempiere Exception by zuhri - if(alloc.processIt(DocAction.ACTION_Complete)) + if (alloc.processIt(DocAction.ACTION_Complete)) { + addDocsPostProcess(alloc); ok = alloc.save(get_TrxName()); - else + } else { throw new AdempiereException(Msg.getMsg(getCtx(), "FailedProcessingDocument") + " - " + alloc.getProcessMsg()); + } // end added by zuhri m_processMsg = "@C_AllocationHdr_ID@: " + alloc.getDocumentNo(); } @@ -2709,6 +2726,7 @@ public class MPayment extends X_C_Payment // added AdempiereException by zuhri if (!alloc.processIt(DocAction.ACTION_Complete)) throw new AdempiereException(Msg.getMsg(getCtx(), "FailedProcessingDocument") + " - " + alloc.getProcessMsg()); + addDocsPostProcess(alloc); // end added alloc.saveEx(get_TrxName()); // diff --git a/org.adempiere.base/src/org/compiere/process/DocumentEngine.java b/org.adempiere.base/src/org/compiere/process/DocumentEngine.java index 4773229560..d8eb86d46b 100644 --- a/org.adempiere.base/src/org/compiere/process/DocumentEngine.java +++ b/org.adempiere.base/src/org/compiere/process/DocumentEngine.java @@ -323,12 +323,13 @@ public class DocumentEngine implements DocAction { // PostProcess documents when invoice or inout (this is to postprocess the generated MatchPO and MatchInv if any) ArrayList docsPostProcess = new ArrayList(); - if (m_document instanceof MInvoice || m_document instanceof MInOut) { + if (m_document instanceof MInvoice || m_document instanceof MInOut || m_document instanceof MPayment) { if (m_document instanceof MInvoice) { docsPostProcess = ((MInvoice) m_document).getDocsPostProcess(); - } - if (m_document instanceof MInOut) { + } else if (m_document instanceof MInOut) { docsPostProcess = ((MInOut) m_document).getDocsPostProcess(); + } else if (m_document instanceof MPayment) { + docsPostProcess = ((MPayment) m_document).getDocsPostProcess(); } } if (m_document instanceof PO && docsPostProcess.size() > 0) {