IDEMPIERE-2553 enter amounts without decimal separator / peer review

This commit is contained in:
Carlos Ruiz 2015-04-27 16:53:49 -05:00
parent 14ae36deff
commit ccb391e324
5 changed files with 140 additions and 19 deletions

View File

@ -26,18 +26,21 @@ UPDATE AD_Field SET IsDisplayed='Y', SeqNo=60, XPosition=1,Updated=TO_DATE('2015
UPDATE AD_Field SET SeqNo=70,Updated=TO_DATE('2015-04-27 10:36:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203798
-- Apr 27, 2015 9:53:47 PM CEST
UPDATE AD_Element SET Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode is no effect on multiplication and division operations. If 0 is entered it will work as usual."',Updated=TO_DATE('2015-04-27 21:53:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=202883
UPDATE AD_Element SET Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode has no effect on multiplication and division operations. If 0 is entered it will work as usual."',Updated=TO_DATE('2015-04-27 21:53:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=202883
;
-- Apr 27, 2015 9:53:47 PM CEST
UPDATE AD_Column SET ColumnName='AutomaticDecimalPlacesForAmoun', Name='Automatic Decimal Places For Amounts', Description='Automatically insert a decimal point', Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode is no effect on multiplication and division operations. If 0 is entered it will work as usual."' WHERE AD_Element_ID=202883
UPDATE AD_Column SET ColumnName='AutomaticDecimalPlacesForAmoun', Name='Automatic Decimal Places For Amounts', Description='Automatically insert a decimal point', Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode has no effect on multiplication and division operations. If 0 is entered it will work as usual."' WHERE AD_Element_ID=202883
;
-- Apr 27, 2015 9:53:47 PM CEST
UPDATE AD_InfoColumn SET ColumnName='AutomaticDecimalPlacesForAmoun', Name='Automatic Decimal Places For Amounts', Description='Automatically insert a decimal point', Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode is no effect on multiplication and division operations. If 0 is entered it will work as usual."' WHERE AD_Element_ID=202883 AND IsCentrallyMaintained='Y'
UPDATE AD_InfoColumn SET ColumnName='AutomaticDecimalPlacesForAmoun', Name='Automatic Decimal Places For Amounts', Description='Automatically insert a decimal point', Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode has no effect on multiplication and division operations. If 0 is entered it will work as usual."' WHERE AD_Element_ID=202883 AND IsCentrallyMaintained='Y'
;
-- Apr 27, 2015 9:53:47 PM CEST
UPDATE AD_Field SET Name='Automatic Decimal Places For Amounts', Description='Automatically insert a decimal point', Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode is no effect on multiplication and division operations. If 0 is entered it will work as usual."' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=202883) AND IsCentrallyMaintained='Y'
UPDATE AD_Field SET Name='Automatic Decimal Places For Amounts', Description='Automatically insert a decimal point', Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode has no effect on multiplication and division operations. If 0 is entered it will work as usual."' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=202883) AND IsCentrallyMaintained='Y'
;
SELECT register_migration_script('201504271636_IDEMPIERE-2553.sql') FROM dual
;

View File

@ -24,19 +24,22 @@ UPDATE AD_Field SET SeqNo=70,Updated=TO_TIMESTAMP('2015-04-27 10:36:32','YYYY-MM
;
-- Apr 27, 2015 9:53:47 PM CEST
UPDATE AD_Element SET Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode is no effect on multiplication and division operations. If 0 is entered it will work as usual."',Updated=TO_TIMESTAMP('2015-04-27 21:53:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=202883
UPDATE AD_Element SET Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode has no effect on multiplication and division operations. If 0 is entered it will work as usual."',Updated=TO_TIMESTAMP('2015-04-27 21:53:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=202883
;
-- Apr 27, 2015 9:53:47 PM CEST
UPDATE AD_Column SET ColumnName='AutomaticDecimalPlacesForAmoun', Name='Automatic Decimal Places For Amounts', Description='Automatically insert a decimal point', Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode is no effect on multiplication and division operations. If 0 is entered it will work as usual."' WHERE AD_Element_ID=202883
UPDATE AD_Column SET ColumnName='AutomaticDecimalPlacesForAmoun', Name='Automatic Decimal Places For Amounts', Description='Automatically insert a decimal point', Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode has no effect on multiplication and division operations. If 0 is entered it will work as usual."' WHERE AD_Element_ID=202883
;
-- Apr 27, 2015 9:53:47 PM CEST
UPDATE AD_InfoColumn SET ColumnName='AutomaticDecimalPlacesForAmoun', Name='Automatic Decimal Places For Amounts', Description='Automatically insert a decimal point', Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode is no effect on multiplication and division operations. If 0 is entered it will work as usual."' WHERE AD_Element_ID=202883 AND IsCentrallyMaintained='Y'
UPDATE AD_InfoColumn SET ColumnName='AutomaticDecimalPlacesForAmoun', Name='Automatic Decimal Places For Amounts', Description='Automatically insert a decimal point', Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode has no effect on multiplication and division operations. If 0 is entered it will work as usual."' WHERE AD_Element_ID=202883 AND IsCentrallyMaintained='Y'
;
-- Apr 27, 2015 9:53:47 PM CEST
UPDATE AD_Field SET Name='Automatic Decimal Places For Amounts', Description='Automatically insert a decimal point', Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode is no effect on multiplication and division operations. If 0 is entered it will work as usual."' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=202883) AND IsCentrallyMaintained='Y'
UPDATE AD_Field SET Name='Automatic Decimal Places For Amounts', Description='Automatically insert a decimal point', Help='i.e. "Entering 2 only results in a value of 0.02 for the entry. If you use the "." key during entry of a value, the decimal point is included at the place you specify. This mode has no effect on multiplication and division operations. If 0 is entered it will work as usual."' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=202883) AND IsCentrallyMaintained='Y'
;
SELECT register_migration_script('201504271636_IDEMPIERE-2553.sql') FROM dual
;

View File

@ -80,10 +80,10 @@ public interface I_AD_UserPreference
/** Column name AD_UserPreference_ID */
public static final String COLUMNNAME_AD_UserPreference_ID = "AD_UserPreference_ID";
/** Set User Preference */
/** Set AD_UserPreference_ID */
public void setAD_UserPreference_ID (int AD_UserPreference_ID);
/** Get User Preference */
/** Get AD_UserPreference_ID */
public int getAD_UserPreference_ID();
/** Column name AD_UserPreference_UU */
@ -104,6 +104,19 @@ public interface I_AD_UserPreference
/** Get Automatic Commit */
public boolean isAutoCommit();
/** Column name AutomaticDecimalPlacesForAmoun */
public static final String COLUMNNAME_AutomaticDecimalPlacesForAmoun = "AutomaticDecimalPlacesForAmoun";
/** Set Automatic Decimal Places For Amounts.
* Automatically insert a decimal point
*/
public void setAutomaticDecimalPlacesForAmoun (int AutomaticDecimalPlacesForAmoun);
/** Get Automatic Decimal Places For Amounts.
* Automatically insert a decimal point
*/
public int getAutomaticDecimalPlacesForAmoun();
/** Column name AutoNew */
public static final String COLUMNNAME_AutoNew = "AutoNew";
@ -142,6 +155,32 @@ public interface I_AD_UserPreference
*/
public boolean isActive();
/** Column name IsAddressLinesReverse */
public static final String COLUMNNAME_IsAddressLinesReverse = "IsAddressLinesReverse";
/** Set Reverse Address Lines.
* Print Address in reverse Order
*/
public void setIsAddressLinesReverse (boolean IsAddressLinesReverse);
/** Get Reverse Address Lines.
* Print Address in reverse Order
*/
public boolean isAddressLinesReverse();
/** Column name IsAllowCopy */
public static final String COLUMNNAME_IsAllowCopy = "IsAllowCopy";
/** Set Allow Copy.
* Determine if a column must be copied when pushing the button to copy record
*/
public void setIsAllowCopy (boolean IsAllowCopy);
/** Get Allow Copy.
* Determine if a column must be copied when pushing the button to copy record
*/
public boolean isAllowCopy();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";

View File

@ -29,7 +29,7 @@ public class X_AD_UserPreference extends PO implements I_AD_UserPreference, I_Pe
/**
*
*/
private static final long serialVersionUID = 20150418L;
private static final long serialVersionUID = 20150427L;
/** Standard Constructor */
public X_AD_UserPreference (Properties ctx, int AD_UserPreference_ID, String trxName)
@ -39,6 +39,8 @@ public class X_AD_UserPreference extends PO implements I_AD_UserPreference, I_Pe
{
setAD_User_ID (0);
setAD_UserPreference_ID (0);
setIsAllowCopy (false);
// N
} */
}
@ -98,8 +100,8 @@ public class X_AD_UserPreference extends PO implements I_AD_UserPreference, I_Pe
return ii.intValue();
}
/** Set User Preference.
@param AD_UserPreference_ID User Preference */
/** Set AD_UserPreference_ID.
@param AD_UserPreference_ID AD_UserPreference_ID */
public void setAD_UserPreference_ID (int AD_UserPreference_ID)
{
if (AD_UserPreference_ID < 1)
@ -108,8 +110,8 @@ public class X_AD_UserPreference extends PO implements I_AD_UserPreference, I_Pe
set_ValueNoCheck (COLUMNNAME_AD_UserPreference_ID, Integer.valueOf(AD_UserPreference_ID));
}
/** Get User Preference.
@return User Preference */
/** Get AD_UserPreference_ID.
@return AD_UserPreference_ID */
public int getAD_UserPreference_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_UserPreference_ID);
@ -153,6 +155,26 @@ public class X_AD_UserPreference extends PO implements I_AD_UserPreference, I_Pe
return false;
}
/** Set Automatic Decimal Places For Amounts.
@param AutomaticDecimalPlacesForAmoun
Automatically insert a decimal point
*/
public void setAutomaticDecimalPlacesForAmoun (int AutomaticDecimalPlacesForAmoun)
{
set_Value (COLUMNNAME_AutomaticDecimalPlacesForAmoun, Integer.valueOf(AutomaticDecimalPlacesForAmoun));
}
/** Get Automatic Decimal Places For Amounts.
@return Automatically insert a decimal point
*/
public int getAutomaticDecimalPlacesForAmoun ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AutomaticDecimalPlacesForAmoun);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Automatic New Record.
@param AutoNew Automatic New Record */
public void setAutoNew (boolean AutoNew)
@ -173,4 +195,52 @@ public class X_AD_UserPreference extends PO implements I_AD_UserPreference, I_Pe
}
return false;
}
/** Set Reverse Address Lines.
@param IsAddressLinesReverse
Print Address in reverse Order
*/
public void setIsAddressLinesReverse (boolean IsAddressLinesReverse)
{
set_Value (COLUMNNAME_IsAddressLinesReverse, Boolean.valueOf(IsAddressLinesReverse));
}
/** Get Reverse Address Lines.
@return Print Address in reverse Order
*/
public boolean isAddressLinesReverse ()
{
Object oo = get_Value(COLUMNNAME_IsAddressLinesReverse);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Allow Copy.
@param IsAllowCopy
Determine if a column must be copied when pushing the button to copy record
*/
public void setIsAllowCopy (boolean IsAllowCopy)
{
set_Value (COLUMNNAME_IsAllowCopy, Boolean.valueOf(IsAllowCopy));
}
/** Get Allow Copy.
@return Determine if a column must be copied when pushing the button to copy record
*/
public boolean isAllowCopy ()
{
Object oo = get_Value(COLUMNNAME_IsAllowCopy);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
}

View File

@ -18,7 +18,6 @@
package org.adempiere.webui.editor;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import org.adempiere.webui.ValuePreference;
@ -199,11 +198,18 @@ public class WNumberEditor extends WEditor implements ContextMenuListener
if(oldValue.toString().contains("."))
return oldValue;
Integer decimalPlaces = Integer.parseInt(Env.getCtx().getProperty("AutomaticDecimalPlacesForAmoun"));
int decimalPlaces = Env.getContextAsInt(Env.getCtx(), "AutomaticDecimalPlacesForAmoun");
if(decimalPlaces <= 0)
return oldValue;
BigDecimal newValue = oldValue.divide(BigDecimal.valueOf(Math.pow(10,decimalPlaces)),decimalPlaces,BigDecimal.ROUND_HALF_UP);
BigDecimal divisor;
if (decimalPlaces == 2) // most common case
divisor = Env.ONEHUNDRED;
else if (decimalPlaces == 1)
divisor = BigDecimal.TEN;
else
divisor = BigDecimal.TEN.pow(decimalPlaces);
BigDecimal newValue = oldValue.divide(divisor, decimalPlaces, BigDecimal.ROUND_HALF_UP);
return newValue;
} //getAddDecimalPlaces