From 3fe1f58582c8104f4227ce9ba5efbd55cd57f0df Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Wed, 7 May 2014 11:44:44 +0000 Subject: [PATCH] Fixes a regression introduced by r1125215 "Add an automatic product price currency conversion which can be switched off in a properties file." r1125215 broke the possibility to set a currency to a product store. The automatic product price currency conversion should not be activated by default Correctly formats changes done by r1125215 in PriceServices.java git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1592977 13f79535-47bb-0310-9956-ffa450edef68 --- .../order/shoppingcart/ShoppingCartItem.java | 6 +++++- applications/product/config/catalog.properties | 2 +- .../org/ofbiz/product/price/PriceServices.java | 17 +++++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java index 6ae2d098e3..d1048d706c 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java @@ -1198,7 +1198,11 @@ public class ShoppingCartItem implements java.io.Serializable { } } } - priceContext.put("currencyUomIdTo", cart.getCurrency()); + if ("true".equals(UtilProperties.getPropertyValue("catalog.properties", "convertProductPriceCurrency"))){ + priceContext.put("currencyUomIdTo", cart.getCurrency()); + } else { + priceContext.put("currencyUomId", cart.getCurrency()); + } priceContext.put("prodCatalogId", this.getProdCatalogId()); priceContext.put("webSiteId", cart.getWebSiteId()); priceContext.put("productStoreId", cart.getProductStoreId()); diff --git a/applications/product/config/catalog.properties b/applications/product/config/catalog.properties index 61837d721f..c78cd8c2d7 100644 --- a/applications/product/config/catalog.properties +++ b/applications/product/config/catalog.properties @@ -43,4 +43,4 @@ image.management.autoApproveImage=Y image.management.multipleApproval=N # Automatic product price currency conversion -convertProductPriceCurrency=true +convertProductPriceCurrency=false diff --git a/applications/product/src/org/ofbiz/product/price/PriceServices.java b/applications/product/src/org/ofbiz/product/price/PriceServices.java index 3baf1ead44..4936142561 100644 --- a/applications/product/src/org/ofbiz/product/price/PriceServices.java +++ b/applications/product/src/org/ofbiz/product/price/PriceServices.java @@ -522,9 +522,9 @@ public class PriceServices { } // Convert the value to the price currency, if required - if("true".equals(UtilProperties.getPropertyValue("catalog.properties", "convertProductPriceCurrency"))){ + if ("true".equals(UtilProperties.getPropertyValue("catalog.properties", "convertProductPriceCurrency"))) { if (UtilValidate.isNotEmpty(currencyDefaultUomId) && UtilValidate.isNotEmpty(currencyUomIdTo) && !currencyDefaultUomId.equals(currencyUomIdTo)) { - if(UtilValidate.isNotEmpty(result)){ + if (UtilValidate.isNotEmpty(result)) { Map convertPriceMap = FastMap.newInstance(); for (Map.Entry entry : result.entrySet()) { BigDecimal tempPrice = BigDecimal.ZERO; @@ -545,22 +545,23 @@ public class PriceServices { else if (entry.getKey() == "listPrice") tempPrice = (BigDecimal) entry.getValue(); - if(tempPrice != null && tempPrice != BigDecimal.ZERO){ + if (tempPrice != null && tempPrice != BigDecimal.ZERO) { Map priceResults = FastMap.newInstance(); try { - priceResults = dispatcher.runSync("convertUom", UtilMisc.toMap("uomId", currencyDefaultUomId, "uomIdTo", currencyUomIdTo, "originalValue", tempPrice , "defaultDecimalScale" , Long.valueOf(2) , "defaultRoundingMode" , "HalfUp")); + priceResults = dispatcher.runSync("convertUom", UtilMisc. toMap("uomId", currencyDefaultUomId, "uomIdTo", currencyUomIdTo, + "originalValue", tempPrice, "defaultDecimalScale", Long.valueOf(2), "defaultRoundingMode", "HalfUp")); if (ServiceUtil.isError(priceResults) || (priceResults.get("convertedValue") == null)) { - Debug.logWarning("Unable to convert " + entry.getKey() + " for product " + productId , module); - } + Debug.logWarning("Unable to convert " + entry.getKey() + " for product " + productId, module); + } } catch (GenericServiceException e) { Debug.logError(e, module); } convertPriceMap.put(entry.getKey(), priceResults.get("convertedValue")); - }else{ + } else { convertPriceMap.put(entry.getKey(), entry.getValue()); } } - if(UtilValidate.isNotEmpty(convertPriceMap)){ + if (UtilValidate.isNotEmpty(convertPriceMap)) { convertPriceMap.put("currencyUsed", currencyUomIdTo); result = convertPriceMap; }