IDEMPIERE-5052 Date Min/Max Validation wrong with 5 digit years (#1016)
* IDEMPIERE-5052 Date Min/Max Validation wrong with 5 digit years * IDEMPIERE-5052 Date Min/Max Validation wrong with 5 digit years / enable for Cost+Price and String
This commit is contained in:
parent
0e58458114
commit
feebea8691
|
@ -0,0 +1,15 @@
|
|||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- IDEMPIERE-5052 Date Min/Max Validation wrong with 5 digit years
|
||||
-- Nov 30, 2021, 5:14:36 PM CET
|
||||
UPDATE AD_Field SET DisplayLogic='@AD_Reference_ID@=11 | @AD_Reference_ID@=12 | @AD_Reference_ID@=15 | @AD_Reference_ID@=22 | @AD_Reference_ID@=29 | @AD_Reference_ID@=37 | @AD_Reference_ID@=10', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-11-30 17:14:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2574
|
||||
;
|
||||
|
||||
-- Nov 30, 2021, 5:14:41 PM CET
|
||||
UPDATE AD_Field SET DisplayLogic='@AD_Reference_ID@=11 | @AD_Reference_ID@=12 | @AD_Reference_ID@=15 | @AD_Reference_ID@=22 | @AD_Reference_ID@=29 | @AD_Reference_ID@=37 | @AD_Reference_ID@=10', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-11-30 17:14:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2573
|
||||
;
|
||||
|
||||
SELECT register_migration_script('202111301716_IDEMPIERE-5052.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
-- IDEMPIERE-5052 Date Min/Max Validation wrong with 5 digit years
|
||||
-- Nov 30, 2021, 5:14:36 PM CET
|
||||
UPDATE AD_Field SET DisplayLogic='@AD_Reference_ID@=11 | @AD_Reference_ID@=12 | @AD_Reference_ID@=15 | @AD_Reference_ID@=22 | @AD_Reference_ID@=29 | @AD_Reference_ID@=37 | @AD_Reference_ID@=10', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-11-30 17:14:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2574
|
||||
;
|
||||
|
||||
-- Nov 30, 2021, 5:14:41 PM CET
|
||||
UPDATE AD_Field SET DisplayLogic='@AD_Reference_ID@=11 | @AD_Reference_ID@=12 | @AD_Reference_ID@=15 | @AD_Reference_ID@=22 | @AD_Reference_ID@=29 | @AD_Reference_ID@=37 | @AD_Reference_ID@=10', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-11-30 17:14:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2573
|
||||
;
|
||||
|
||||
SELECT register_migration_script('202111301716_IDEMPIERE-5052.sql') FROM dual
|
||||
;
|
||||
|
|
@ -23,6 +23,7 @@ import java.math.BigDecimal;
|
|||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -747,6 +748,13 @@ public class POInfo implements Serializable
|
|||
return "LessThanMinValue"+";"+m_columns[index].ValueMin_BD.toPlainString();
|
||||
}
|
||||
}
|
||||
else if (value instanceof Timestamp && m_columns[index].ValueMin_TS != null) // Date
|
||||
{
|
||||
if (((Timestamp) value).before(m_columns[index].ValueMin_TS))
|
||||
{
|
||||
return "LessThanMinValue"+";"+m_columns[index].ValueMin;
|
||||
}
|
||||
}
|
||||
else // String
|
||||
{
|
||||
int comp = m_columns[index].ValueMin.compareTo(value.toString());
|
||||
|
@ -774,6 +782,13 @@ public class POInfo implements Serializable
|
|||
return "MoreThanMaxValue"+";"+m_columns[index].ValueMax_BD.toPlainString();
|
||||
}
|
||||
}
|
||||
else if (value instanceof Timestamp && m_columns[index].ValueMax_TS != null) // Date
|
||||
{
|
||||
if (((Timestamp) value).after(m_columns[index].ValueMax_TS))
|
||||
{
|
||||
return "MoreThanMaxValue"+";"+m_columns[index].ValueMax;
|
||||
}
|
||||
}
|
||||
else // String
|
||||
{
|
||||
int comp = m_columns[index].ValueMax.compareTo(value.toString());
|
||||
|
|
|
@ -18,9 +18,12 @@ package org.compiere.model;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
/**
|
||||
* PO Info Column Info Value Object
|
||||
|
@ -33,7 +36,7 @@ public class POInfoColumn implements Serializable
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3882249785085847367L;
|
||||
private static final long serialVersionUID = -6550300505836470875L;
|
||||
|
||||
/** Used by Remote FinReport */
|
||||
/**
|
||||
|
@ -106,24 +109,38 @@ public class POInfoColumn implements Serializable
|
|||
//
|
||||
FieldLength = fieldLength;
|
||||
ValueMin = valueMin;
|
||||
try
|
||||
{
|
||||
if (valueMin != null && valueMin.length() > 0)
|
||||
ValueMin_BD = new BigDecimal(valueMin);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CLogger.get().log(Level.SEVERE, "ValueMin=" + valueMin, ex);
|
||||
if (!Util.isEmpty(ValueMin)) {
|
||||
try {
|
||||
ValueMin_BD = new BigDecimal(ValueMin);
|
||||
} catch (Exception ex) {
|
||||
ValueMin_BD = null;
|
||||
}
|
||||
try {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
ValueMin_TS = new java.sql.Timestamp(dateFormat.parse(ValueMin).getTime());
|
||||
} catch (Exception ex) {
|
||||
ValueMin_TS = null;
|
||||
}
|
||||
if (ValueMin_BD == null && ValueMin_TS == null) {
|
||||
CLogger.get().log(Level.SEVERE, "ValueMin cannot be parsed to a number or date = " + ValueMin);
|
||||
}
|
||||
}
|
||||
ValueMax = valueMax;
|
||||
try
|
||||
{
|
||||
if (valueMax != null && valueMax.length() > 0)
|
||||
ValueMax_BD = new BigDecimal(valueMax);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CLogger.get().log(Level.SEVERE, "ValueMax=" + valueMax, ex);
|
||||
if (!Util.isEmpty(ValueMax)) {
|
||||
try {
|
||||
ValueMax_BD = new BigDecimal(ValueMax);
|
||||
} catch (Exception ex) {
|
||||
ValueMax_BD = null;
|
||||
}
|
||||
try {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
ValueMax_TS = new java.sql.Timestamp(dateFormat.parse(ValueMax).getTime());
|
||||
} catch (Exception ex) {
|
||||
ValueMax_TS = null;
|
||||
}
|
||||
if (ValueMax_BD == null && ValueMax_TS == null) {
|
||||
CLogger.get().log(Level.SEVERE, "ValueMax cannot be parsed to a number or date = " + ValueMax);
|
||||
}
|
||||
}
|
||||
IsTranslated = isTranslated;
|
||||
IsEncrypted = isEncrypted;
|
||||
|
@ -179,6 +196,10 @@ public class POInfoColumn implements Serializable
|
|||
public BigDecimal ValueMin_BD = null;
|
||||
/** Max Value */
|
||||
public BigDecimal ValueMax_BD = null;
|
||||
/** Min Value */
|
||||
public Timestamp ValueMin_TS = null;
|
||||
/** Max Value */
|
||||
public Timestamp ValueMax_TS = null;
|
||||
|
||||
/**
|
||||
* String representation
|
||||
|
|
Loading…
Reference in New Issue