|
Author: hansbak
Date: Thu Mar 15 06:31:32 2012 New Revision: 1300817 URL: http://svn.apache.org/viewvc?rev=1300817&view=rev Log: make the currencyRounding a property variable, using the value which is hardcoded now. contribution of 'Tor' 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=1300817&r1=1300816&r2=1300817&view=diff ============================================================================== --- ofbiz/trunk/framework/common/config/general.properties (original) +++ ofbiz/trunk/framework/common/config/general.properties Thu Mar 15 06:31:32 2012 @@ -32,6 +32,9 @@ VISUAL_THEME=TOMAHAWK # -- the default decimal format for currency (used in UtilFormatOut.java) currency.decimal.format=#,##0.00 +# -- the default rounding for currency (used in OfbizCurrencyTransform.java) +currency.rounding.default=10 + # -- 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=1300817&r1=1300816&r2=1300817&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 Thu Mar 15 06:31:32 2012 @@ -37,6 +37,9 @@ import freemarker.template.TemplateTrans import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.base.util.UtilHttp; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.entity.Delegator; +import org.ofbiz.entity.util.EntityUtilProperties; /** * OfbizCurrencyTransform - Freemarker Transform for content links @@ -125,6 +128,22 @@ 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"); + Environment env = Environment.getCurrentEnvironment(); + BeanModel req = null; + try { + req = (BeanModel) env.getVariable("request"); + } catch (TemplateModelException e) { + Debug.logError(e.getMessage(), module); + } + if (req != null) { + HttpServletRequest request = (HttpServletRequest) req.getWrappedObject(); + Delegator delegator = (Delegator) request.getAttribute("delegator"); + // Get rounding from SystemProperty + if (UtilValidate.isNotEmpty(delegator)) { + String roundingString = EntityUtilProperties.getPropertyValue("general.properties", "currency.rounding.default", "10", delegator); + if (UtilValidate.isInteger(roundingString)) roundingNumber = Integer.parseInt(roundingString); + } + } if (roundingNumber == null) roundingNumber = 10; final int rounding = roundingNumber; |
| Free forum by Nabble | Edit this page |
