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-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 575defd  Improved: Changed decimals, rounding, zero static variables 
names as per best practices in manufacturing component. (#200)
575defd is described below

commit 575defd088b6e785049646f8f909e6a5da363cd8
Author: Suraj Khurana <64310724+surajkhur...@users.noreply.github.com>
AuthorDate: Fri Jun 12 16:35:36 2020 +0530

    Improved: Changed decimals, rounding, zero static variables names as per 
best practices in manufacturing component. (#200)
    
    (OFBIZ-11804)
    Also make them private data members of the class.
---
 .../jobshopmgt/ProductionRunServices.java              | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git 
a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
 
b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
index 1a10c4a..7ad8481 100644
--- 
a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
+++ 
b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
@@ -70,9 +70,9 @@ public class ProductionRunServices {
     private static final String RES_ORDER = "OrderErrorUiLabels";
     private static final String RES_PRODUCT = "ProductUiLabels";
 
-    public static final int decimals = 
UtilNumber.getBigDecimalScale("order.decimals");
-    public static final RoundingMode rounding = 
UtilNumber.getRoundingMode("finaccount.rounding");
-    public static final BigDecimal ZERO = BigDecimal.ZERO.setScale(decimals, 
rounding);
+    private static final int DECIMALS = 
UtilNumber.getBigDecimalScale("order.decimals");
+    private static final RoundingMode ROUNDING = 
UtilNumber.getRoundingMode("finaccount.rounding");
+    private static final BigDecimal ZERO = BigDecimal.ZERO.setScale(DECIMALS, 
ROUNDING);
 
     /**
      * Cancels a ProductionRun.
@@ -1209,7 +1209,7 @@ public class ProductionRunServices {
                     if (variableCost == null) {
                         variableCost = BigDecimal.ZERO;
                     }
-                    BigDecimal totalCost = 
fixedCost.add(variableCost.multiply(BigDecimal.valueOf(totalTime))).setScale(decimals,
 rounding);
+                    BigDecimal totalCost = 
fixedCost.add(variableCost.multiply(BigDecimal.valueOf(totalTime))).setScale(DECIMALS,
 ROUNDING);
                     // store the cost
                     Map<String, Object> inMap = UtilMisc.<String, 
Object>toMap("userLogin", userLogin, "workEffortId", productionRunTaskId);
                     inMap.put("costComponentTypeId", "ACTUAL_" + 
workEffortCostCalc.getString("costComponentTypeId"));
@@ -1253,8 +1253,8 @@ public class ProductionRunServices {
                     if (usageCost != null) {
                         usageCostAmount = 
usageCost.getBigDecimal("amount").multiply(BigDecimal.valueOf(actualMilliSeconds));
                     }
-                    BigDecimal fixedAssetCost = 
setupCostAmount.add(usageCostAmount).setScale(decimals, rounding);
-                    fixedAssetCost = 
fixedAssetCost.divide(BigDecimal.valueOf(3600000), decimals, rounding);
+                    BigDecimal fixedAssetCost = 
setupCostAmount.add(usageCostAmount).setScale(DECIMALS, ROUNDING);
+                    fixedAssetCost = 
fixedAssetCost.divide(BigDecimal.valueOf(3600000), DECIMALS, ROUNDING);
                     // store the cost
                     Map<String, Object> inMap = UtilMisc.<String, 
Object>toMap("userLogin", userLogin, 
                             "workEffortId", productionRunTaskId);
@@ -1288,7 +1288,7 @@ public class ProductionRunServices {
                     materialsCostByCurrency.put(currencyUomId, 
BigDecimal.ZERO);
                 }
                 BigDecimal materialsCost = 
materialsCostByCurrency.get(currencyUomId);
-                materialsCost = 
materialsCost.add(unitCost.multiply(quantity)).setScale(decimals, rounding);
+                materialsCost = 
materialsCost.add(unitCost.multiply(quantity)).setScale(DECIMALS, ROUNDING);
                 materialsCostByCurrency.put(currencyUomId, materialsCost);
             }
             for (String currencyUomId : materialsCostByCurrency.keySet()) {
@@ -2379,7 +2379,7 @@ public class ProductionRunServices {
                 try {
                     List<GenericValue> components = 
theTask.getRelated("WorkEffortGoodStandard", null, null, false);
                     for (GenericValue component : components) {
-                        BigDecimal totalRequiredMaterialQuantity = 
component.getBigDecimal("estimatedQuantity").multiply(totalQuantityProduced).divide(quantityToProduce,
 rounding);
+                        BigDecimal totalRequiredMaterialQuantity = 
component.getBigDecimal("estimatedQuantity").multiply(totalQuantityProduced).divide(quantityToProduce,
 ROUNDING);
                         // now get the units that have been already issued and 
subtract them
                         List<GenericValue> issuances = 
EntityQuery.use(delegator).from("WorkEffortAndInventoryAssign")
                                 .where("workEffortId", workEffortId, 
@@ -3426,7 +3426,7 @@ public class ProductionRunServices {
                 // will be equal to the components' standard costs
                 costCoefficient = BigDecimal.ONE;
             } else {
-                costCoefficient = inventoryItemCost.divide(packageCost, 10, 
rounding);
+                costCoefficient = inventoryItemCost.divide(packageCost, 10, 
ROUNDING);
             }
 
             // the components are retrieved

Reply via email to