diff --git a/base/src/org/adempiere/exceptions/PeriodClosedException.java b/base/src/org/adempiere/exceptions/PeriodClosedException.java
index c62814ba7d..dc016c164c 100644
--- a/base/src/org/adempiere/exceptions/PeriodClosedException.java
+++ b/base/src/org/adempiere/exceptions/PeriodClosedException.java
@@ -19,9 +19,12 @@ import java.sql.Timestamp;
/**
* Period Closed Exception.
* This exception is throwed by
- * {@link org.compiere.model.MPeriod#testPeriodOpen(java.util.Properties, Timestamp, int)} and
- * {@link org.compiere.model.MPeriod#testPeriodOpen(java.util.Properties, Timestamp, String)} methods.
+ * {@link org.compiere.model.MPeriod#testPeriodOpen(java.util.Properties, Timestamp, int, int)} and
+ * {@link org.compiere.model.MPeriod#testPeriodOpen(java.util.Properties, Timestamp, String, int)} methods.
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ *
FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
*
*/
public class PeriodClosedException extends AdempiereException {
diff --git a/base/src/org/compiere/acct/Doc.java b/base/src/org/compiere/acct/Doc.java
index 62c5bdc9e6..2c278e8812 100644
--- a/base/src/org/compiere/acct/Doc.java
+++ b/base/src/org/compiere/acct/Doc.java
@@ -117,6 +117,9 @@ import org.eevolution.model.MPPCostCollector;
*
*
* @author Jorg Janke
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @version $Id: Doc.java,v 1.6 2006/07/30 00:53:33 jjanke Exp $
*/
public abstract class Doc
@@ -1106,10 +1109,10 @@ public abstract class Doc
{
Integer ii = (Integer)p_po.get_Value(index);
if (ii != null)
- m_period = MPeriod.get(getCtx(), ii.intValue());
+ m_period = MPeriod.get(getCtx(), ii.intValue(), getAD_Org_ID());
}
if (m_period == null)
- m_period = MPeriod.get(getCtx(), getDateAcct());
+ m_period = MPeriod.get(getCtx(), getDateAcct(), getAD_Org_ID());
// Is Period Open?
if (m_period != null
&& m_period.isOpen(getDocumentType(), getDateAcct()))
diff --git a/base/src/org/compiere/acct/Doc_Bank.java b/base/src/org/compiere/acct/Doc_Bank.java
index 1390c7a338..57a70a416c 100644
--- a/base/src/org/compiere/acct/Doc_Bank.java
+++ b/base/src/org/compiere/acct/Doc_Bank.java
@@ -39,6 +39,9 @@ import org.compiere.util.Env;
*
* FR [ 1840016 ] Avoid usage of clearing accounts - subject to C_AcctSchema.IsPostIfClearingEqual
* Avoid posting if both accounts BankAsset and BankInTransit are equal
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
*
*/
public class Doc_Bank extends Doc
@@ -102,7 +105,7 @@ public class Doc_Bank extends Doc
// Set Date Acct
if (i == 0)
setDateAcct(line.getDateAcct());
- MPeriod period = MPeriod.get(getCtx(), line.getDateAcct());
+ MPeriod period = MPeriod.get(getCtx(), line.getDateAcct(), line.getAD_Org_ID());
if (period != null && period.isOpen(DOCTYPE_BankStatement, line.getDateAcct()))
docLine.setC_Period_ID(period.getC_Period_ID());
//
diff --git a/base/src/org/compiere/model/I_AD_OrgInfo.java b/base/src/org/compiere/model/I_AD_OrgInfo.java
index a3eef80f66..0374c12c48 100644
--- a/base/src/org/compiere/model/I_AD_OrgInfo.java
+++ b/base/src/org/compiere/model/I_AD_OrgInfo.java
@@ -20,6 +20,7 @@
package org.compiere.model;
import java.math.BigDecimal;
+import java.sql.Timestamp;
import org.compiere.util.KeyNamePair;
/** Generated Interface for AD_OrgInfo
@@ -43,18 +44,13 @@ public interface I_AD_OrgInfo
/** Load Meta Data */
- /** Column name AD_Org_ID */
- public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
+ /** Column name AD_Client_ID */
+ public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
- /** Set Organization.
- * Organizational entity within client
+ /** Get Client.
+ * Client/Tenant for this installation.
*/
- public void setAD_Org_ID (int AD_Org_ID);
-
- /** Get Organization.
- * Organizational entity within client
- */
- public int getAD_Org_ID();
+ public int getAD_Client_ID();
/** Column name AD_OrgType_ID */
public static final String COLUMNNAME_AD_OrgType_ID = "AD_OrgType_ID";
@@ -71,6 +67,34 @@ public interface I_AD_OrgInfo
public I_AD_OrgType getAD_OrgType() throws RuntimeException;
+ /** Column name AD_Org_ID */
+ public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
+
+ /** Set Organization.
+ * Organizational entity within client
+ */
+ public void setAD_Org_ID (int AD_Org_ID);
+
+ /** Get Organization.
+ * Organizational entity within client
+ */
+ public int getAD_Org_ID();
+
+ /** Column name C_Calendar_ID */
+ public static final String COLUMNNAME_C_Calendar_ID = "C_Calendar_ID";
+
+ /** Set Calendar.
+ * Accounting Calendar Name
+ */
+ public void setC_Calendar_ID (int C_Calendar_ID);
+
+ /** Get Calendar.
+ * Accounting Calendar Name
+ */
+ public int getC_Calendar_ID();
+
+ public I_C_Calendar getC_Calendar() throws RuntimeException;
+
/** Column name C_Location_ID */
public static final String COLUMNNAME_C_Location_ID = "C_Location_ID";
@@ -84,6 +108,35 @@ public interface I_AD_OrgInfo
*/
public int getC_Location_ID();
+ /** Column name Created */
+ public static final String COLUMNNAME_Created = "Created";
+
+ /** Get Created.
+ * Date this record was created
+ */
+ public Timestamp getCreated();
+
+ /** Column name CreatedBy */
+ public static final String COLUMNNAME_CreatedBy = "CreatedBy";
+
+ /** Get Created By.
+ * User who created this records
+ */
+ public int getCreatedBy();
+
+ /** Column name DUNS */
+ public static final String COLUMNNAME_DUNS = "DUNS";
+
+ /** Set D-U-N-S.
+ * Dun & Bradstreet Number
+ */
+ public void setDUNS (String DUNS);
+
+ /** Get D-U-N-S.
+ * Dun & Bradstreet Number
+ */
+ public String getDUNS();
+
/** Column name DropShip_Warehouse_ID */
public static final String COLUMNNAME_DropShip_Warehouse_ID = "DropShip_Warehouse_ID";
@@ -97,18 +150,18 @@ public interface I_AD_OrgInfo
*/
public int getDropShip_Warehouse_ID();
- /** Column name DUNS */
- public static final String COLUMNNAME_DUNS = "DUNS";
+ /** Column name IsActive */
+ public static final String COLUMNNAME_IsActive = "IsActive";
- /** Set D-U-N-S.
- * Dun & Bradstreet Number
+ /** Set Active.
+ * The record is active in the system
*/
- public void setDUNS (String DUNS);
+ public void setIsActive (boolean IsActive);
- /** Get D-U-N-S.
- * Dun & Bradstreet Number
+ /** Get Active.
+ * The record is active in the system
*/
- public String getDUNS();
+ public boolean isActive();
/** Column name M_Warehouse_ID */
public static final String COLUMNNAME_M_Warehouse_ID = "M_Warehouse_ID";
@@ -198,4 +251,20 @@ public interface I_AD_OrgInfo
/** Get CashBook for transfers */
public int getTransferCashBook_ID();
+
+ /** Column name Updated */
+ public static final String COLUMNNAME_Updated = "Updated";
+
+ /** Get Updated.
+ * Date this record was updated
+ */
+ public Timestamp getUpdated();
+
+ /** Column name UpdatedBy */
+ public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
+
+ /** Get Updated By.
+ * User who updated this records
+ */
+ public int getUpdatedBy();
}
diff --git a/base/src/org/compiere/model/MAllocationHdr.java b/base/src/org/compiere/model/MAllocationHdr.java
index f29176d049..57dfcd3da0 100644
--- a/base/src/org/compiere/model/MAllocationHdr.java
+++ b/base/src/org/compiere/model/MAllocationHdr.java
@@ -41,8 +41,12 @@ import org.compiere.util.Msg;
*
* @author Jorg Janke
* @version $Id: MAllocationHdr.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
- * @author victor.perez@e-evolution.com www.e-evolution.com FR [ 1866214 ] http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335
- */
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 1866214 ]
+ * @see http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
+*/
public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
{
/**
@@ -301,7 +305,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
log.warning ("No transaction");
if (isPosted())
{
- if (!MPeriod.isOpen(getCtx(), getDateTrx(), MDocType.DOCBASETYPE_PaymentAllocation))
+ if (!MPeriod.isOpen(getCtx(), getDateTrx(), MDocType.DOCBASETYPE_PaymentAllocation, getAD_Org_ID()))
{
log.warning ("Period Closed");
return false;
@@ -390,7 +394,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
return DocAction.STATUS_Invalid;
// Std Period open?
- if (!MPeriod.isOpen(getCtx(), getDateAcct(), MDocType.DOCBASETYPE_PaymentAllocation))
+ if (!MPeriod.isOpen(getCtx(), getDateAcct(), MDocType.DOCBASETYPE_PaymentAllocation, getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
@@ -709,7 +713,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
throw new IllegalStateException("Allocation already reversed (not active)");
// Can we delete posting
- if (!MPeriod.isOpen(getCtx(), getDateTrx(), MPeriodControl.DOCBASETYPE_PaymentAllocation))
+ if (!MPeriod.isOpen(getCtx(), getDateTrx(), MPeriodControl.DOCBASETYPE_PaymentAllocation, getAD_Org_ID()))
throw new IllegalStateException("@PeriodClosed@");
// Set Inactive
diff --git a/base/src/org/compiere/model/MBankStatement.java b/base/src/org/compiere/model/MBankStatement.java
index c6808e0b44..354f16f4cc 100644
--- a/base/src/org/compiere/model/MBankStatement.java
+++ b/base/src/org/compiere/model/MBankStatement.java
@@ -35,9 +35,12 @@ import org.compiere.util.Msg;
* Bank Statement Model
*
* @author Eldir Tomassen/Jorg Janke
-* @author victor.perez@e-evolution.com fixed bug [ 1933645 ] Wrong balance Bank Statement
+* @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+* BF [ 1933645 ] Wrong balance Bank Statement
* @see http://sourceforge.net/tracker/?func=detail&atid=879332&aid=1933645&group_id=176962
-* @version $Id: MBankStatement.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
+* FR [ 2520591 ] Support multiples calendar for Org
+* @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
+* @version $Id: MBankStatement.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
*/
public class MBankStatement extends X_C_BankStatement implements DocAction
{
@@ -310,7 +313,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction
return DocAction.STATUS_Invalid;
// Std Period open?
- if (!MPeriod.isOpen(getCtx(), getStatementDate(), MDocType.DOCBASETYPE_BankStatement))
+ if (!MPeriod.isOpen(getCtx(), getStatementDate(), MDocType.DOCBASETYPE_BankStatement, getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
@@ -336,8 +339,8 @@ public class MBankStatement extends X_C_BankStatement implements DocAction
}
setStatementDifference(total);
setEndingBalance(getBeginningBalance().add(total));
- if (!MPeriod.isOpen(getCtx(), minDate, MDocType.DOCBASETYPE_BankStatement)
- || !MPeriod.isOpen(getCtx(), maxDate, MDocType.DOCBASETYPE_BankStatement))
+ if (!MPeriod.isOpen(getCtx(), minDate, MDocType.DOCBASETYPE_BankStatement, 0)
+ || !MPeriod.isOpen(getCtx(), maxDate, MDocType.DOCBASETYPE_BankStatement, 0))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
@@ -461,7 +464,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction
// Std Period open?
else
{
- if (!MPeriod.isOpen(getCtx(), getStatementDate(), MDocType.DOCBASETYPE_BankStatement))
+ if (!MPeriod.isOpen(getCtx(), getStatementDate(), MDocType.DOCBASETYPE_BankStatement, getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return false;
diff --git a/base/src/org/compiere/model/MCash.java b/base/src/org/compiere/model/MCash.java
index 0f906a3af0..7a7aac53fc 100644
--- a/base/src/org/compiere/model/MCash.java
+++ b/base/src/org/compiere/model/MCash.java
@@ -37,7 +37,11 @@ import org.compiere.util.TimeUtil;
*
* @author Jorg Janke
* @version $Id: MCash.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
- * @author victor.perez@e-evolution.com www.e-evolution.com FR [ 1866214 ] http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 1866214 ]
+ * @see http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
* BF [ 1831997 ] Cash journal allocation reversed
* BF [ 1894524 ] Pay an reversed invoice
@@ -349,7 +353,7 @@ public class MCash extends X_C_Cash implements DocAction
return DocAction.STATUS_Invalid;
// Std Period open?
- if (!MPeriod.isOpen(getCtx(), getDateAcct(), MDocType.DOCBASETYPE_CashJournal))
+ if (!MPeriod.isOpen(getCtx(), getDateAcct(), MDocType.DOCBASETYPE_CashJournal, getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
@@ -591,7 +595,7 @@ public class MCash extends X_C_Cash implements DocAction
}
// Can we delete posting
- if (!MPeriod.isOpen(getCtx(), this.getDateAcct(), MPeriodControl.DOCBASETYPE_CashJournal))
+ if (!MPeriod.isOpen(getCtx(), this.getDateAcct(), MPeriodControl.DOCBASETYPE_CashJournal, getAD_Org_ID()))
throw new IllegalStateException("@PeriodClosed@");
// Reverse Allocations
diff --git a/base/src/org/compiere/model/MInOut.java b/base/src/org/compiere/model/MInOut.java
index ea63bdcbc1..066f7ca9dd 100644
--- a/base/src/org/compiere/model/MInOut.java
+++ b/base/src/org/compiere/model/MInOut.java
@@ -43,8 +43,10 @@ import org.compiere.util.Msg;
* Modifications: Added the RMA functionality (Ashley Ramdass)
* @author Karsten Thiemann, Schaeffer AG
* Bug [ 1759431 ] Problems with VCreateFrom
- * @author victor.perez@e-evolution.com, e-Evolution
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
* FR [ 1948157 ] Is necessary the reference for document reverse
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @author Armen Rizal, Goodwill Consulting
* BF [ 1745154 ] Cost in Reversing Material Related Docs
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
@@ -1064,7 +1066,7 @@ public class MInOut extends X_M_InOut implements DocAction
return DocAction.STATUS_Invalid;
}
// Std Period open?
- if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType()))
+ if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
@@ -1979,7 +1981,7 @@ public class MInOut extends X_M_InOut implements DocAction
return false;
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
- if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType()))
+ if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return false;
diff --git a/base/src/org/compiere/model/MInventory.java b/base/src/org/compiere/model/MInventory.java
index b9af087239..b6f0b7a982 100644
--- a/base/src/org/compiere/model/MInventory.java
+++ b/base/src/org/compiere/model/MInventory.java
@@ -38,8 +38,10 @@ import org.compiere.util.Msg;
*
* @author Jorg Janke
* @version $Id: MInventory.java,v 1.3 2006/07/30 00:51:05 jjanke Exp $
- * @author victor.perez@e-evolution.com, e-Evolution
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
* FR [ 1948157 ] Is necessary the reference for document reverse
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @author Armen Rizal, Goodwill Consulting
* BF [ 1745154 ] Cost in Reversing Material Related Docs
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
@@ -327,7 +329,7 @@ public class MInventory extends X_M_Inventory implements DocAction
return DocAction.STATUS_Invalid;
// Std Period open?
- if (!MPeriod.isOpen(getCtx(), getMovementDate(), MDocType.DOCBASETYPE_MaterialPhysicalInventory))
+ if (!MPeriod.isOpen(getCtx(), getMovementDate(), MDocType.DOCBASETYPE_MaterialPhysicalInventory, getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
@@ -760,7 +762,7 @@ public class MInventory extends X_M_Inventory implements DocAction
return false;
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
- if (!MPeriod.isOpen(getCtx(), getMovementDate(), dt.getDocBaseType()))
+ if (!MPeriod.isOpen(getCtx(), getMovementDate(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return false;
diff --git a/base/src/org/compiere/model/MInvoice.java b/base/src/org/compiere/model/MInvoice.java
index 282d947a17..12eec0853e 100644
--- a/base/src/org/compiere/model/MInvoice.java
+++ b/base/src/org/compiere/model/MInvoice.java
@@ -46,8 +46,10 @@ import org.eevolution.model.MPPProductBOMLine;
*
* @author Jorg Janke
* @version $Id: MInvoice.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $
- * @author victor.perez@e-evolution.com
- * @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* Modifications: Added RMA functionality (Ashley Ramdass)
*/
public class MInvoice extends X_C_Invoice implements DocAction
@@ -1372,7 +1374,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
MDocType dt = MDocType.get(getCtx(), getC_DocTypeTarget_ID());
// Std Period open?
- if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType()))
+ if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
@@ -2201,7 +2203,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
return false;
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
- if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType()))
+ if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return false;
diff --git a/base/src/org/compiere/model/MJournal.java b/base/src/org/compiere/model/MJournal.java
index 1046e7fb7d..324e22d457 100644
--- a/base/src/org/compiere/model/MJournal.java
+++ b/base/src/org/compiere/model/MJournal.java
@@ -39,10 +39,12 @@ import org.compiere.util.Msg;
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
* BF [ 1619150 ] Usability/Consistency: reversed gl journal description
* BF [ 1775358 ] GL Journal DateAcct/C_Period_ID issue
- * @author victor.perez@e-evolution.com, e-Evolution
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
* FR [ 1948157 ] Is necessary the reference for document reverse
- * @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
+ * @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
* FR: [ 2214883 ] Remove SQL code and Replace for Query
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
*/
public class MJournal extends X_GL_Journal implements DocAction
{
@@ -162,7 +164,7 @@ public class MJournal extends X_GL_Journal implements DocAction
return;
if (getC_Period_ID() != 0)
return;
- int C_Period_ID = MPeriod.getC_Period_ID(getCtx(), DateAcct);
+ int C_Period_ID = MPeriod.getC_Period_ID(getCtx(), DateAcct, getAD_Org_ID());
if (C_Period_ID == 0)
log.warning("setDateAcct - Period not found");
else
@@ -403,7 +405,7 @@ public class MJournal extends X_GL_Journal implements DocAction
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
// Get Period
- MPeriod period = MPeriod.get (getCtx(), getDateAcct());
+ MPeriod period = MPeriod.get (getCtx(), getDateAcct(), getAD_Org_ID());
if (period == null)
{
log.warning("No Period for " + getDateAcct());
diff --git a/base/src/org/compiere/model/MJournalBatch.java b/base/src/org/compiere/model/MJournalBatch.java
index ae039d5cce..f8afddc524 100644
--- a/base/src/org/compiere/model/MJournalBatch.java
+++ b/base/src/org/compiere/model/MJournalBatch.java
@@ -36,9 +36,11 @@ import org.compiere.util.Msg;
* Journal Batch Model
*
* @author Jorg Janke
- * @author victor.perez@e-evolution.com, e-Evolution
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
* FR [ 1948157 ] Is necessary the reference for document reverse
- * @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
+ * @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @version $Id: MJournalBatch.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
*/
public class MJournalBatch extends X_GL_JournalBatch implements DocAction
@@ -168,7 +170,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction
return;
if (getC_Period_ID() != 0)
return;
- int C_Period_ID = MPeriod.getC_Period_ID(getCtx(), DateAcct);
+ int C_Period_ID = MPeriod.getC_Period_ID(getCtx(), DateAcct, getAD_Org_ID());
if (C_Period_ID == 0)
log.warning("Period not found");
else
@@ -308,7 +310,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
// Std Period open?
- if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType()))
+ if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
diff --git a/base/src/org/compiere/model/MMatchInv.java b/base/src/org/compiere/model/MMatchInv.java
index 6d144f5d9e..cd155a8bc8 100644
--- a/base/src/org/compiere/model/MMatchInv.java
+++ b/base/src/org/compiere/model/MMatchInv.java
@@ -40,7 +40,9 @@ import org.compiere.util.Env;
*
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
* BF [ 1926113 ] MMatchInv.getNewerDateAcct() should work in trx
- *
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @author Bayu Cahya, Sistematika
* BF [ 2240484 ] Re MatchingPO, MMatchPO doesn't contains Invoice info
*
@@ -358,7 +360,7 @@ public class MMatchInv extends X_M_MatchInv
{
if (isPosted())
{
- MPeriod.testPeriodOpen(getCtx(), getDateTrx(), MDocType.DOCBASETYPE_MatchInvoice);
+ MPeriod.testPeriodOpen(getCtx(), getDateTrx(), MDocType.DOCBASETYPE_MatchInvoice, getAD_Org_ID());
setPosted(false);
MFactAcct.deleteEx (Table_ID, get_ID(), get_TrxName());
}
diff --git a/base/src/org/compiere/model/MMatchPO.java b/base/src/org/compiere/model/MMatchPO.java
index d2fcf612f0..cd28a18564 100644
--- a/base/src/org/compiere/model/MMatchPO.java
+++ b/base/src/org/compiere/model/MMatchPO.java
@@ -46,6 +46,10 @@ import org.compiere.util.Env;
*
* @author Armen Rizal, Goodwill Consulting
* BF [ 2215840 ] MatchPO Bug Collection
+ *
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
*/
public class MMatchPO extends X_M_MatchPO
{
@@ -721,7 +725,7 @@ public class MMatchPO extends X_M_MatchPO
{
if (isPosted())
{
- MPeriod.testPeriodOpen(getCtx(), getDateTrx(), MDocType.DOCBASETYPE_MatchPO);
+ MPeriod.testPeriodOpen(getCtx(), getDateTrx(), MDocType.DOCBASETYPE_MatchPO, getAD_Org_ID());
setPosted(false);
MFactAcct.deleteEx (Table_ID, get_ID(), get_TrxName());
}
diff --git a/base/src/org/compiere/model/MMovement.java b/base/src/org/compiere/model/MMovement.java
index 1af915fdae..55bcb55a6b 100644
--- a/base/src/org/compiere/model/MMovement.java
+++ b/base/src/org/compiere/model/MMovement.java
@@ -37,9 +37,11 @@ import org.eevolution.model.MDDOrderLine;
* Inventory Movement Model
*
* @author Jorg Janke
- * @author victor.perez@e-evolution.com, e-Evolution
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
* FR [ 1948157 ] Is necessary the reference for document reverse
- * @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
+ * @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @author Armen Rizal, Goodwill Consulting
* BF [ 1745154 ] Cost in Reversing Material Related Docs
* @version $Id: MMovement.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
@@ -297,7 +299,7 @@ public class MMovement extends X_M_Movement implements DocAction
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
// Std Period open?
- if (!MPeriod.isOpen(getCtx(), getMovementDate(), dt.getDocBaseType()))
+ if (!MPeriod.isOpen(getCtx(), getMovementDate(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
@@ -860,7 +862,7 @@ public class MMovement extends X_M_Movement implements DocAction
return false;
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
- if (!MPeriod.isOpen(getCtx(), getMovementDate(), dt.getDocBaseType()))
+ if (!MPeriod.isOpen(getCtx(), getMovementDate(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return false;
diff --git a/base/src/org/compiere/model/MMovementConfirm.java b/base/src/org/compiere/model/MMovementConfirm.java
index 5b070c0345..341e194ab8 100644
--- a/base/src/org/compiere/model/MMovementConfirm.java
+++ b/base/src/org/compiere/model/MMovementConfirm.java
@@ -35,6 +35,10 @@ import org.compiere.util.Msg;
* Inventory Movement Confirmation
*
* @author Jorg Janke
+ *
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @version $Id: MMovementConfirm.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
*/
public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
@@ -293,7 +297,7 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
return DocAction.STATUS_Invalid;
// Std Period open?
- if (!MPeriod.isOpen(getCtx(), getUpdated(), MDocType.DOCBASETYPE_MaterialMovement))
+ if (!MPeriod.isOpen(getCtx(), getUpdated(), MDocType.DOCBASETYPE_MaterialMovement, getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
diff --git a/base/src/org/compiere/model/MOrder.java b/base/src/org/compiere/model/MOrder.java
index 4684b64486..12ae8edaae 100644
--- a/base/src/org/compiere/model/MOrder.java
+++ b/base/src/org/compiere/model/MOrder.java
@@ -47,6 +47,10 @@ import org.eevolution.model.MPPProductBOMLine;
* Use DocAction and C_DocTypeTarget_ID instead.
*
* @author Jorg Janke
+ *
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @version $Id: MOrder.java,v 1.5 2006/10/06 00:42:24 jjanke Exp $
*/
public class MOrder extends X_C_Order implements DocAction
@@ -1104,7 +1108,7 @@ public class MOrder extends X_C_Order implements DocAction
MDocType dt = MDocType.get(getCtx(), getC_DocTypeTarget_ID());
// Std Period open?
- if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType()))
+ if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
diff --git a/base/src/org/compiere/model/MPayment.java b/base/src/org/compiere/model/MPayment.java
index b18d74658a..36d4134186 100644
--- a/base/src/org/compiere/model/MPayment.java
+++ b/base/src/org/compiere/model/MPayment.java
@@ -62,12 +62,16 @@ import org.compiere.util.ValueNamePair;
* When Payment is posed, the Allocation is made
*
* @author Jorg Janke
- * @author victor.perez@e-evolution.com, e-Evolution
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
* FR [ 1948157 ] Is necessary the reference for document reverse
- * @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
- * @version $Id: MPayment.java,v 1.4 2006/10/02 05:18:39 jjanke Exp $
- * @author victor.perez@e-evolution.com www.e-evolution.com FR [ 1866214 ] http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335
+ * @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
+ * FR [ 1866214 ]
+ * @sse http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
+ *
* @author Carlos Ruiz - globalqss [ 2141475 ] Payment <> allocations must not be completed - implement lots of validations on prepareIt
+ * @version $Id: MPayment.java,v 1.4 2006/10/02 05:18:39 jjanke Exp $
*/
public final class MPayment extends X_C_Payment
implements DocAction, ProcessCall
@@ -1597,7 +1601,7 @@ public final class MPayment extends X_C_Payment
// Std Period open?
if (!MPeriod.isOpen(getCtx(), getDateAcct(),
- isReceipt() ? X_C_DocType.DOCBASETYPE_ARReceipt : X_C_DocType.DOCBASETYPE_APPayment))
+ isReceipt() ? X_C_DocType.DOCBASETYPE_ARReceipt : X_C_DocType.DOCBASETYPE_APPayment, getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
@@ -2274,7 +2278,7 @@ public final class MPayment extends X_C_Payment
// Std Period open?
Timestamp dateAcct = getDateAcct();
if (!MPeriod.isOpen(getCtx(), dateAcct,
- isReceipt() ? X_C_DocType.DOCBASETYPE_ARReceipt : X_C_DocType.DOCBASETYPE_APPayment))
+ isReceipt() ? X_C_DocType.DOCBASETYPE_ARReceipt : X_C_DocType.DOCBASETYPE_APPayment, getAD_Org_ID()))
dateAcct = new Timestamp(System.currentTimeMillis());
// Auto Reconcile if not on Bank Statement
diff --git a/base/src/org/compiere/model/MPeriod.java b/base/src/org/compiere/model/MPeriod.java
index 1a44c765de..53287759d9 100644
--- a/base/src/org/compiere/model/MPeriod.java
+++ b/base/src/org/compiere/model/MPeriod.java
@@ -44,6 +44,10 @@ import org.compiere.util.TimeUtil;
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
* BF [ 1779438 ] Minor auto period control bug
* BF [ 1893486 ] Auto Period Control return that period is always open
+ *
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
*/
public class MPeriod extends X_C_Period
{
@@ -52,6 +56,7 @@ public class MPeriod extends X_C_Period
* @param ctx context
* @param C_Period_ID id
* @return MPeriod
+ * @deprecated
*/
public static MPeriod get (Properties ctx, int C_Period_ID)
{
@@ -65,12 +70,33 @@ public class MPeriod extends X_C_Period
s_cache.put (key, retValue);
return retValue;
} // get
+
+ /**
+ * Get Period from Cache
+ * @param ctx context
+ * @param C_Period_ID id
+ * @param AD_Org_ID Organization
+ * @return MPeriod
+ */
+ public static MPeriod get (Properties ctx, int C_Period_ID, int AD_Org_ID)
+ {
+ Integer key = new Integer(C_Period_ID);
+ MPeriod retValue = (MPeriod) s_cache.get (key);
+ if (retValue != null)
+ return retValue;
+ //
+ retValue = new MPeriod (ctx, C_Period_ID, null);
+ if (retValue.get_ID () != 0)
+ s_cache.put (key, retValue);
+ return retValue;
+ } // get
/**
* Find standard Period of DateAcct based on Client Calendar
* @param ctx context
* @param DateAcct date
* @return active Period or null
+ * @deprecated
*/
public static MPeriod get (Properties ctx, Timestamp DateAcct)
{
@@ -127,12 +153,91 @@ public class MPeriod extends X_C_Period
+ " (AD_Client_ID=" + AD_Client_ID + ")");
return retValue;
} // get
+
+ /**
+ * Find standard Period of DateAcct based on Client Calendar
+ * @param ctx context
+ * @param DateAcct date
+ * @param AD_Org_ID Organization
+ * @return active Period or null
+ */
+ public static MPeriod get (Properties ctx, Timestamp DateAcct, int AD_Org_ID)
+ {
+ int AD_Client_ID = Env.getAD_Client_ID(ctx);
+ if (DateAcct == null)
+ return null;
+
+ int C_Calendar_ID = 0;
+ if (AD_Org_ID != 0)
+ {
+ MOrgInfo info = MOrgInfo.get(ctx, AD_Org_ID);
+ C_Calendar_ID = info.getC_Calendar_ID();
+ }
+ if (C_Calendar_ID == 0)
+ {
+ MClientInfo cInfo = MClientInfo.get(ctx);
+ C_Calendar_ID = cInfo.getC_Calendar_ID();
+ }
+
+ // Search in Cache first
+ Iterator it = s_cache.values().iterator();
+ while (it.hasNext())
+ {
+ MPeriod period = (MPeriod)it.next();
+ if (period.getC_Calendar_ID() == C_Calendar_ID && period.isStandardPeriod() && period.isInPeriod(DateAcct)
+ && period.getAD_Client_ID() == AD_Client_ID) // globalqss - CarlosRuiz - Fix [ 1820810 ] Wrong Period Assigned to Fact_Acct
+ return period;
+ }
+
+ // Get it from DB
+ MPeriod retValue = null;
+ String sql = "SELECT * "
+ + "FROM C_Period "
+ + "WHERE C_Year_ID IN "
+ + "(SELECT C_Year_ID FROM C_Year WHERE C_Calendar_ID= ?)"
+ + " AND ? BETWEEN TRUNC(StartDate) AND TRUNC(EndDate)"
+ + " AND IsActive=? AND PeriodType=?";
+
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ try
+ {
+ pstmt = DB.prepareStatement(sql, null);
+ pstmt.setInt (1, C_Calendar_ID);
+ pstmt.setTimestamp (2, TimeUtil.getDay(DateAcct));
+ pstmt.setString(3, "Y");
+ pstmt.setString(4, "S");
+ rs = pstmt.executeQuery();
+ while (rs.next())
+ {
+ MPeriod period = new MPeriod(ctx, rs, null);
+ Integer key = new Integer(period.getC_Period_ID());
+ s_cache.put (key, period);
+ if (period.isStandardPeriod())
+ retValue = period;
+ }
+ }
+ catch (SQLException e)
+ {
+ s_log.log(Level.SEVERE, "DateAcct=" + DateAcct, e);
+ }
+ finally
+ {
+ DB.close(rs, pstmt);
+ rs = null; pstmt = null;
+ }
+ if (retValue == null)
+ s_log.warning("No Standard Period for " + DateAcct
+ + " (AD_Client_ID=" + AD_Client_ID + ")");
+ return retValue;
+ } // get
/**
* Find valid standard Period of DateAcct based on Client Calendar
* @param ctx context
* @param DateAcct date
* @return C_Period_ID or 0
+ * @deprecated
*/
public static int getC_Period_ID (Properties ctx, Timestamp DateAcct)
{
@@ -141,6 +246,21 @@ public class MPeriod extends X_C_Period
return 0;
return period.getC_Period_ID();
} // getC_Period_ID
+
+ /**
+ * Find valid standard Period of DateAcct based on Client Calendar
+ * @param ctx context
+ * @param DateAcct date
+ * @param AD_Org_ID Organization
+ * @return C_Period_ID or 0
+ */
+ public static int getC_Period_ID (Properties ctx, Timestamp DateAcct, int AD_Org_ID)
+ {
+ MPeriod period = get (ctx, DateAcct, AD_Org_ID);
+ if (period == null)
+ return 0;
+ return period.getC_Period_ID();
+ } // getC_Period_ID
/**
* Is standard Period Open for Document Base Type
@@ -148,6 +268,7 @@ public class MPeriod extends X_C_Period
* @param DateAcct date
* @param DocBaseType base type
* @return true if open
+ * @deprecated
*/
public static boolean isOpen (Properties ctx, Timestamp DateAcct, String DocBaseType)
{
@@ -174,11 +295,45 @@ public class MPeriod extends X_C_Period
return open;
} // isOpen
+ /**
+ * Is standard Period Open for Document Base Type
+ * @param ctx context
+ * @param DateAcct date
+ * @param DocBaseType base type
+ * @param AD_Org_ID Organization
+ * @return true if open
+ */
+ public static boolean isOpen (Properties ctx, Timestamp DateAcct, String DocBaseType, int AD_Org_ID)
+ {
+ if (DateAcct == null)
+ {
+ s_log.warning("No DateAcct");
+ return false;
+ }
+ if (DocBaseType == null)
+ {
+ s_log.warning("No DocBaseType");
+ return false;
+ }
+ MPeriod period = MPeriod.get (ctx, DateAcct, AD_Org_ID);
+ if (period == null)
+ {
+ s_log.warning("No Period for " + DateAcct + " (" + DocBaseType + ")");
+ return false;
+ }
+ boolean open = period.isOpen(DocBaseType, DateAcct);
+ if (!open)
+ s_log.warning(period.getName()
+ + ": Not open for " + DocBaseType + " (" + DateAcct + ")");
+ return open;
+ } // isOpen
+
/**
* Find first Year Period of DateAcct based on Client Calendar
* @param ctx context
* @param DateAcct date
* @return active first Period
+ * @deprecated
*/
public static MPeriod getFirstInYear (Properties ctx, Timestamp DateAcct)
{
@@ -217,12 +372,63 @@ public class MPeriod extends X_C_Period
}
return retValue;
} // getFirstInYear
+
+ /**
+ * Find first Year Period of DateAcct based on Client Calendar
+ * @param ctx context
+ * @param DateAcct date
+ * @param AD_Org_ID TODO
+ * @return active first Period
+ */
+ public static MPeriod getFirstInYear (Properties ctx, Timestamp DateAcct, int AD_Org_ID)
+ {
+ MPeriod retValue = null;
+ int C_Calendar_ID = MPeriod.get(ctx, DateAcct, AD_Org_ID).getC_Calendar_ID();
+
+ String sql = "SELECT * "
+ + "FROM C_Period "
+ + "WHERE C_Year_ID IN "
+ + "(SELECT p.C_Year_ID "
+ + "FROM C_Year y"
+ + " INNER JOIN C_Period p ON (y.C_Year_ID=p.C_Year_ID) "
+ + "WHERE y.C_Calendar_ID=?"
+ + " AND ? BETWEEN StartDate AND EndDate)"
+ + " AND IsActive=? AND PeriodType=? "
+ + "ORDER BY StartDate";
+
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ try
+ {
+ pstmt = DB.prepareStatement(sql, null);
+ pstmt.setInt (1, C_Calendar_ID);
+ pstmt.setTimestamp (2, DateAcct);
+ pstmt.setString (3, "Y");
+ pstmt.setString (4, "S");
+ rs = pstmt.executeQuery();
+ if (rs.next()) // first only
+ retValue = new MPeriod(ctx, rs, null);
+ }
+ catch (SQLException e)
+ {
+ s_log.log(Level.SEVERE, sql, e);
+ }
+ finally
+ {
+ DB.close(rs, pstmt);
+ rs = null; pstmt = null;
+ }
+ return retValue;
+ } // getFirstInYear
/** Cache */
private static CCache s_cache = new CCache("C_Period", 10);
/** Logger */
- private static CLogger s_log = CLogger.getCLogger (MPeriod.class);
+ private static CLogger s_log = CLogger.getCLogger (MPeriod.class);
+
+ /** Calendar */
+ private int m_C_Calendar_ID = 0;
/**************************************************************************
@@ -553,6 +759,7 @@ public class MPeriod extends X_C_Period
* @param docBaseType
* @throws PeriodClosedException if period is closed
* @see #isOpen(Properties, Timestamp, String)
+ * @deprecated
*/
public static void testPeriodOpen(Properties ctx, Timestamp dateAcct, String docBaseType)
throws PeriodClosedException
@@ -566,9 +773,27 @@ public class MPeriod extends X_C_Period
* Conventient method for testing if a period is open
* @param ctx
* @param dateAcct
+ * @param docBaseType
+ * @param AD_Org_ID Organization
+ * @throws PeriodClosedException if period is closed
+ * @see #isOpen(Properties, Timestamp, String, int)
+ */
+ public static void testPeriodOpen(Properties ctx, Timestamp dateAcct, String docBaseType, int AD_Org_ID)
+ throws PeriodClosedException
+ {
+ if (!MPeriod.isOpen(ctx, dateAcct, docBaseType, AD_Org_ID)) {
+ throw new PeriodClosedException(dateAcct, docBaseType);
+ }
+ }
+
+ /**
+ * Conventient method for testing if a period is open
+ * @param ctx
+ * @param dateAcct
* @param C_DocType_ID
* @throws PeriodClosedException
* @see {@link #isOpen(Properties, Timestamp, String)}
+ * @deprecated
*/
public static void testPeriodOpen(Properties ctx, Timestamp dateAcct, int C_DocType_ID)
throws PeriodClosedException
@@ -576,4 +801,37 @@ public class MPeriod extends X_C_Period
MDocType dt = MDocType.get(ctx, C_DocType_ID);
testPeriodOpen(ctx, dateAcct, dt.getDocBaseType());
}
+
+ /**
+ * Conventient method for testing if a period is open
+ * @param ctx
+ * @param dateAcct
+ * @param C_DocType_ID
+ * @param AD_Org_ID Organization
+ * @throws PeriodClosedException
+ * @see {@link #isOpen(Properties, Timestamp, String, int)}
+ */
+ public static void testPeriodOpen(Properties ctx, Timestamp dateAcct, int C_DocType_ID, int AD_Org_ID)
+ throws PeriodClosedException
+ {
+ MDocType dt = MDocType.get(ctx, C_DocType_ID);
+ testPeriodOpen(ctx, dateAcct, dt.getDocBaseType(), AD_Org_ID);
+ }
+
+ /**
+ * Get Calendar of Period
+ * @return calendar
+ */
+ public int getC_Calendar_ID()
+ {
+ if (m_C_Calendar_ID == 0)
+ {
+ MYear year = (MYear) getC_Year();
+ if (year != null)
+ m_C_Calendar_ID = year.getC_Calendar_ID();
+ else
+ log.severe("@NotFound@ C_Year_ID=" + getC_Year_ID());
+ }
+ return m_C_Calendar_ID;
+ } // getC_Calendar_ID
} // MPeriod
diff --git a/base/src/org/compiere/model/MRequisition.java b/base/src/org/compiere/model/MRequisition.java
index 6e9d9a3d5b..d9b70e12b4 100644
--- a/base/src/org/compiere/model/MRequisition.java
+++ b/base/src/org/compiere/model/MRequisition.java
@@ -35,6 +35,10 @@ import org.compiere.util.Msg;
* Requisition Model
*
* @author Jorg Janke
+ *
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @version $Id: MRequisition.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $
*/
public class MRequisition extends X_M_Requisition implements DocAction
@@ -265,7 +269,7 @@ public class MRequisition extends X_M_Requisition implements DocAction
return DocAction.STATUS_Invalid;
// Std Period open?
- if (!MPeriod.isOpen(getCtx(), getDateDoc(), MDocType.DOCBASETYPE_PurchaseRequisition))
+ if (!MPeriod.isOpen(getCtx(), getDateDoc(), MDocType.DOCBASETYPE_PurchaseRequisition, getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
diff --git a/base/src/org/compiere/model/MTimeExpense.java b/base/src/org/compiere/model/MTimeExpense.java
index 747a90c8fe..5086481b16 100644
--- a/base/src/org/compiere/model/MTimeExpense.java
+++ b/base/src/org/compiere/model/MTimeExpense.java
@@ -36,6 +36,10 @@ import org.compiere.util.Msg;
* Time + Expense Model
*
* @author Jorg Janke
+ *
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @version $Id: MTimeExpense.java,v 1.4 2006/07/30 00:51:03 jjanke Exp $
*/
public class MTimeExpense extends X_S_TimeExpense implements DocAction
@@ -303,7 +307,7 @@ public class MTimeExpense extends X_S_TimeExpense implements DocAction
return DocAction.STATUS_Invalid;
// Std Period open? - AP (Reimbursement) Invoice
- if (!MPeriod.isOpen(getCtx(), getDateReport(), MDocType.DOCBASETYPE_APInvoice))
+ if (!MPeriod.isOpen(getCtx(), getDateReport(), MDocType.DOCBASETYPE_APInvoice, getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
diff --git a/base/src/org/compiere/model/X_AD_OrgInfo.java b/base/src/org/compiere/model/X_AD_OrgInfo.java
index 6c7070d8d7..cc9d957159 100644
--- a/base/src/org/compiere/model/X_AD_OrgInfo.java
+++ b/base/src/org/compiere/model/X_AD_OrgInfo.java
@@ -31,7 +31,7 @@ public class X_AD_OrgInfo extends PO implements I_AD_OrgInfo, I_Persistent
/**
*
*/
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 20081221L;
/** Standard Constructor */
public X_AD_OrgInfo (Properties ctx, int AD_OrgInfo_ID, String trxName)
@@ -113,6 +113,45 @@ public class X_AD_OrgInfo extends PO implements I_AD_OrgInfo, I_Persistent
return ii.intValue();
}
+ public I_C_Calendar getC_Calendar() throws RuntimeException
+ {
+ Class> clazz = MTable.getClass(I_C_Calendar.Table_Name);
+ I_C_Calendar result = null;
+ try {
+ Constructor> constructor = null;
+ constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});
+ result = (I_C_Calendar)constructor.newInstance(new Object[] {getCtx(), new Integer(getC_Calendar_ID()), get_TrxName()});
+ } catch (Exception e) {
+ log.log(Level.SEVERE, "(id) - Table=" + Table_Name + ",Class=" + clazz, e);
+ log.saveError("Error", "Table=" + Table_Name + ",Class=" + clazz);
+ throw new RuntimeException( e );
+ }
+ return result;
+ }
+
+ /** Set Calendar.
+ @param C_Calendar_ID
+ Accounting Calendar Name
+ */
+ public void setC_Calendar_ID (int C_Calendar_ID)
+ {
+ if (C_Calendar_ID < 1)
+ set_Value (COLUMNNAME_C_Calendar_ID, null);
+ else
+ set_Value (COLUMNNAME_C_Calendar_ID, Integer.valueOf(C_Calendar_ID));
+ }
+
+ /** Get Calendar.
+ @return Accounting Calendar Name
+ */
+ public int getC_Calendar_ID ()
+ {
+ Integer ii = (Integer)get_Value(COLUMNNAME_C_Calendar_ID);
+ if (ii == null)
+ return 0;
+ return ii.intValue();
+ }
+
/** Set Address.
@param C_Location_ID
Location or Address
@@ -136,6 +175,25 @@ public class X_AD_OrgInfo extends PO implements I_AD_OrgInfo, I_Persistent
return ii.intValue();
}
+ /** Set D-U-N-S.
+ @param DUNS
+ Dun & Bradstreet Number
+ */
+ public void setDUNS (String DUNS)
+ {
+ if (DUNS == null)
+ throw new IllegalArgumentException ("DUNS is mandatory.");
+ set_Value (COLUMNNAME_DUNS, DUNS);
+ }
+
+ /** Get D-U-N-S.
+ @return Dun & Bradstreet Number
+ */
+ public String getDUNS ()
+ {
+ return (String)get_Value(COLUMNNAME_DUNS);
+ }
+
/** Set Drop Ship Warehouse.
@param DropShip_Warehouse_ID
The (logical) warehouse to use for recording drop ship receipts and shipments.
@@ -159,25 +217,6 @@ public class X_AD_OrgInfo extends PO implements I_AD_OrgInfo, I_Persistent
return ii.intValue();
}
- /** Set D-U-N-S.
- @param DUNS
- Dun & Bradstreet Number
- */
- public void setDUNS (String DUNS)
- {
- if (DUNS == null)
- throw new IllegalArgumentException ("DUNS is mandatory.");
- set_Value (COLUMNNAME_DUNS, DUNS);
- }
-
- /** Get D-U-N-S.
- @return Dun & Bradstreet Number
- */
- public String getDUNS ()
- {
- return (String)get_Value(COLUMNNAME_DUNS);
- }
-
public I_M_Warehouse getM_Warehouse() throws RuntimeException
{
Class> clazz = MTable.getClass(I_M_Warehouse.Table_Name);
diff --git a/base/src/org/compiere/report/FinStatement.java b/base/src/org/compiere/report/FinStatement.java
index b77cf74e11..045b72212f 100644
--- a/base/src/org/compiere/report/FinStatement.java
+++ b/base/src/org/compiere/report/FinStatement.java
@@ -44,6 +44,10 @@ import org.compiere.util.Msg;
* @author Low Heng Sin
* - Remove update balance option to resolved Feature Request [ 1557707 ] and
* bug [1619917]
+ *
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
*/
public class FinStatement extends SvrProcess
{
@@ -269,7 +273,7 @@ public class FinStatement extends SvrProcess
m_acct = new MElementValue (getCtx(), p_Account_ID, get_TrxName());
if (!m_acct.isBalanceSheet())
{
- MPeriod first = MPeriod.getFirstInYear (getCtx(), p_DateAcct_From);
+ MPeriod first = MPeriod.getFirstInYear (getCtx(), p_DateAcct_From, p_AD_Org_ID);
if (first != null)
sb.append(" AND TRUNC(DateAcct) >= ").append(DB.TO_DATE(first.getStartDate()));
else
diff --git a/base/src/org/compiere/report/TrialBalance.java b/base/src/org/compiere/report/TrialBalance.java
index 52063921bf..54090323d0 100644
--- a/base/src/org/compiere/report/TrialBalance.java
+++ b/base/src/org/compiere/report/TrialBalance.java
@@ -37,6 +37,10 @@ import org.compiere.util.Language;
* Trial Balance
*
* @author Jorg Janke
+ *
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @version $Id: TrialBalance.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $
*/
public class TrialBalance extends SvrProcess
@@ -402,7 +406,7 @@ public class TrialBalance extends SvrProcess
m_acct = new MElementValue (getCtx(), p_Account_ID, get_TrxName());
if (!m_acct.isBalanceSheet())
{
- MPeriod first = MPeriod.getFirstInYear (getCtx(), p_DateAcct_From);
+ MPeriod first = MPeriod.getFirstInYear (getCtx(), p_DateAcct_From, p_AD_Org_ID);
if (first != null)
sql.append(" AND DateAcct >= ").append(DB.TO_DATE(first.getStartDate(), true));
else
diff --git a/base/src/org/eevolution/model/MDDOrder.java b/base/src/org/eevolution/model/MDDOrder.java
index ee6a0c5d0d..19ed2b915c 100644
--- a/base/src/org/eevolution/model/MDDOrder.java
+++ b/base/src/org/eevolution/model/MDDOrder.java
@@ -56,7 +56,10 @@ import org.compiere.util.Util;
* They are set in the process() method.
* Use DocAction and C_DocTypeTarget_ID instead.
*
- * @author Victor Perez,e-Evolution,SC
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * Original contributor of Distribution Functionality
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
*/
public class MDDOrder extends X_DD_Order implements DocAction
{
@@ -773,7 +776,7 @@ public class MDDOrder extends X_DD_Order implements DocAction
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
// Std Period open?
- if (!MPeriod.isOpen(getCtx(), getDateOrdered(), dt.getDocBaseType()))
+ if (!MPeriod.isOpen(getCtx(), getDateOrdered(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
diff --git a/base/src/org/eevolution/model/MHRProcess.java b/base/src/org/eevolution/model/MHRProcess.java
index 70c020b1bd..b3dcba07fb 100644
--- a/base/src/org/eevolution/model/MHRProcess.java
+++ b/base/src/org/eevolution/model/MHRProcess.java
@@ -48,7 +48,11 @@ import org.compiere.util.Util;
/**
* HR Process Model
*
- * @author e-Evolution, Mexico
+ * @author oscar.gomez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * Original contributor of Payroll Functionality
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @author Cristina Ghita, www.arhipac.ro
*/
public class MHRProcess extends X_HR_Process implements DocAction
@@ -193,8 +197,9 @@ public class MHRProcess extends X_HR_Process implements DocAction
}
// Std Period open?
+
MHRPeriod period = MHRPeriod.get(getCtx(), getHR_Period_ID());
- MPeriod.testPeriodOpen(getCtx(), period.getDateAcct(), getC_DocTypeTarget_ID());
+ MPeriod.testPeriodOpen(getCtx(), period.getDateAcct(), getC_DocTypeTarget_ID(), getAD_Org_ID());
// New or in Progress/Invalid
if ( DOCSTATUS_Drafted.equals(getDocStatus())
diff --git a/base/src/org/eevolution/model/MHRYear.java b/base/src/org/eevolution/model/MHRYear.java
index e1ad31db31..bf44b00f63 100644
--- a/base/src/org/eevolution/model/MHRYear.java
+++ b/base/src/org/eevolution/model/MHRYear.java
@@ -29,7 +29,12 @@ import org.compiere.util.TimeUtil;
/**
* MHRYear Year for a Payroll
*
- * @author Oscar Gómez Islas
+ * @author oscar.gomez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * Original contributor of Payroll Functionality
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
+
*/
public class MHRYear extends X_HR_Year
{
@@ -102,7 +107,7 @@ public class MHRYear extends X_HR_Year
if(C_Period_ID <= 0)
return false;
- MPeriod m_period = MPeriod.get(getCtx(), C_Period_ID);
+ MPeriod m_period = MPeriod.get(getCtx(), C_Period_ID, payroll.getAD_Org_ID());
X_HR_Period HR_Period = new X_HR_Period(getCtx(), 0, get_TrxName());
HR_Period.setAD_Org_ID(getAD_Org_ID());
HR_Period.setHR_Year_ID(getHR_Year_ID());
diff --git a/base/src/org/eevolution/model/MPPCostCollector.java b/base/src/org/eevolution/model/MPPCostCollector.java
index 44cceeffb9..172db9941d 100644
--- a/base/src/org/eevolution/model/MPPCostCollector.java
+++ b/base/src/org/eevolution/model/MPPCostCollector.java
@@ -61,10 +61,13 @@ import org.eevolution.exceptions.ActivityProcessedException;
/**
* PP Cost Collector Model
*
- * @author Victor Perez www.e-evolution.com
- * @version $Id: MPPCostCollector.java,v 1.1 2004/06/19 02:10:34 vpj-cd Exp $
+ * @author victor.perez@-evolution.com, e-Evolution http://www.e-evolution.com
+ * Original contributor of Manufacturing Standard Cost
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
*
- * @author Teo Sarca, www.arhipac.ro
+ * @author Teo Sarca, www.arhipac.ro
+ * @version $Id: MPPCostCollector.java,v 1.1 2004/06/19 02:10:34 vpj-cd Exp $
*/
public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
{
@@ -270,7 +273,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
return DocAction.STATUS_Invalid;
}
- MPeriod.testPeriodOpen(getCtx(), getMovementDate(), getC_DocTypeTarget_ID());
+ MPeriod.testPeriodOpen(getCtx(), getMovementDate(), getC_DocTypeTarget_ID(), getAD_Org_ID());
// Convert/Check DocType
setC_DocType_ID(getC_DocTypeTarget_ID());
@@ -902,10 +905,11 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
order.setIsSOTrx(false);
order.setC_DocTypeTarget_ID();
order.setDatePromised(datePromised);
- order.setDescription(getPP_Order().getDocumentNo());
+ order.setDescription(Msg.translate(getCtx(), MPPOrder.COLUMNNAME_PP_Order_ID) +":"+getPP_Order().getDocumentNo());
order.setDocStatus(MOrder.DOCSTATUS_Drafted);
order.setDocAction(MOrder.DOCACTION_Complete);
order.setAD_User_ID(getAD_User_ID());
+ order.setM_Warehouse_ID(getM_Warehouse_ID());
//order.setSalesRep_ID(getAD_User_ID());
order.saveEx();
addDescription(Msg.translate(getCtx(), "C_Order_ID")+": "+order.getDocumentNo());
@@ -932,6 +936,7 @@ public class MPPCostCollector extends X_PP_Cost_Collector implements DocAction
MOrderLine oline = new MOrderLine(order);
oline.setM_Product_ID(product.getM_Product_ID());
oline.setDescription(activity.getDescription());
+ oline.setM_Warehouse_ID(getM_Warehouse_ID());
oline.setQty(QtyOrdered);
//line.setPrice(m_product_po.getPricePO());
//oline.setPriceList(m_product_po.getPriceList());
diff --git a/migration/353a-trunk/oracle/403_FR2520591_CalendarToOrg.sql b/migration/353a-trunk/oracle/403_FR2520591_CalendarToOrg.sql
new file mode 100644
index 0000000000..ffca3da772
--- /dev/null
+++ b/migration/353a-trunk/oracle/403_FR2520591_CalendarToOrg.sql
@@ -0,0 +1,90 @@
+-- Jan 22, 2009 10:59:03 PM ECT
+-- Calendar
+INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,56678,190,0,19,228,'C_Calendar_ID',TO_DATE('2009-01-22 22:58:59','YYYY-MM-DD HH24:MI:SS'),100,'Accounting Calendar Name','D',22,'The Calendar uniquely identifies an accounting calendar. Multiple calendars can be used. For example you may need a standard calendar that runs from Jan 1 to Dec 31 and a fiscal calendar that runs from July 1 to June 30.','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Calendar',0,TO_DATE('2009-01-22 22:58:59','YYYY-MM-DD HH24:MI:SS'),100,0)
+;
+
+-- Jan 22, 2009 10:59:03 PM ECT
+-- Calendar
+INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=56678 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID)
+;
+
+-- Jan 22, 2009 10:59:08 PM ECT
+-- Calendar
+ALTER TABLE AD_OrgInfo ADD C_Calendar_ID NUMBER(10)
+;
+
+-- Jan 22, 2009 10:59:38 PM ECT
+-- Calendar
+INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,52075,56621,0,170,TO_DATE('2009-01-22 22:59:35','YYYY-MM-DD HH24:MI:SS'),100,'Bank account depending on currency will be used from this bank for doing transfers',22,'D','Y','Y','Y','N','N','N','N','N','Bank for transfers',TO_DATE('2009-01-22 22:59:35','YYYY-MM-DD HH24:MI:SS'),100)
+;
+
+-- Jan 22, 2009 10:59:38 PM ECT
+-- Calendar
+INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56621 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
+;
+
+-- Jan 22, 2009 10:59:39 PM ECT
+-- Calendar
+INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,56678,56622,0,170,TO_DATE('2009-01-22 22:59:38','YYYY-MM-DD HH24:MI:SS'),100,'Accounting Calendar Name',22,'D','The Calendar uniquely identifies an accounting calendar. Multiple calendars can be used. For example you may need a standard calendar that runs from Jan 1 to Dec 31 and a fiscal calendar that runs from July 1 to June 30.','Y','Y','Y','N','N','N','N','N','Calendar',TO_DATE('2009-01-22 22:59:38','YYYY-MM-DD HH24:MI:SS'),100)
+;
+
+-- Jan 22, 2009 10:59:39 PM ECT
+-- Calendar
+INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56622 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
+;
+
+-- Jan 22, 2009 10:59:41 PM ECT
+-- Calendar
+INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,DisplayLength,EntityType,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,52076,56623,0,170,TO_DATE('2009-01-22 22:59:39','YYYY-MM-DD HH24:MI:SS'),100,22,'D','Y','Y','Y','N','N','N','N','N','CashBook for transfers',TO_DATE('2009-01-22 22:59:39','YYYY-MM-DD HH24:MI:SS'),100)
+;
+
+-- Jan 22, 2009 10:59:41 PM ECT
+-- Calendar
+INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56623 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
+;
+
+-- Jan 22, 2009 10:59:44 PM ECT
+-- Calendar
+INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,52112,56624,0,170,TO_DATE('2009-01-22 22:59:41','YYYY-MM-DD HH24:MI:SS'),100,'This message will be displayed at the bottom of a receipt when doing a sales or purchase',1024,'D','Y','Y','Y','N','N','N','N','N','Receipt Footer Msg',TO_DATE('2009-01-22 22:59:41','YYYY-MM-DD HH24:MI:SS'),100)
+;
+
+-- Jan 22, 2009 10:59:44 PM ECT
+-- Calendar
+INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56624 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=56621
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=56623
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=56624
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=55416
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=1314
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=1315
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=56622
+;
+
diff --git a/migration/353a-trunk/postgresql/403_FR2520591_CalendarToOrg.sql b/migration/353a-trunk/postgresql/403_FR2520591_CalendarToOrg.sql
new file mode 100644
index 0000000000..7a81c06c0e
--- /dev/null
+++ b/migration/353a-trunk/postgresql/403_FR2520591_CalendarToOrg.sql
@@ -0,0 +1,90 @@
+-- Jan 22, 2009 10:59:03 PM ECT
+-- Calendar
+INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,56678,190,0,19,228,'C_Calendar_ID',TO_TIMESTAMP('2009-01-22 22:58:59','YYYY-MM-DD HH24:MI:SS'),100,'Accounting Calendar Name','D',22,'The Calendar uniquely identifies an accounting calendar. Multiple calendars can be used. For example you may need a standard calendar that runs from Jan 1 to Dec 31 and a fiscal calendar that runs from July 1 to June 30.','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Calendar',0,TO_TIMESTAMP('2009-01-22 22:58:59','YYYY-MM-DD HH24:MI:SS'),100,0)
+;
+
+-- Jan 22, 2009 10:59:03 PM ECT
+-- Calendar
+INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=56678 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID)
+;
+
+-- Jan 22, 2009 10:59:08 PM ECT
+-- Calendar
+ALTER TABLE AD_OrgInfo ADD COLUMN C_Calendar_ID NUMERIC(10)
+;
+
+-- Jan 22, 2009 10:59:38 PM ECT
+-- Calendar
+INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,52075,56621,0,170,TO_TIMESTAMP('2009-01-22 22:59:35','YYYY-MM-DD HH24:MI:SS'),100,'Bank account depending on currency will be used from this bank for doing transfers',22,'D','Y','Y','Y','N','N','N','N','N','Bank for transfers',TO_TIMESTAMP('2009-01-22 22:59:35','YYYY-MM-DD HH24:MI:SS'),100)
+;
+
+-- Jan 22, 2009 10:59:38 PM ECT
+-- Calendar
+INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56621 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
+;
+
+-- Jan 22, 2009 10:59:39 PM ECT
+-- Calendar
+INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,56678,56622,0,170,TO_TIMESTAMP('2009-01-22 22:59:38','YYYY-MM-DD HH24:MI:SS'),100,'Accounting Calendar Name',22,'D','The Calendar uniquely identifies an accounting calendar. Multiple calendars can be used. For example you may need a standard calendar that runs from Jan 1 to Dec 31 and a fiscal calendar that runs from July 1 to June 30.','Y','Y','Y','N','N','N','N','N','Calendar',TO_TIMESTAMP('2009-01-22 22:59:38','YYYY-MM-DD HH24:MI:SS'),100)
+;
+
+-- Jan 22, 2009 10:59:39 PM ECT
+-- Calendar
+INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56622 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
+;
+
+-- Jan 22, 2009 10:59:41 PM ECT
+-- Calendar
+INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,DisplayLength,EntityType,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,52076,56623,0,170,TO_TIMESTAMP('2009-01-22 22:59:39','YYYY-MM-DD HH24:MI:SS'),100,22,'D','Y','Y','Y','N','N','N','N','N','CashBook for transfers',TO_TIMESTAMP('2009-01-22 22:59:39','YYYY-MM-DD HH24:MI:SS'),100)
+;
+
+-- Jan 22, 2009 10:59:41 PM ECT
+-- Calendar
+INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56623 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
+;
+
+-- Jan 22, 2009 10:59:44 PM ECT
+-- Calendar
+INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,EntityType,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,Updated,UpdatedBy) VALUES (0,52112,56624,0,170,TO_TIMESTAMP('2009-01-22 22:59:41','YYYY-MM-DD HH24:MI:SS'),100,'This message will be displayed at the bottom of a receipt when doing a sales or purchase',1024,'D','Y','Y','Y','N','N','N','N','N','Receipt Footer Msg',TO_TIMESTAMP('2009-01-22 22:59:41','YYYY-MM-DD HH24:MI:SS'),100)
+;
+
+-- Jan 22, 2009 10:59:44 PM ECT
+-- Calendar
+INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=56624 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID)
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=56621
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=56623
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=56624
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y' WHERE AD_Field_ID=55416
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=1314
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=1315
+;
+
+-- Jan 22, 2009 11:00:10 PM ECT
+-- Calendar
+UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=56622
+;
+