IDEMPIERE-2687 Void a Document on Closed Period

This commit is contained in:
Carlos Ruiz 2015-06-22 14:17:53 -05:00
parent ccc2d90e8c
commit 274a8bf748
2 changed files with 39 additions and 22 deletions

View File

@ -903,10 +903,11 @@ public class DocumentEngine implements DocAction
* @param AD_Table_ID * @param AD_Table_ID
* @param docAction * @param docAction
* @param options * @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 * @return Number of valid options
*/ */
public static int getValidActions(String docStatus, Object processing, 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) if (options == null)
throw new IllegalArgumentException("Option array parameter is null"); throw new IllegalArgumentException("Option array parameter is null");
@ -1001,8 +1002,9 @@ public class DocumentEngine implements DocAction
// Complete .. CO // Complete .. CO
if (docStatus.equals(DocumentEngine.STATUS_Completed)) if (docStatus.equals(DocumentEngine.STATUS_Completed))
{ {
options[index++] = DocumentEngine.ACTION_Void; if (periodOpen) {
options[index++] = DocumentEngine.ACTION_Reverse_Correct; options[index++] = DocumentEngine.ACTION_Reverse_Correct;
}
options[index++] = DocumentEngine.ACTION_Reverse_Accrual; options[index++] = DocumentEngine.ACTION_Reverse_Accrual;
} }
} }
@ -1014,8 +1016,9 @@ public class DocumentEngine implements DocAction
// Complete .. CO // Complete .. CO
if (docStatus.equals(DocumentEngine.STATUS_Completed)) if (docStatus.equals(DocumentEngine.STATUS_Completed))
{ {
options[index++] = DocumentEngine.ACTION_Void; if (periodOpen) {
options[index++] = DocumentEngine.ACTION_Reverse_Correct; options[index++] = DocumentEngine.ACTION_Reverse_Correct;
}
options[index++] = DocumentEngine.ACTION_Reverse_Accrual; options[index++] = DocumentEngine.ACTION_Reverse_Accrual;
} }
} }
@ -1027,8 +1030,9 @@ public class DocumentEngine implements DocAction
// Complete .. CO // Complete .. CO
if (docStatus.equals(DocumentEngine.STATUS_Completed)) if (docStatus.equals(DocumentEngine.STATUS_Completed))
{ {
options[index++] = DocumentEngine.ACTION_Void; if (periodOpen) {
options[index++] = DocumentEngine.ACTION_Reverse_Correct; options[index++] = DocumentEngine.ACTION_Reverse_Correct;
}
options[index++] = DocumentEngine.ACTION_Reverse_Accrual; options[index++] = DocumentEngine.ACTION_Reverse_Accrual;
} }
} }
@ -1040,10 +1044,12 @@ public class DocumentEngine implements DocAction
// Complete .. CO // Complete .. CO
if (docStatus.equals(DocumentEngine.STATUS_Completed)) if (docStatus.equals(DocumentEngine.STATUS_Completed))
{ {
if (periodOpen) {
options[index++] = DocumentEngine.ACTION_Reverse_Correct; options[index++] = DocumentEngine.ACTION_Reverse_Correct;
options[index++] = DocumentEngine.ACTION_Reverse_Accrual;
options[index++] = DocumentEngine.ACTION_ReActivate; options[index++] = DocumentEngine.ACTION_ReActivate;
} }
options[index++] = DocumentEngine.ACTION_Reverse_Accrual;
}
} }
/******************** /********************
* Allocation * Allocation
@ -1053,8 +1059,9 @@ public class DocumentEngine implements DocAction
// Complete .. CO // Complete .. CO
if (docStatus.equals(DocumentEngine.STATUS_Completed)) if (docStatus.equals(DocumentEngine.STATUS_Completed))
{ {
options[index++] = DocumentEngine.ACTION_Void; if (periodOpen) {
options[index++] = DocumentEngine.ACTION_Reverse_Correct; options[index++] = DocumentEngine.ACTION_Reverse_Correct;
}
options[index++] = DocumentEngine.ACTION_Reverse_Accrual; options[index++] = DocumentEngine.ACTION_Reverse_Accrual;
} }
} }
@ -1078,9 +1085,11 @@ public class DocumentEngine implements DocAction
// Complete .. CO // Complete .. CO
if (docStatus.equals(DocumentEngine.STATUS_Completed)) if (docStatus.equals(DocumentEngine.STATUS_Completed))
{ {
if (periodOpen) {
options[index++] = DocumentEngine.ACTION_Void; options[index++] = DocumentEngine.ACTION_Void;
} }
} }
}
/******************** /********************
* Inventory Movement, Physical Inventory * Inventory Movement, Physical Inventory
*/ */
@ -1090,8 +1099,9 @@ public class DocumentEngine implements DocAction
// Complete .. CO // Complete .. CO
if (docStatus.equals(DocumentEngine.STATUS_Completed)) if (docStatus.equals(DocumentEngine.STATUS_Completed))
{ {
options[index++] = DocumentEngine.ACTION_Void; if (periodOpen) {
options[index++] = DocumentEngine.ACTION_Reverse_Correct; options[index++] = DocumentEngine.ACTION_Reverse_Correct;
}
options[index++] = DocumentEngine.ACTION_Reverse_Accrual; options[index++] = DocumentEngine.ACTION_Reverse_Accrual;
} }
} }
@ -1129,8 +1139,9 @@ public class DocumentEngine implements DocAction
// Complete .. CO // Complete .. CO
else if (docStatus.equals(DocumentEngine.STATUS_Completed)) else if (docStatus.equals(DocumentEngine.STATUS_Completed))
{ {
options[index++] = DocumentEngine.ACTION_Void; if (periodOpen) {
options[index++] = DocumentEngine.ACTION_Reverse_Correct; options[index++] = DocumentEngine.ACTION_Reverse_Correct;
}
options[index++] = DocumentEngine.ACTION_Reverse_Accrual; options[index++] = DocumentEngine.ACTION_Reverse_Accrual;
} }

