This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/release24.09 by this push:
new ae45e302cf Fixed production run cost calculation logic to consider
returned items in material cost calculation. (#1182)
ae45e302cf is described below
commit ae45e302cf280411f27bf110aa0776936e386ae0
Author: Nameet Jain <[email protected]>
AuthorDate: Mon May 11 14:25:43 2026 +0530
Fixed production run cost calculation logic to consider returned items in
material cost calculation. (#1182)
Fixed: production run cost calculation logic to consider returned items
in material cost calculation.
(OFBIZ-13243)
---
.../jobshopmgt/ProductionRunServices.java | 23 ++++++++++++++++++++++
1 file changed, 23 insertions(+)
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 6da3dc1816..2f6942956c 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
@@ -1308,6 +1308,29 @@ public class ProductionRunServices {
materialsCost =
materialsCost.add(unitCost.multiply(quantity)).setScale(DECIMALS, ROUNDING);
materialsCostByCurrency.put(currencyUomId, materialsCost);
}
+ List<GenericValue> returns =
EntityQuery.use(delegator).from("WorkEffortAndInventoryProduced")
+ .where("workEffortId", productionRunTaskId).queryList();
+ for (GenericValue inventoryProduced : returns) {
+ // We check if it is a "return" (i.e. a product that was a
component of the task)
+ GenericValue component =
EntityQuery.use(delegator).from("WorkEffortGoodStandard")
+ .where("workEffortId", productionRunTaskId,
+ "productId",
inventoryProduced.get("productId"),
+ "workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED")
+ .queryFirst();
+ if (component != null) {
+ BigDecimal quantity =
inventoryProduced.getBigDecimal("quantityOnHandTotal");
+ BigDecimal unitCost =
inventoryProduced.getBigDecimal("unitCost");
+ if (UtilValidate.isNotEmpty(unitCost) &&
UtilValidate.isNotEmpty(quantity)) {
+ String currencyUomId =
inventoryProduced.getString("currencyUomId");
+ if
(!materialsCostByCurrency.containsKey(currencyUomId)) {
+ materialsCostByCurrency.put(currencyUomId,
BigDecimal.ZERO);
+ }
+ BigDecimal materialsCost =
materialsCostByCurrency.get(currencyUomId);
+ materialsCost =
materialsCost.subtract(unitCost.multiply(quantity)).setScale(DECIMALS,
ROUNDING);
+ materialsCostByCurrency.put(currencyUomId,
materialsCost);
+ }
+ }
+ }
for (String currencyUomId : materialsCostByCurrency.keySet()) {
BigDecimal materialsCost =
materialsCostByCurrency.get(currencyUomId);
Map<String, Object> inMap = UtilMisc.<String,
Object>toMap("userLogin", userLogin,