diff --git a/migration/iD11/oracle/202302150816_IDEMPIERE-5575.sql b/migration/iD11/oracle/202302150816_IDEMPIERE-5575.sql new file mode 100644 index 0000000000..e8a05fc9a4 --- /dev/null +++ b/migration/iD11/oracle/202302150816_IDEMPIERE-5575.sql @@ -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') +; + diff --git a/migration/iD11/postgresql/202302150816_IDEMPIERE-5575.sql b/migration/iD11/postgresql/202302150816_IDEMPIERE-5575.sql new file mode 100644 index 0000000000..b60c001b7e --- /dev/null +++ b/migration/iD11/postgresql/202302150816_IDEMPIERE-5575.sql @@ -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') +; + diff --git a/org.adempiere.base.process/src/org/compiere/process/PeriodControlStatus.java b/org.adempiere.base.process/src/org/compiere/process/PeriodControlStatus.java index cdd6d68ced..ee16c13082 100644 --- a/org.adempiere.base.process/src/org/compiere/process/PeriodControlStatus.java +++ b/org.adempiere.base.process/src/org/compiere/process/PeriodControlStatus.java @@ -83,6 +83,9 @@ public class PeriodControlStatus extends SvrProcess // Open if (MPeriodControl.PERIODACTION_OpenPeriod.equals(pc.getPeriodAction())) pc.setPeriodStatus(MPeriodControl.PERIODSTATUS_Open); + // Document Close + if (MPeriodControl.PERIODACTION_DocumentClosePeriod.equals(pc.getPeriodAction())) + pc.setPeriodStatus(MPeriodControl.PERIODSTATUS_DocumentClosed); // Close if (MPeriodControl.PERIODACTION_ClosePeriod.equals(pc.getPeriodAction())) pc.setPeriodStatus(MPeriodControl.PERIODSTATUS_Closed); diff --git a/org.adempiere.base/src/org/compiere/acct/Doc.java b/org.adempiere.base/src/org/compiere/acct/Doc.java index 945835419f..f34831423a 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc.java @@ -1105,7 +1105,7 @@ public abstract class Doc m_period = MPeriod.get(getCtx(), getDateAcct(), getAD_Org_ID(), (String)null); // Is Period Open? if (m_period != null - && m_period.isOpen(getDocumentType(), getDateAcct())) + && m_period.isOpen(getDocumentType(), getDateAcct(), true)) m_C_Period_ID = m_period.getC_Period_ID(); else m_C_Period_ID = -1; diff --git a/org.adempiere.base/src/org/compiere/model/I_C_PeriodControl.java b/org.adempiere.base/src/org/compiere/model/I_C_PeriodControl.java index 5a1f8dc425..e92ec05ac1 100644 --- a/org.adempiere.base/src/org/compiere/model/I_C_PeriodControl.java +++ b/org.adempiere.base/src/org/compiere/model/I_C_PeriodControl.java @@ -22,7 +22,7 @@ import org.compiere.util.KeyNamePair; /** Generated Interface for C_PeriodControl * @author iDempiere (generated) - * @version Release 10 + * @version Release 11 */ public interface I_C_PeriodControl { diff --git a/org.adempiere.base/src/org/compiere/model/MPeriod.java b/org.adempiere.base/src/org/compiere/model/MPeriod.java index 9fad4d6df0..1d701b9c8a 100644 --- a/org.adempiere.base/src/org/compiere/model/MPeriod.java +++ b/org.adempiere.base/src/org/compiere/model/MPeriod.java @@ -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) @@ -270,7 +270,21 @@ public class MPeriod extends X_C_Period implements ImmutablePOSupport * @param AD_Org_ID Organization * @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) { @@ -288,7 +302,7 @@ public class MPeriod extends X_C_Period implements ImmutablePOSupport s_log.warning("No Period for " + DateAcct + " (" + DocBaseType + ")"); return false; } - boolean open = period.isOpen(DocBaseType, DateAcct); + boolean open = period.isOpen(DocBaseType, DateAcct, forPosting); if (!open) s_log.warning(period.getName() + ": Not open for " + DocBaseType + " (" + DateAcct + ")"); @@ -300,9 +314,23 @@ public class MPeriod extends X_C_Period implements ImmutablePOSupport * @param ctx context * @param tableID * @param recordID + * @param trxName * @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); 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 int periodID = po.get_ValueAsInt("C_Period_ID"); MPeriod period = MPeriod.get(ctx, periodID); - boolean open = period.isOpen(docBaseType, dateAcct); + boolean open = period.isOpen(docBaseType, dateAcct, forPosting); if (!open) s_log.warning(period.getName() + ": Not open for " + docBaseType + " (" + dateAcct + ")"); return open; } - return isOpen(ctx, dateAcct, docBaseType, orgID); + return isOpen(ctx, dateAcct, docBaseType, orgID, forPosting); } // isOpen /** @@ -665,6 +693,21 @@ public class MPeriod extends X_C_Period implements ImmutablePOSupport * @since 3.3.1b */ 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": + *