I have found a bug in the assetmaint plugin, specifically in the following file:

assetmaint/src/main/java/org/apache/ofbiz/assetmaint/FixedAssetMaintServices.java

Problematic code fragment:

EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(UtilMisc.toList(                     EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId),                     EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId), EntityCondition.makeCondition("availableToPromiseTotal", EntityOperator.GREATER_THAN, "0")), // Here is the bug
                    EntityOperator.AND);

Proposed fix:

EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(UtilMisc.toList(                     EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId),                     EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId), EntityCondition.makeCondition("availableToPromiseTotal", EntityOperator.GREATER_THAN, BigDecimal.Zero)),
                    EntityOperator.AND);

Rationale:

The availableToPromiseTotal field represents a numerical value (defined as a fixed-point number in the entity model), not a String. Passing the string "0" causes a type mismatch exception or a database parsing failure at runtime. Replacing it with BigDecimal.ZERO resolves the issue.

Best regards,
Tomek

Reply via email to