Class MPeriod

All Implemented Interfaces:
Serializable, Cloneable, Comparator<Object>, I_C_Period, I_Persistent, Evaluatee, ImmutablePOSupport

public class MPeriod extends X_C_Period implements ImmutablePOSupport
Calendar Period Model
Version:
$Id: MPeriod.java,v 1.4 2006/07/30 00:51:05 jjanke Exp $
Author:
Jorg Janke, Teo Sarca, SC ARHIPAC SERVICE SRL
  • BF [ 1779438 ] Minor auto period control bug
  • BF [ 1893486 ] Auto Period Control return that period is always open, victor.perez@e-evolution.com, e-Evolution http://www.e-evolution.com
  • FR [ 2520591 ] Support multiples calendar for Org
  • See Also:
    • Constructor Details

      • MPeriod

        public MPeriod(Properties ctx, String C_Period_UU, String trxName)
        UUID based Constructor
        Parameters:
        ctx - Context
        C_Period_UU - UUID key
        trxName - Transaction
      • MPeriod

        public MPeriod(Properties ctx, int C_Period_ID, String trxName)
        Standard Constructor
        Parameters:
        ctx - context
        C_Period_ID - id
        trxName - transaction
      • MPeriod

        public MPeriod(Properties ctx, ResultSet rs, String trxName)
        Load Constructor
        Parameters:
        ctx - context
        rs - result set
        trxName - transaction
      • MPeriod

        public MPeriod(MYear year, int PeriodNo, String name, Timestamp startDate, Timestamp endDate)
        Parent constructor
        Parameters:
        year - year
        PeriodNo - no
        name - name
        startDate - start
        endDate - end
      • MPeriod

        public MPeriod(MPeriod copy)
        Copy constructor
        Parameters:
        copy -
      • MPeriod

        public MPeriod(Properties ctx, MPeriod copy)
        Copy constructor
        Parameters:
        ctx -
        copy -
      • MPeriod

        public MPeriod(Properties ctx, MPeriod copy, String trxName)
        Copy constructor
        Parameters:
        ctx -
        copy -
        trxName -
    • Method Details

      • get

        public static MPeriod get(int C_Period_ID)
        Get Period from Cache (immutable)
        Parameters:
        C_Period_ID - id
        Returns:
        MPeriod
      • get

        public static MPeriod get(Properties ctx, int C_Period_ID)
        Get Period from Cache (immutable)
        Parameters:
        ctx - context
        C_Period_ID - id
        Returns:
        MPeriod
      • get

        @Deprecated public static MPeriod get(Properties ctx, Timestamp DateAcct)
        Deprecated.
        Find standard Period of DateAcct based on Client Calendar
        Parameters:
        ctx - context
        DateAcct - date
        Returns:
        active Period or null
      • get

        public static MPeriod get(Properties ctx, Timestamp DateAcct, int AD_Org_ID, String trxName)
        Find standard Period of DateAcct based on Client Calendar
        Parameters:
        ctx - context
        DateAcct - date
        AD_Org_ID - Organization
        Returns:
        active Period or null
      • get

        @Deprecated public static MPeriod get(Properties ctx, Timestamp DateAcct, int AD_Org_ID)
        Deprecated.
      • getCopy

        public static MPeriod getCopy(Properties ctx, int C_Period_ID, String trxName)
        Get updateable copy of MPeriod from cache
        Parameters:
        ctx -
        C_Period_ID -
        trxName -
        Returns:
        MPeriod
      • findByCalendar

        @Deprecated public static MPeriod findByCalendar(Properties ctx, Timestamp DateAcct, int C_Calendar_ID)
        Deprecated.
        Parameters:
        ctx -
        DateAcct -
        C_Calendar_ID -
        Returns:
        MPeriod
      • findByCalendar

        public static MPeriod findByCalendar(Properties ctx, Timestamp DateAcct, int C_Calendar_ID, String trxName)
        Find standard Period of DateAcct
        Parameters:
        ctx -
        DateAcct -
        C_Calendar_ID -
        trxName -
        Returns:
        MPeriod or null
      • getC_Period_ID

        @Deprecated public static int getC_Period_ID(Properties ctx, Timestamp DateAcct)
        Deprecated.
        Find valid standard Period of DateAcct based on Client Calendar
        Parameters:
        ctx - context
        DateAcct - date
        Returns:
        C_Period_ID or 0
      • getC_Period_ID

        public static int getC_Period_ID(Properties ctx, Timestamp DateAcct, int AD_Org_ID)
        Find valid standard Period of DateAcct based on Client Calendar
        Parameters:
        ctx - context
        DateAcct - date
        AD_Org_ID - Organization
        Returns:
        C_Period_ID or 0
      • isOpen

        @Deprecated public static boolean isOpen(Properties ctx, Timestamp DateAcct, String DocBaseType)
        Deprecated.
        Is standard Period Open for Document Base Type
        Parameters:
        ctx - context
        DateAcct - date
        DocBaseType - base type
        Returns:
        true if open
      • isOpen

        public static boolean isOpen(Properties ctx, Timestamp DateAcct, String DocBaseType, int AD_Org_ID)
        Is standard Period Open for Document Base Type
        Parameters:
        ctx - context
        DateAcct - date
        DocBaseType - base type (X_C_DocType.DOCBASETYPE_*)
        AD_Org_ID - Organization
        Returns:
        true if open
      • isOpen

        public static boolean isOpen(Properties ctx, Timestamp DateAcct, String DocBaseType, int AD_Org_ID, boolean forPosting)
        Is standard Period Open for Document Base Type
        Parameters:
        ctx - context
        DateAcct - date
        DocBaseType - base type (X_C_DocType.DOCBASETYPE_*)
        AD_Org_ID - Organization
        forPosting - - true to check if the period is open for posting, false is for DocAction
        Returns:
        true if open
      • isOpen

        public static boolean isOpen(Properties ctx, int tableID, int recordID, String trxName)
        Is standard Period Open - based on tableID+recordID (for IDEMPIERE-2392)
        Parameters:
        ctx - context
        tableID -
        recordID -
        trxName -
        Returns:
        true if open
      • isOpen

        public static boolean isOpen(Properties ctx, int tableID, int recordID, String trxName, boolean forPosting)
        Is standard Period Open - based on tableID+recordID (for IDEMPIERE-2392)
        Parameters:
        ctx - context
        tableID -
        recordID -
        trxName -
        forPosting - - true to check if the period is open for posting, false is for DocAction
        Returns:
        true if open
      • getFirstInYear

        @Deprecated public static MPeriod getFirstInYear(Properties ctx, Timestamp DateAcct)
        Deprecated.
        Find first Year Period of DateAcct based on Client Calendar
        Parameters:
        ctx - context
        DateAcct - date
        Returns:
        active first Period
      • getFirstInYear

        public static MPeriod getFirstInYear(Properties ctx, Timestamp DateAcct, int AD_Org_ID)
        Find first Year Period of DateAcct based on Client Calendar
        Parameters:
        ctx - context
        DateAcct - date
        AD_Org_ID - organization
        Returns:
        active first Period
      • getPeriodControls

        public MPeriodControl[] getPeriodControls(boolean requery)
        Get Period Control
        Parameters:
        requery - true to re-query from DB
        Returns:
        period controls
      • getPeriodControl

        public MPeriodControl getPeriodControl(String DocBaseType)
        Get Period Control
        Parameters:
        DocBaseType - Document Base Type (X_C_DocType.DOCBASETYPE_*)
        Returns:
        period control or null
      • isInPeriod

        public boolean isInPeriod(Timestamp date)
        Is Date In this Period
        Parameters:
        date - date
        Returns:
        true if date is in this period
      • isOpen

        @Deprecated public boolean isOpen(String DocBaseType)
        Deprecated.
        since 3.3.1b; use isOpen(String, Timestamp) instead
        Is Period Open for Doc Base Type
        Parameters:
        DocBaseType - document base type
        Returns:
        true if open
      • isOpen

        public boolean isOpen(String DocBaseType, Timestamp dateAcct)
        Is Period Open for Doc Base Type
        Parameters:
        DocBaseType - document base type (X_C_DocType.DOCBASETYPE_*)
        dateAcct - date; Applies only for "Auto Period Control":
      • if not null, date should be in auto period range (today - OpenHistory, today+OpenHistory)
      • if null, this period should be in auto period range
      • Returns:
        true if open
        Since:
        3.3.1b
      • isOpen

        public boolean isOpen(String DocBaseType, Timestamp dateAcct, boolean forPosting)
        Is Period Open for Doc Base Type
        Parameters:
        DocBaseType - document base type
        dateAcct - date; Applies only for "Auto Period Control":
      • if not null, date should be in auto period range (today - OpenHistory, today+OpenHistory)
      • if null, this period should be in auto period range
      • forPosting - - true to check if the period is open for posting, false is for DocAction
        Returns:
        true if open
      • isStandardPeriod

        public boolean isStandardPeriod()
        Standard Period
        Returns:
        true if this is of standard calendar periods type (PERIODTYPE_StandardCalendarPeriod)
      • beforeSave

        protected boolean beforeSave(boolean newRecord)
        Description copied from class: PO
        Called before Save for Pre-Save Operation.
        Default implementation is nop, to be implemented in sub-classes that needed it.
        Overrides:
        beforeSave in class PO
        Parameters:
        newRecord - true if it is a new record
        Returns:
        true if record can be saved
      • afterSave

        protected boolean afterSave(boolean newRecord, boolean success)
        Description copied from class: PO
        Called after Save for Post-Save Operation.
        Default implementation is nop, to be implemented in sub-classes that needed it.
        Overrides:
        afterSave in class PO
        Parameters:
        newRecord - true if it is a new record
        success - true if save operation was success
        Returns:
        if save was a success
      • toString

        public String toString()
        String Representation
        Overrides:
        toString in class X_C_Period
        Returns:
        info
      • testPeriodOpen

        @Deprecated public static void testPeriodOpen(Properties ctx, Timestamp dateAcct, String docBaseType) throws PeriodClosedException
        Deprecated.
        Convenient method for testing if a period is open
        Parameters:
        ctx -
        dateAcct -
        docBaseType -
        Throws:
        PeriodClosedException - if period is closed
        See Also:
      • testPeriodOpen

        public static void testPeriodOpen(Properties ctx, Timestamp dateAcct, String docBaseType, int AD_Org_ID) throws PeriodClosedException
        Convenient method for testing if a period is open
        Parameters:
        ctx -
        dateAcct -
        docBaseType - X_C_DocType.DOCBASETYPE_*
        AD_Org_ID - Organization
        Throws:
        PeriodClosedException - if period is closed
        See Also:
      • testPeriodOpen

        @Deprecated public static void testPeriodOpen(Properties ctx, Timestamp dateAcct, int C_DocType_ID) throws PeriodClosedException
        Deprecated.
        Convenient method for testing if a period is open
        Parameters:
        ctx -
        dateAcct -
        C_DocType_ID -
        Throws:
        PeriodClosedException
      • testPeriodOpen

        public static void testPeriodOpen(Properties ctx, Timestamp dateAcct, int C_DocType_ID, int AD_Org_ID) throws PeriodClosedException
        Convenient method for testing if a period is open
        Parameters:
        ctx -
        dateAcct -
        C_DocType_ID -
        AD_Org_ID - Organization
        Throws:
        PeriodClosedException
      • getC_Calendar_ID

        public int getC_Calendar_ID()
        Get Calendar of Period
        Returns:
        C_Calendar_ID
      • getC_Calendar_ID

        public static int getC_Calendar_ID(Properties ctx, int AD_Org_ID)
        Get Calendar for Organization
        Parameters:
        ctx - Context
        AD_Org_ID - Organization
        Returns:
        C_Calendar_ID
      • markImmutable

        public MPeriod markImmutable()
        Description copied from interface: ImmutablePOSupport
        mark PO as immutable
        Specified by:
        markImmutable in interface ImmutablePOSupport
        Returns:
        PO
      • hasUnpostedDocs

        public boolean hasUnpostedDocs()
        Is the period has un-posted documents
        Returns:
        boolean - true if there is at least 1 un-posted document in this period
      • hasUnpostedDocs

        public boolean hasUnpostedDocs(int periodControlID)
        Is this period has un-posted documents
        Parameters:
        periodControlID - C_PeriodControl_ID. If > 0, check only documents with the period control's DocBaseType
        Returns:
        boolean - true if there is at least 1 un-posted document in this period