IDEMPIERE-5081 add IDocsPostProcess interface (#1035)

This commit is contained in:
hengsin 2021-12-07 19:32:14 +08:00 committed by GitHub
parent 6637f549d7
commit 40462f674b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 60 additions and 17 deletions

View File

@ -39,6 +39,7 @@ import org.compiere.print.MPrintFormat;
import org.compiere.print.ReportEngine;
import org.compiere.process.DocAction;
import org.compiere.process.DocumentEngine;
import org.compiere.process.IDocsPostProcess;
import org.compiere.process.ProcessInfo;
import org.compiere.process.ServerProcessCtl;
import org.compiere.util.CLogger;
@ -67,7 +68,7 @@ import org.compiere.util.TimeUtil;
* <li>BF [ 2993853 ] Voiding/Reversing Receipt should void confirmations
* https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2993853&group_id=176962
*/
public class MInOut extends X_M_InOut implements DocAction
public class MInOut extends X_M_InOut implements DocAction, IDocsPostProcess
{
/**
*
@ -1801,7 +1802,8 @@ public class MInOut extends X_M_InOut implements DocAction
docsPostProcess.add(doc);
}
public ArrayList<PO> getDocsPostProcess() {
@Override
public List<PO> getDocsPostProcess() {
return docsPostProcess;
}

View File

@ -40,6 +40,7 @@ import org.compiere.print.MPrintFormat;
import org.compiere.print.ReportEngine;
import org.compiere.process.DocAction;
import org.compiere.process.DocumentEngine;
import org.compiere.process.IDocsPostProcess;
import org.compiere.process.ProcessInfo;
import org.compiere.process.ServerProcessCtl;
import org.compiere.util.CLogger;
@ -66,7 +67,7 @@ import org.eevolution.model.MPPProductBOMLine;
* Modifications: Added RMA functionality (Ashley Ramdass)
* Modifications: Generate DocNo^ instead of using a new number whan an invoice is reversed (Diego Ruiz-globalqss)
*/
public class MInvoice extends X_C_Invoice implements DocAction
public class MInvoice extends X_C_Invoice implements DocAction, IDocsPostProcess
{
/**
*
@ -2236,7 +2237,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
docsPostProcess.add(doc);
}
public ArrayList<PO> getDocsPostProcess() {
@Override
public List<PO> getDocsPostProcess() {
return docsPostProcess;
}

View File

@ -34,6 +34,7 @@ import org.adempiere.util.IProcessUI;
import org.adempiere.util.PaymentUtil;
import org.compiere.process.DocAction;
import org.compiere.process.DocumentEngine;
import org.compiere.process.IDocsPostProcess;
import org.compiere.process.ProcessCall;
import org.compiere.process.ProcessInfo;
import org.compiere.util.CLogger;
@ -82,7 +83,7 @@ import org.compiere.util.ValueNamePair;
* @version $Id: MPayment.java,v 1.4 2006/10/02 05:18:39 jjanke Exp $
*/
public class MPayment extends X_C_Payment
implements DocAction, ProcessCall, PaymentInterface
implements DocAction, ProcessCall, PaymentInterface, IDocsPostProcess
{
/**
*
@ -2162,7 +2163,8 @@ public class MPayment extends X_C_Payment
docsPostProcess.add(doc);
}
public ArrayList<PO> getDocsPostProcess() {
@Override
public List<PO> getDocsPostProcess() {
return docsPostProcess;
}

View File

@ -23,6 +23,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
@ -328,15 +329,9 @@ public class DocumentEngine implements DocAction
if (m_document != null && ok)
{
// PostProcess documents when invoice or inout (this is to postprocess the generated MatchPO and MatchInv if any)
ArrayList<PO> docsPostProcess = new ArrayList<PO>();
if (m_document instanceof MInvoice || m_document instanceof MInOut || m_document instanceof MPayment) {
if (m_document instanceof MInvoice) {
docsPostProcess = ((MInvoice) m_document).getDocsPostProcess();
} else if (m_document instanceof MInOut) {
docsPostProcess = ((MInOut) m_document).getDocsPostProcess();
} else if (m_document instanceof MPayment) {
docsPostProcess = ((MPayment) m_document).getDocsPostProcess();
}
List<PO> docsPostProcess = new ArrayList<PO>();
if (m_document instanceof IDocsPostProcess) {
docsPostProcess = ((IDocsPostProcess) m_document).getDocsPostProcess();
}
if (m_document instanceof PO && docsPostProcess.size() > 0) {
// Process (this is to update the ProcessedOn flag with a timestamp after the original document)

View File

@ -0,0 +1,42 @@
/***********************************************************************
* This file is part of iDempiere ERP Open Source *
* http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - hengsin *
**********************************************************************/
package org.compiere.process;
import java.util.List;
import org.compiere.model.PO;
/**
*
* @author hengsin
*
*/
public interface IDocsPostProcess {
/**
*
* @return List of doc to process after Complete
*/
public List<PO> getDocsPostProcess();
}

View File

@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.LogRecord;
import org.compiere.model.MBPartner;
@ -126,7 +126,7 @@ public class InvoiceCustomerTest extends AbstractTestCase {
assertEquals(false, invoice.isPaid(), "Invoice isPaid() is not false");
assertTrue(payment1.isPosted(), "Payment not posted");
ArrayList<PO> postProcessDocs = payment1.getDocsPostProcess();
List<PO> postProcessDocs = payment1.getDocsPostProcess();
for(PO postProcessDoc : postProcessDocs) {
assertTrue(postProcessDoc.get_ValueAsBoolean("Posted"), "Post Process Doc not posted: " + postProcessDoc);
}