View File

@ -39,9 +39,11 @@ import org.compiere.model.MAllocationHdr;
import org.compiere.model.MBankStatement; import org.compiere.model.MBankStatement;
import org.compiere.model.MClientInfo; import org.compiere.model.MClientInfo;
import org.compiere.model.MDocType; import org.compiere.model.MDocType;
import org.compiere.model.MPeriod;
import org.compiere.model.MProduction; import org.compiere.model.MProduction;
import org.compiere.model.MTable; import org.compiere.model.MTable;
import org.compiere.model.PO; import org.compiere.model.PO;
import org.compiere.process.DocAction;
import org.compiere.process.DocOptions; import org.compiere.process.DocOptions;
import org.compiere.process.DocumentEngine; import org.compiere.process.DocumentEngine;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -65,7 +67,7 @@ public class WDocActionPanel extends Window implements EventListener<Event>, Dia
/** /**
* *
*/ */
private static final long serialVersionUID = -1467198100278350775L; private static final long serialVersionUID = -2166149559040327486L;
private Label lblDocAction; private Label lblDocAction;
private Label label; private Label label;
@ -159,12 +161,16 @@ public class WDocActionPanel extends Window implements EventListener<Event>, Dia
* General Actions * 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); MTable table = MTable.get(Env.getCtx(), m_AD_Table_ID);
PO po = table.getPO(gridTab.getRecord_ID(), null); 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) if (po instanceof DocOptions)
index = ((DocOptions) po).customizeValidActions(DocStatus, Processing, OrderType, IsSOTrx, index = ((DocOptions) po).customizeValidActions(DocStatus, Processing, OrderType, IsSOTrx,
m_AD_Table_ID, docActionHolder, options, index); m_AD_Table_ID, docActionHolder, options, index);