svn commit: r1307303 - in /ofbiz/trunk/framework: common/config/general.properties webapp/src/org/ofbiz/webapp/ftl/OfbizCurrencyTransform.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1307303 - in /ofbiz/trunk/framework: common/config/general.properties webapp/src/org/ofbiz/webapp/ftl/OfbizCurrencyTransform.java

hansbak-2
Author: hansbak
Date: Fri Mar 30 08:29:28 2012
New Revision: 1307303

URL: http://svn.apache.org/viewvc?rev=1307303&view=rev
Log:
property to either show currency decimals when zero or not

Modified:
    ofbiz/trunk/framework/common/config/general.properties
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCurrencyTransform.java

Modified: ofbiz/trunk/framework/common/config/general.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/general.properties?rev=1307303&r1=1307302&r2=1307303&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/config/general.properties (original)
+++ ofbiz/trunk/framework/common/config/general.properties Fri Mar 30 08:29:28 2012
@@ -35,6 +35,12 @@ currency.decimal.format=#,##0.00
 # -- the default rounding for currency (used in OfbizCurrencyTransform.java)
 currency.rounding.default=10
 
+# -- the default check scale for integer currency enabled (Y|N) (used in OfbizCurrencyTransform.java)
+#When decimals are '00'
+# -- Y if you want to display only x , example : 10
+# -- N if you want to display x.00 , example : 10.00
+currency.scale.enabled=N
+
 # -- Properties fallback locale. Change this setting with caution. If you
 #    start getting "resource not found" exceptions, then there are
 #    properties missing in the locale you specified. This property does not

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCurrencyTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCurrencyTransform.java?rev=1307303&r1=1307302&r2=1307303&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCurrencyTransform.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCurrencyTransform.java Fri Mar 30 08:29:28 2012
@@ -128,6 +128,7 @@ public class OfbizCurrencyTransform impl
         // rounding should be handled by the code, however some times the numbers are coming from
         // someplace else (i.e. an integration)
         Integer roundingNumber = getInteger(args, "rounding");
+        String scaleEnabled = "N";
         Environment env = Environment.getCurrentEnvironment();
         BeanModel req = null;
         try {
@@ -141,12 +142,18 @@ public class OfbizCurrencyTransform impl
             // Get rounding from SystemProperty
             if (UtilValidate.isNotEmpty(delegator)) {
                 String roundingString = EntityUtilProperties.getPropertyValue("general.properties", "currency.rounding.default", "10", delegator);
+                scaleEnabled = EntityUtilProperties.getPropertyValue("general.properties", "currency.scale.enabled", "N", delegator);
                 if (UtilValidate.isInteger(roundingString)) roundingNumber = Integer.parseInt(roundingString);
             }
         }
         if (roundingNumber == null) roundingNumber = 10;
+        if ("Y".equals(scaleEnabled)) {
+            if (amount.stripTrailingZeros().scale() <= 0) {
+                roundingNumber = 0;
+            }
+        }
         final int rounding = roundingNumber;
-
+        
         return new Writer(out) {
             @Override
             public void write(char cbuf[], int off, int len) {