This is an automated email from the ASF dual-hosted git repository. surajk pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/trunk by this push: new b4bdfcd Improved: Changed dependency of decimals, rounding static variables as per best practices in ebay component. (#28) b4bdfcd is described below commit b4bdfcdf929919e7972d4882074be68e39643e40 Author: Suraj Khurana <64310724+surajkhur...@users.noreply.github.com> AuthorDate: Sat Jun 13 14:42:35 2020 +0530 Improved: Changed dependency of decimals, rounding static variables as per best practices in ebay component. (#28) * Improved: Changed dependency of decimals, rounding static variables as per best practices in ebay component. (OFBIZ-11804) --- ebay/src/main/java/org/apache/ofbiz/ebay/EbayOrderServices.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ebay/src/main/java/org/apache/ofbiz/ebay/EbayOrderServices.java b/ebay/src/main/java/org/apache/ofbiz/ebay/EbayOrderServices.java index ae9e1f1..ae81d85 100644 --- a/ebay/src/main/java/org/apache/ofbiz/ebay/EbayOrderServices.java +++ b/ebay/src/main/java/org/apache/ofbiz/ebay/EbayOrderServices.java @@ -20,6 +20,7 @@ package org.apache.ofbiz.ebay; import java.math.BigDecimal; +import java.math.RoundingMode; import java.sql.Timestamp; import java.util.HashMap; import java.util.Iterator; @@ -35,6 +36,7 @@ import org.apache.ofbiz.base.util.UtilGenerics; import org.apache.ofbiz.base.util.UtilMisc; import org.apache.ofbiz.base.util.UtilProperties; import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.base.util.UtilNumber; import org.apache.ofbiz.base.util.UtilXml; import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.GenericEntityException; @@ -59,6 +61,9 @@ public class EbayOrderServices { private static final String RESOURCE = "EbayUiLabels"; private static final String MODULE = EbayOrderServices.class.getName(); + + private static final int DECIMALS = UtilNumber.getBigDecimalScale("order.decimals"); + private static final RoundingMode ROUNDING = UtilNumber.getRoundingMode("order.rounding"); private static boolean isGetSellerTransactionsCall = false; private static boolean isGetOrdersCall = false; private static boolean isGetMyeBaySellingCall = false; @@ -1269,7 +1274,7 @@ public class EbayOrderServices { itemPrice = (String) orderItem.get("amount"); } BigDecimal price = new BigDecimal(itemPrice); - price = price.setScale(ShoppingCart.scale, ShoppingCart.rounding); + price = price.setScale(DECIMALS, ROUNDING); HashMap<String, Object> attrs = new HashMap<>(); attrs.put("shipGroup", groupIdx); @@ -1294,7 +1299,7 @@ public class EbayOrderServices { cartItem.setQuantity(qty, dispatcher, cart, true, false); // locate the price verify it matches the expected price BigDecimal cartPrice = cartItem.getBasePrice(); - cartPrice = cartPrice.setScale(ShoppingCart.scale, ShoppingCart.rounding); + cartPrice = cartPrice.setScale(DECIMALS, ROUNDING); if (price.doubleValue() != cartPrice.doubleValue()) { // does not match; honor the price but hold the order for manual review cartItem.setIsModifiedPrice(true);