IDEMPIERE-5575 - Period Controll, new option - Period Document Close (#1676)
* IDEMPIERE-5575 - Period Controll, new option - Period Document Close * IDEMPIERE-5575 - patch pr1676
This commit is contained in:
parent
dff85c45de
commit
883edf8436
|
@ -0,0 +1,14 @@
|
||||||
|
-- IDEMPIERE-5575
|
||||||
|
SELECT register_migration_script('202302150816_IDEMPIERE-5575.sql') FROM dual;
|
||||||
|
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- Feb 15, 2023, 8:16:38 AM CET
|
||||||
|
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200628,'Document closed',177,'D',0,0,'Y',TO_TIMESTAMP('2023-02-15 08:16:38','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-02-15 08:16:38','YYYY-MM-DD HH24:MI:SS'),100,'D','948b0299-f812-4fc7-92b8-9063f7deae6d')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Feb 15, 2023, 8:26:25 AM CET
|
||||||
|
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200629,'Document Close Period',176,'D',0,0,'Y',TO_TIMESTAMP('2023-02-15 08:26:25','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-02-15 08:26:25','YYYY-MM-DD HH24:MI:SS'),100,'D','115de309-7e7b-42a0-873b-7acf400d3ac3')
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
-- IDEMPIERE-5575
|
||||||
|
SELECT register_migration_script('202302150816_IDEMPIERE-5575.sql') FROM dual;
|
||||||
|
|
||||||
|
-- Feb 15, 2023, 8:16:38 AM CET
|
||||||
|
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200628,'Document closed',177,'D',0,0,'Y',TO_TIMESTAMP('2023-02-15 08:16:38','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-02-15 08:16:38','YYYY-MM-DD HH24:MI:SS'),100,'D','948b0299-f812-4fc7-92b8-9063f7deae6d')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Feb 15, 2023, 8:26:25 AM CET
|
||||||
|
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200629,'Document Close Period',176,'D',0,0,'Y',TO_TIMESTAMP('2023-02-15 08:26:25','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-02-15 08:26:25','YYYY-MM-DD HH24:MI:SS'),100,'D','115de309-7e7b-42a0-873b-7acf400d3ac3')
|
||||||
|
;
|
||||||
|
|
|
@ -83,6 +83,9 @@ public class PeriodControlStatus extends SvrProcess
|
||||||
// Open
|
// Open
|
||||||
if (MPeriodControl.PERIODACTION_OpenPeriod.equals(pc.getPeriodAction()))
|
if (MPeriodControl.PERIODACTION_OpenPeriod.equals(pc.getPeriodAction()))
|
||||||
pc.setPeriodStatus(MPeriodControl.PERIODSTATUS_Open);
|
pc.setPeriodStatus(MPeriodControl.PERIODSTATUS_Open);
|
||||||
|
// Document Close
|
||||||
|
if (MPeriodControl.PERIODACTION_DocumentClosePeriod.equals(pc.getPeriodAction()))
|
||||||
|
pc.setPeriodStatus(MPeriodControl.PERIODSTATUS_DocumentClosed);
|
||||||
// Close
|
// Close
|
||||||
if (MPeriodControl.PERIODACTION_ClosePeriod.equals(pc.getPeriodAction()))
|
if (MPeriodControl.PERIODACTION_ClosePeriod.equals(pc.getPeriodAction()))
|
||||||
pc.setPeriodStatus(MPeriodControl.PERIODSTATUS_Closed);
|
pc.setPeriodStatus(MPeriodControl.PERIODSTATUS_Closed);
|
||||||
|
|
|
@ -1105,7 +1105,7 @@ public abstract class Doc
|
||||||
m_period = MPeriod.get(getCtx(), getDateAcct(), getAD_Org_ID(), (String)null);
|
m_period = MPeriod.get(getCtx(), getDateAcct(), getAD_Org_ID(), (String)null);
|
||||||
// Is Period Open?
|
// Is Period Open?
|
||||||
if (m_period != null
|
if (m_period != null
|
||||||
&& m_period.isOpen(getDocumentType(), getDateAcct()))
|
&& m_period.isOpen(getDocumentType(), getDateAcct(), true))
|
||||||
m_C_Period_ID = m_period.getC_Period_ID();
|
m_C_Period_ID = m_period.getC_Period_ID();
|
||||||
else
|
else
|
||||||
m_C_Period_ID = -1;
|
m_C_Period_ID = -1;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.compiere.util.KeyNamePair;
|
||||||
|
|
||||||
/** Generated Interface for C_PeriodControl
|
/** Generated Interface for C_PeriodControl
|
||||||
* @author iDempiere (generated)
|
* @author iDempiere (generated)
|
||||||
* @version Release 10
|
* @version Release 11
|
||||||
*/
|
*/
|
||||||
public interface I_C_PeriodControl
|
public interface I_C_PeriodControl
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class MPeriod extends X_C_Period implements ImmutablePOSupport
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -4813116760490243399L;
|
private static final long serialVersionUID = 3016788523921605808L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Period from Cache (immutable)
|
* Get Period from Cache (immutable)
|
||||||
|
@ -270,7 +270,21 @@ public class MPeriod extends X_C_Period implements ImmutablePOSupport
|
||||||
* @param AD_Org_ID Organization
|
* @param AD_Org_ID Organization
|
||||||
* @return true if open
|
* @return true if open
|
||||||
*/
|
*/
|
||||||
public static boolean isOpen (Properties ctx, Timestamp DateAcct, String DocBaseType, int AD_Org_ID)
|
public static boolean isOpen(Properties ctx, Timestamp DateAcct, String DocBaseType, int AD_Org_ID)
|
||||||
|
{
|
||||||
|
return isOpen(ctx, DateAcct, DocBaseType, AD_Org_ID, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is standard Period Open for Document Base Type
|
||||||
|
* @param ctx context
|
||||||
|
* @param DateAcct date
|
||||||
|
* @param DocBaseType base type
|
||||||
|
* @param AD_Org_ID Organization
|
||||||
|
* @param forPosting - check if the period is open for posting, false is for DocAction
|
||||||
|
* @return true if open
|
||||||
|
*/
|
||||||
|
public static boolean isOpen (Properties ctx, Timestamp DateAcct, String DocBaseType, int AD_Org_ID, boolean forPosting)
|
||||||
{
|
{
|
||||||
if (DateAcct == null)
|
if (DateAcct == null)
|
||||||
{
|
{
|
||||||
|
@ -288,7 +302,7 @@ public class MPeriod extends X_C_Period implements ImmutablePOSupport
|
||||||
s_log.warning("No Period for " + DateAcct + " (" + DocBaseType + ")");
|
s_log.warning("No Period for " + DateAcct + " (" + DocBaseType + ")");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean open = period.isOpen(DocBaseType, DateAcct);
|
boolean open = period.isOpen(DocBaseType, DateAcct, forPosting);
|
||||||
if (!open)
|
if (!open)
|
||||||
s_log.warning(period.getName()
|
s_log.warning(period.getName()
|
||||||
+ ": Not open for " + DocBaseType + " (" + DateAcct + ")");
|
+ ": Not open for " + DocBaseType + " (" + DateAcct + ")");
|
||||||
|
@ -300,9 +314,23 @@ public class MPeriod extends X_C_Period implements ImmutablePOSupport
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
* @param tableID
|
* @param tableID
|
||||||
* @param recordID
|
* @param recordID
|
||||||
|
* @param trxName
|
||||||
* @return true if open
|
* @return true if open
|
||||||
*/
|
*/
|
||||||
public static boolean isOpen (Properties ctx, int tableID, int recordID, String trxName) {
|
public static boolean isOpen(Properties ctx, int tableID, int recordID, String trxName) {
|
||||||
|
return isOpen (ctx, tableID, recordID, trxName, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is standard Period Open - based on tableID+recordID (for IDEMPIERE-2392)
|
||||||
|
* @param ctx context
|
||||||
|
* @param tableID
|
||||||
|
* @param recordID
|
||||||
|
* @param trxName
|
||||||
|
* @param forPosting - check if the period is open for posting, false is for DocAction
|
||||||
|
* @return true if open
|
||||||
|
*/
|
||||||
|
public static boolean isOpen (Properties ctx, int tableID, int recordID, String trxName, boolean forPosting) {
|
||||||
MTable table = MTable.get(ctx, tableID);
|
MTable table = MTable.get(ctx, tableID);
|
||||||
PO po = table.getPO(recordID, trxName);
|
PO po = table.getPO(recordID, trxName);
|
||||||
|
|
||||||
|
@ -405,13 +433,13 @@ public class MPeriod extends X_C_Period implements ImmutablePOSupport
|
||||||
// special case for journal that has direct period
|
// special case for journal that has direct period
|
||||||
int periodID = po.get_ValueAsInt("C_Period_ID");
|
int periodID = po.get_ValueAsInt("C_Period_ID");
|
||||||
MPeriod period = MPeriod.get(ctx, periodID);
|
MPeriod period = MPeriod.get(ctx, periodID);
|
||||||
boolean open = period.isOpen(docBaseType, dateAcct);
|
boolean open = period.isOpen(docBaseType, dateAcct, forPosting);
|
||||||
if (!open)
|
if (!open)
|
||||||
s_log.warning(period.getName() + ": Not open for " + docBaseType + " (" + dateAcct + ")");
|
s_log.warning(period.getName() + ": Not open for " + docBaseType + " (" + dateAcct + ")");
|
||||||
return open;
|
return open;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isOpen(ctx, dateAcct, docBaseType, orgID);
|
return isOpen(ctx, dateAcct, docBaseType, orgID, forPosting);
|
||||||
} // isOpen
|
} // isOpen
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -665,6 +693,21 @@ public class MPeriod extends X_C_Period implements ImmutablePOSupport
|
||||||
* @since 3.3.1b
|
* @since 3.3.1b
|
||||||
*/
|
*/
|
||||||
public boolean isOpen (String DocBaseType, Timestamp dateAcct)
|
public boolean isOpen (String DocBaseType, Timestamp dateAcct)
|
||||||
|
{
|
||||||
|
return isOpen(DocBaseType, dateAcct, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is Period Open for Doc Base Type
|
||||||
|
* @param DocBaseType document base type
|
||||||
|
* @param dateAcct date;
|
||||||
|
* Applies only for "Auto Period Control":
|
||||||
|
* <li>if not null, date should be in auto period range (today - OpenHistory, today+OpenHistory)
|
||||||
|
* <li>if null, this period should be in auto period range
|
||||||
|
* @param forPosting - check if the period is open for posting, false is for DocAction
|
||||||
|
* @return true if open
|
||||||
|
*/
|
||||||
|
public boolean isOpen (String DocBaseType, Timestamp dateAcct, boolean forPosting)
|
||||||
{
|
{
|
||||||
if (!isActive())
|
if (!isActive())
|
||||||
{
|
{
|
||||||
|
@ -724,7 +767,7 @@ public class MPeriod extends X_C_Period implements ImmutablePOSupport
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (log.isLoggable(Level.FINE)) log.fine(getName() + ": " + DocBaseType);
|
if (log.isLoggable(Level.FINE)) log.fine(getName() + ": " + DocBaseType);
|
||||||
return pc.isOpen();
|
return pc.isOpen(forPosting);
|
||||||
} // isOpen
|
} // isOpen
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,8 +33,7 @@ public class MPeriodControl extends X_C_PeriodControl implements ImmutablePOSupp
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -3743823984541572396L;
|
private static final long serialVersionUID = -7818843756246170549L;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* Standard Constructor
|
||||||
|
@ -129,10 +128,23 @@ public class MPeriodControl extends X_C_PeriodControl implements ImmutablePOSupp
|
||||||
*/
|
*/
|
||||||
public boolean isOpen()
|
public boolean isOpen()
|
||||||
{
|
{
|
||||||
return PERIODSTATUS_Open.equals(getPeriodStatus());
|
return isOpen(false);
|
||||||
|
} // isOpen
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is Period Open
|
||||||
|
* @param forPosting - check if the period is open for posting, false is for DocAction
|
||||||
|
* @return true if open
|
||||||
|
*/
|
||||||
|
public boolean isOpen(boolean forPosting)
|
||||||
|
{
|
||||||
|
if (forPosting)
|
||||||
|
return PERIODSTATUS_Open.equals(getPeriodStatus())
|
||||||
|
|| PERIODSTATUS_DocumentClosed.equals(getPeriodStatus());
|
||||||
|
else
|
||||||
|
return PERIODSTATUS_Open.equals(getPeriodStatus());
|
||||||
} // isOpen
|
} // isOpen
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String Representation
|
* String Representation
|
||||||
* @return info
|
* @return info
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.compiere.util.KeyNamePair;
|
||||||
|
|
||||||
/** Generated Model for C_PeriodControl
|
/** Generated Model for C_PeriodControl
|
||||||
* @author iDempiere (generated)
|
* @author iDempiere (generated)
|
||||||
* @version Release 10 - $Id$ */
|
* @version Release 11 - $Id$ */
|
||||||
@org.adempiere.base.Model(table="C_PeriodControl")
|
@org.adempiere.base.Model(table="C_PeriodControl")
|
||||||
public class X_C_PeriodControl extends PO implements I_C_PeriodControl, I_Persistent
|
public class X_C_PeriodControl extends PO implements I_C_PeriodControl, I_Persistent
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ public class X_C_PeriodControl extends PO implements I_C_PeriodControl, I_Persis
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 20221224L;
|
private static final long serialVersionUID = 20230215L;
|
||||||
|
|
||||||
/** Standard Constructor */
|
/** Standard Constructor */
|
||||||
public X_C_PeriodControl (Properties ctx, int C_PeriodControl_ID, String trxName)
|
public X_C_PeriodControl (Properties ctx, int C_PeriodControl_ID, String trxName)
|
||||||
|
@ -248,6 +248,8 @@ public class X_C_PeriodControl extends PO implements I_C_PeriodControl, I_Persis
|
||||||
public static final int PERIODACTION_AD_Reference_ID=176;
|
public static final int PERIODACTION_AD_Reference_ID=176;
|
||||||
/** Close Period = C */
|
/** Close Period = C */
|
||||||
public static final String PERIODACTION_ClosePeriod = "C";
|
public static final String PERIODACTION_ClosePeriod = "C";
|
||||||
|
/** Document Close Period = D */
|
||||||
|
public static final String PERIODACTION_DocumentClosePeriod = "D";
|
||||||
/** <No Action> = N */
|
/** <No Action> = N */
|
||||||
public static final String PERIODACTION_NoAction = "N";
|
public static final String PERIODACTION_NoAction = "N";
|
||||||
/** Open Period = O */
|
/** Open Period = O */
|
||||||
|
@ -275,6 +277,8 @@ public class X_C_PeriodControl extends PO implements I_C_PeriodControl, I_Persis
|
||||||
public static final int PERIODSTATUS_AD_Reference_ID=177;
|
public static final int PERIODSTATUS_AD_Reference_ID=177;
|
||||||
/** Closed = C */
|
/** Closed = C */
|
||||||
public static final String PERIODSTATUS_Closed = "C";
|
public static final String PERIODSTATUS_Closed = "C";
|
||||||
|
/** Document closed = D */
|
||||||
|
public static final String PERIODSTATUS_DocumentClosed = "D";
|
||||||
/** Never opened = N */
|
/** Never opened = N */
|
||||||
public static final String PERIODSTATUS_NeverOpened = "N";
|
public static final String PERIODSTATUS_NeverOpened = "N";
|
||||||
/** Open = O */
|
/** Open = O */
|
||||||
|
|
|
@ -1322,7 +1322,7 @@ public class WAcctViewer extends Window implements EventListener<Event>
|
||||||
&& m_data.AD_Table_ID != 0 && m_data.Record_ID != 0)
|
&& m_data.AD_Table_ID != 0 && m_data.Record_ID != 0)
|
||||||
{
|
{
|
||||||
// IDEMPIERE-2392
|
// IDEMPIERE-2392
|
||||||
if (! MPeriod.isOpen(Env.getCtx(), m_data.AD_Table_ID, m_data.Record_ID, null)) {
|
if (! MPeriod.isOpen(Env.getCtx(), m_data.AD_Table_ID, m_data.Record_ID, null, true)) {
|
||||||
Dialog.error(0, "Error", Msg.getMsg(Env.getCtx(), "PeriodClosed"));
|
Dialog.error(0, "Error", Msg.getMsg(Env.getCtx(), "PeriodClosed"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue