diff --git a/base/src/org/compiere/model/MInOut.java b/base/src/org/compiere/model/MInOut.java
index baa42edd35..28cdf730de 100644
--- a/base/src/org/compiere/model/MInOut.java
+++ b/base/src/org/compiere/model/MInOut.java
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
+import org.adempiere.exceptions.AdempiereException;
import org.compiere.print.ReportEngine;
import org.compiere.process.DocAction;
import org.compiere.process.DocumentEngine;
@@ -49,6 +50,9 @@ import org.compiere.util.Msg;
* @author Armen Rizal, Goodwill Consulting
*
BF [ 1745154 ] Cost in Reversing Material Related Docs
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
+ * @author Teo Sarca, teo.sarca@gmail.com
+ * 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
{
@@ -919,6 +923,19 @@ public class MInOut extends X_M_InOut implements DocAction
else if (ship)
MInOutConfirm.create (this, MInOutConfirm.CONFIRMTYPE_ShipReceiptConfirm, true);
} // createConfirmation
+
+ private void voidConfirmations()
+ {
+ for(MInOutConfirm confirm : getConfirmations(true))
+ {
+ if (!confirm.isProcessed())
+ {
+ if (!confirm.processIt(MInOutConfirm.DOCACTION_Void))
+ throw new AdempiereException(confirm.getProcessMsg());
+ confirm.saveEx();
+ }
+ }
+ }
/**
@@ -1922,6 +1939,11 @@ public class MInOut extends X_M_InOut implements DocAction
line.save(get_TrxName());
}
}
+ //
+ // Void Confirmations
+ setDocStatus(DOCSTATUS_Voided); // need to set & save docstatus to be able to check it in MInOutConfirm.voidIt()
+ saveEx();
+ voidConfirmations();
}
else
{
@@ -2068,6 +2090,12 @@ public class MInOut extends X_M_InOut implements DocAction
reversal.saveEx(get_TrxName());
//
addDescription("(" + reversal.getDocumentNo() + "<-)");
+
+ //
+ // Void Confirmations
+ setDocStatus(DOCSTATUS_Reversed); // need to set & save docstatus to be able to check it in MInOutConfirm.voidIt()
+ saveEx();
+ voidConfirmations();
// After reverseCorrect
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT);
diff --git a/base/src/org/compiere/model/MInOutConfirm.java b/base/src/org/compiere/model/MInOutConfirm.java
index 29c027ca58..b9a11de905 100644
--- a/base/src/org/compiere/model/MInOutConfirm.java
+++ b/base/src/org/compiere/model/MInOutConfirm.java
@@ -40,6 +40,9 @@ import org.compiere.util.Msg;
* @author Teo Sarca, www.arhipac.ro
* BF [ 2800460 ] System generate Material Receipt with no lines
* https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2800460&group_id=176962
+ * @author Teo Sarca, teo.sarca@gmail.com
+ * BF [ 2993853 ] Voiding/Reversing Receipt should void confirmations
+ * https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2993853&group_id=176962
*/
public class MInOutConfirm extends X_M_InOutConfirm implements DocAction
{
@@ -525,7 +528,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction
m_processMsg = "Split @M_InOut_ID@=" + split.getDocumentNo()
+ " - @M_InOutConfirm_ID@=";
-
+
// Create Dispute Confirmation
if (!split.processIt(DocAction.ACTION_Prepare))
throw new AdempiereException(split.getProcessMsg());
@@ -645,12 +648,53 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID);
if (m_processMsg != null)
return false;
+
+ if (DOCSTATUS_Closed.equals(getDocStatus())
+ || DOCSTATUS_Reversed.equals(getDocStatus())
+ || DOCSTATUS_Voided.equals(getDocStatus()))
+ {
+ m_processMsg = "Document Closed: " + getDocStatus();
+ return false;
+ }
+
+ // Not Processed
+ if (DOCSTATUS_Drafted.equals(getDocStatus())
+ || DOCSTATUS_Invalid.equals(getDocStatus())
+ || DOCSTATUS_InProgress.equals(getDocStatus())
+ || DOCSTATUS_Approved.equals(getDocStatus())
+ || DOCSTATUS_NotApproved.equals(getDocStatus()) )
+ {
+ MInOut inout = (MInOut)getM_InOut();
+ if (!MInOut.DOCSTATUS_Voided.equals(inout.getDocStatus())
+ && !MInOut.DOCSTATUS_Reversed.equals(inout.getDocStatus()) )
+ {
+ throw new AdempiereException("@M_InOut_ID@ @DocStatus@<>VO");
+ }
+ for (MInOutLineConfirm confirmLine : getLines(true))
+ {
+ confirmLine.setTargetQty(Env.ZERO);
+ confirmLine.setConfirmedQty(Env.ZERO);
+ confirmLine.setScrappedQty(Env.ZERO);
+ confirmLine.setDifferenceQty(Env.ZERO);
+ confirmLine.setProcessed(true);
+ confirmLine.saveEx();
+ }
+ setIsCancelled(true);
+ }
+ else
+ {
+ return reverseCorrectIt();
+ }
+
// After Void
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID);
if (m_processMsg != null)
return false;
- return false;
+ setProcessed(true);
+ setDocAction(DOCACTION_None);
+
+ return true;
} // voidIt
/**