diff --git a/org.adempiere.base/src/org/compiere/process/DocumentEngine.java b/org.adempiere.base/src/org/compiere/process/DocumentEngine.java index 6b5d477132..79269bb6fe 100644 --- a/org.adempiere.base/src/org/compiere/process/DocumentEngine.java +++ b/org.adempiere.base/src/org/compiere/process/DocumentEngine.java @@ -903,10 +903,11 @@ public class DocumentEngine implements DocAction * @param AD_Table_ID * @param docAction * @param options + * @param periodOpen - flag indicating if the period is Open - to avoid including Void and ReverseCorrect options in the list * @return Number of valid options */ public static int getValidActions(String docStatus, Object processing, - String orderType, String isSOTrx, int AD_Table_ID, String[] docAction, String[] options) + String orderType, String isSOTrx, int AD_Table_ID, String[] docAction, String[] options, boolean periodOpen) { if (options == null) throw new IllegalArgumentException("Option array parameter is null"); @@ -1001,8 +1002,9 @@ public class DocumentEngine implements DocAction // Complete .. CO if (docStatus.equals(DocumentEngine.STATUS_Completed)) { - options[index++] = DocumentEngine.ACTION_Void; - options[index++] = DocumentEngine.ACTION_Reverse_Correct; + if (periodOpen) { + options[index++] = DocumentEngine.ACTION_Reverse_Correct; + } options[index++] = DocumentEngine.ACTION_Reverse_Accrual; } } @@ -1014,8 +1016,9 @@ public class DocumentEngine implements DocAction // Complete .. CO if (docStatus.equals(DocumentEngine.STATUS_Completed)) { - options[index++] = DocumentEngine.ACTION_Void; - options[index++] = DocumentEngine.ACTION_Reverse_Correct; + if (periodOpen) { + options[index++] = DocumentEngine.ACTION_Reverse_Correct; + } options[index++] = DocumentEngine.ACTION_Reverse_Accrual; } } @@ -1027,8 +1030,9 @@ public class DocumentEngine implements DocAction // Complete .. CO if (docStatus.equals(DocumentEngine.STATUS_Completed)) { - options[index++] = DocumentEngine.ACTION_Void; - options[index++] = DocumentEngine.ACTION_Reverse_Correct; + if (periodOpen) { + options[index++] = DocumentEngine.ACTION_Reverse_Correct; + } options[index++] = DocumentEngine.ACTION_Reverse_Accrual; } } @@ -1040,9 +1044,11 @@ public class DocumentEngine implements DocAction // Complete .. CO if (docStatus.equals(DocumentEngine.STATUS_Completed)) { - options[index++] = DocumentEngine.ACTION_Reverse_Correct; + if (periodOpen) { + options[index++] = DocumentEngine.ACTION_Reverse_Correct; + options[index++] = DocumentEngine.ACTION_ReActivate; + } options[index++] = DocumentEngine.ACTION_Reverse_Accrual; - options[index++] = DocumentEngine.ACTION_ReActivate; } } /******************** @@ -1053,8 +1059,9 @@ public class DocumentEngine implements DocAction // Complete .. CO if (docStatus.equals(DocumentEngine.STATUS_Completed)) { - options[index++] = DocumentEngine.ACTION_Void; - options[index++] = DocumentEngine.ACTION_Reverse_Correct; + if (periodOpen) { + options[index++] = DocumentEngine.ACTION_Reverse_Correct; + } options[index++] = DocumentEngine.ACTION_Reverse_Accrual; } } @@ -1078,7 +1085,9 @@ public class DocumentEngine implements DocAction // Complete .. CO if (docStatus.equals(DocumentEngine.STATUS_Completed)) { - options[index++] = DocumentEngine.ACTION_Void; + if (periodOpen) { + options[index++] = DocumentEngine.ACTION_Void; + } } } /******************** @@ -1090,8 +1099,9 @@ public class DocumentEngine implements DocAction // Complete .. CO if (docStatus.equals(DocumentEngine.STATUS_Completed)) { - options[index++] = DocumentEngine.ACTION_Void; - options[index++] = DocumentEngine.ACTION_Reverse_Correct; + if (periodOpen) { + options[index++] = DocumentEngine.ACTION_Reverse_Correct; + } options[index++] = DocumentEngine.ACTION_Reverse_Accrual; } } @@ -1129,8 +1139,9 @@ public class DocumentEngine implements DocAction // Complete .. CO else if (docStatus.equals(DocumentEngine.STATUS_Completed)) { - options[index++] = DocumentEngine.ACTION_Void; - options[index++] = DocumentEngine.ACTION_Reverse_Correct; + if (periodOpen) { + options[index++] = DocumentEngine.ACTION_Reverse_Correct; + } options[index++] = DocumentEngine.ACTION_Reverse_Accrual; } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java index 2ed270bf31..d07eb06aa2 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java @@ -39,9 +39,11 @@ import org.compiere.model.MAllocationHdr; import org.compiere.model.MBankStatement; import org.compiere.model.MClientInfo; import org.compiere.model.MDocType; +import org.compiere.model.MPeriod; import org.compiere.model.MProduction; import org.compiere.model.MTable; import org.compiere.model.PO; +import org.compiere.process.DocAction; import org.compiere.process.DocOptions; import org.compiere.process.DocumentEngine; import org.compiere.util.CLogger; @@ -65,8 +67,8 @@ public class WDocActionPanel extends Window implements EventListener, Dia /** * */ - private static final long serialVersionUID = -1467198100278350775L; - + private static final long serialVersionUID = -2166149559040327486L; + private Label lblDocAction; private Label label; private Listbox lstDocAction; @@ -159,12 +161,16 @@ public class WDocActionPanel extends Window implements EventListener, Dia * General Actions */ - String[] docActionHolder = new String[]{DocAction}; - index = DocumentEngine.getValidActions(DocStatus, Processing, OrderType, IsSOTrx, - m_AD_Table_ID, docActionHolder, options); - MTable table = MTable.get(Env.getCtx(), m_AD_Table_ID); PO po = table.getPO(gridTab.getRecord_ID(), null); + boolean periodOpen = true; + if (po instanceof DocAction) + periodOpen = MPeriod.isOpen(Env.getCtx(), m_AD_Table_ID, gridTab.getRecord_ID(), null); + + String[] docActionHolder = new String[]{DocAction}; + index = DocumentEngine.getValidActions(DocStatus, Processing, OrderType, IsSOTrx, + m_AD_Table_ID, docActionHolder, options, periodOpen); + if (po instanceof DocOptions) index = ((DocOptions) po).customizeValidActions(DocStatus, Processing, OrderType, IsSOTrx, m_AD_Table_ID, docActionHolder, options, index);