IDEMPIERE-452 Control dates / based on patch from Nicolas Micoud (nmicoud)
This commit is contained in:
parent
410a19b632
commit
0a5309d390
|
@ -0,0 +1,23 @@
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- Jan 25, 2014 2:39:55 PM COT
|
||||||
|
-- IDEMPIERE-452 Control dates
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutEngine.checkPeriodOpen',Updated=TO_DATE('2014-01-25 14:39:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3552
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 25, 2014 2:40:28 PM COT
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutEngine.checkPeriodOpen',Updated=TO_DATE('2014-01-25 14:40:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3579
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 25, 2014 2:40:49 PM COT
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutEngine.checkPeriodOpen',Updated=TO_DATE('2014-01-25 14:40:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3608
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 25, 2014 2:41:13 PM COT
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutEngine.checkPeriodOpen',Updated=TO_DATE('2014-01-25 14:41:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=14527
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201401251441_IDEMPIERE-452.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
-- Jan 25, 2014 2:39:55 PM COT
|
||||||
|
-- IDEMPIERE-452 Control dates
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutEngine.checkPeriodOpen',Updated=TO_TIMESTAMP('2014-01-25 14:39:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3552
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 25, 2014 2:40:28 PM COT
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutEngine.checkPeriodOpen',Updated=TO_TIMESTAMP('2014-01-25 14:40:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3579
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 25, 2014 2:40:49 PM COT
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutEngine.checkPeriodOpen',Updated=TO_TIMESTAMP('2014-01-25 14:40:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3608
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 25, 2014 2:41:13 PM COT
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutEngine.checkPeriodOpen',Updated=TO_TIMESTAMP('2014-01-25 14:41:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=14527
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201401251441_IDEMPIERE-452.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.sql.Timestamp;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.compiere.acct.Doc;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
|
||||||
|
@ -230,9 +231,59 @@ public class CalloutEngine implements Callout
|
||||||
if (value == null || !(value instanceof Timestamp))
|
if (value == null || !(value instanceof Timestamp))
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
mTab.setValue("DateAcct", value);
|
mTab.setValue("DateAcct", value);
|
||||||
return NO_ERROR;
|
return checkPeriodOpen (ctx, WindowNo, mTab, mField, value);
|
||||||
} // dateAcct
|
} // dateAcct
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Account Date is on a opened period
|
||||||
|
* @param ctx context
|
||||||
|
* @param WindowNo window no
|
||||||
|
* @param mTab tab
|
||||||
|
* @param mField field
|
||||||
|
* @param value value
|
||||||
|
* @return null or error message
|
||||||
|
*/
|
||||||
|
public String checkPeriodOpen (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
|
||||||
|
{
|
||||||
|
if (isCalloutActive()) // assuming it is resetting value
|
||||||
|
return NO_ERROR;
|
||||||
|
if (value == null || !(value instanceof Timestamp))
|
||||||
|
return NO_ERROR;
|
||||||
|
|
||||||
|
int orgID = 0;
|
||||||
|
if (mTab.getValue("AD_Org_ID") != null)
|
||||||
|
orgID = (Integer) mTab.getValue("AD_Org_ID");
|
||||||
|
|
||||||
|
int doctypeID = -1;
|
||||||
|
if (mTab.getValue("C_DocTypeTarget_ID") != null)
|
||||||
|
doctypeID = (Integer) mTab.getValue("C_DocTypeTarget_ID");
|
||||||
|
else if (mTab.getValue("C_DocType_ID") != null)
|
||||||
|
doctypeID = (Integer) mTab.getValue("C_DocType_ID");
|
||||||
|
|
||||||
|
String docBase = null;
|
||||||
|
if (doctypeID <= 0) {
|
||||||
|
if (MBankStatement.Table_Name.equals(mTab.getTableName()))
|
||||||
|
docBase = Doc.DOCTYPE_BankStatement;
|
||||||
|
else if (MBankStatementLine.Table_Name.equals(mTab.getTableName()))
|
||||||
|
docBase = Doc.DOCTYPE_BankStatement;
|
||||||
|
else if (MInventory.Table_Name.equals(mTab.getTableName()))
|
||||||
|
docBase = Doc.DOCTYPE_MatInventory;
|
||||||
|
else if (MMovement.Table_Name.equals(mTab.getTableName()))
|
||||||
|
docBase = Doc.DOCTYPE_MatMovement;
|
||||||
|
else if (MProduction.Table_Name.equals(mTab.getTableName()))
|
||||||
|
docBase = Doc.DOCTYPE_MatProduction;
|
||||||
|
else if (MRequisition.Table_Name.equals(mTab.getTableName()))
|
||||||
|
docBase = Doc.DOCTYPE_PurchaseRequisition;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doctypeID > 0) {
|
||||||
|
MPeriod.testPeriodOpen(ctx, (Timestamp)value, doctypeID, orgID);
|
||||||
|
} else if (docBase != null) {
|
||||||
|
MPeriod.testPeriodOpen(ctx, (Timestamp)value, docBase, orgID);
|
||||||
|
}
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rate - set Multiply Rate from Divide Rate and vice versa
|
* Rate - set Multiply Rate from Divide Rate and vice versa
|
||||||
* org.compiere.model.CalloutEngine.rate
|
* org.compiere.model.CalloutEngine.rate
|
||||||
|
|
Loading…
Reference in New Issue