Projects:Validity dates - Valid To/Technical Document
This project will be released as a new module available at http://forge.openbravo.com/projects/validto
Contents |
- Java Package Name : org.openbravo.module.validto
- DB Prexix : VALIDTO
Application Dictionary Changes
A new column called "EM_VALIDTO_VALIDTO" will be created in the following tables:
- C_BPARTNER
- C_ELEMENTVALUE
- C_TAX
It's very important to ensure the column name for this columns defined at the Application Dictionary is equal to [EM_ValidTo_ValidTo] (capital letters are important). This ensures the three generated attributes (and getters methods) for each class have exactly the same name. This is mandatory for allowing us the use of reflection for simplifying the code development and for allowing future extensions (or new modules based on this one).
Datasets
A new Dataset Client/Org data level will be created to store the definition of the Accounting process that checks the valid to value of the Business Partner, Element Value and Tax Rate entities.
Java Code
org.openbravo.module.validto.process.ValidToProcess
Represents the accounting process that checks the
* Business Partner * Tax Rate * Element Value (Account)
have a valid to field >= Document's Accounting date
org.openbravo.module.validto.process.ValidToProcessDao
Data Access Object used by the ValidToProcess class to access the database using DAL (Hibernate)
org.openbravo.module.validto.process.ValidToUtility
Utility class.
The public static boolean hasValidDateTo(final BaseOBObject baseOBObject, final String methodName,final Date date) method is very important because it verifies the baseOBObject has a valid to date >= date. The valid to date field can be defined with a different name for each BaseOBObject, so the methodName parameter represents the baseOBObject method to determine the valid to value.
- the baseOBObject param is an Openbravo BaseOBObject with a valid to attribute
- the methodName param is the name of the method that gets the value of the valid to attribute. This method must accept 0 parameters and must return a java.util.Date object
- the date param is a Date to compare to the valid to date
Note: This method uses reflection for invoking the methodName passed as parameter, so it can be easily used in the future to define new processes that check the valid to field of any Openbravo BaseOBObject, like for example Organization, Accounting Schemas, etc.