IDEMPIERE-704 The Min. value and Max. value validation of column is not working

This commit is contained in:
Heng Sin Low 2013-04-05 15:28:31 +08:00
parent 25524d3868
commit fc607f9fef
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,13 @@
-- Apr 5, 2013 3:20:49 PM MYT
-- IDEMPIERE-704 The Min. value and Max. value validation of column is not working
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Maximum value must be greater than or equal to minimum value.',200170,'D','3b17f511-d109-4e5a-9d22-3bd81699c4b4','MaxLessThanMin','Y',TO_DATE('2013-04-05 15:20:48','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2013-04-05 15:20:48','YYYY-MM-DD HH24:MI:SS'))
;
-- Apr 5, 2013 3:20:50 PM MYT
-- IDEMPIERE-704 The Min. value and Max. value validation of column is not working
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200170 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
SELECT register_migration_script('201304050725_IDEMPIERE-704.sql') FROM dual
;

View File

@ -0,0 +1,13 @@
-- Apr 5, 2013 3:20:49 PM MYT
-- IDEMPIERE-704 The Min. value and Max. value validation of column is not working
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('E','Maximum value must be greater than or equal to minimum value.',200170,'D','3b17f511-d109-4e5a-9d22-3bd81699c4b4','MaxLessThanMin','Y',TO_TIMESTAMP('2013-04-05 15:20:48','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2013-04-05 15:20:48','YYYY-MM-DD HH24:MI:SS'))
;
-- Apr 5, 2013 3:20:50 PM MYT
-- IDEMPIERE-704 The Min. value and Max. value validation of column is not working
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200170 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
SELECT register_migration_script('201304050725_IDEMPIERE-704.sql') FROM dual
;

View File

@ -16,6 +16,7 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.math.BigDecimal;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -219,6 +220,19 @@ public class MColumn extends X_AD_Column
} }
} }
if (!isVirtualColumn() && getValueMax() != null && getValueMin() != null)
{
try {
BigDecimal valueMax = new BigDecimal(getValueMax());
BigDecimal valueMin = new BigDecimal(getValueMin());
if (valueMax.compareTo(valueMin) < 0)
{
log.saveError("MaxLessThanMin", Msg.getElement(getCtx(), COLUMNNAME_ValueMax));
return false;
}
} catch (Exception e){}
}
/** Views are not updateable /** Views are not updateable
UPDATE AD_Column c UPDATE AD_Column c
SET IsUpdateable='N', IsAlwaysUpdateable='N' SET IsUpdateable='N', IsAlwaysUpdateable='N'