You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2026/09/27 08:24:00 UTC

[jira] [Commented] (OFBIZ-13617) Three regressions in the minilang-to-Groovy conversion of CostServices.groovy

    [ https://issues.apache.org/jira/browse/OFBIZ-13617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18119788#comment-18119788 ] 

ASF subversion and git services commented on OFBIZ-13617:
---------------------------------------------------------

Commit e76ac3bf8ec2cb550a59928e8223f352f9cb5d76 in ofbiz-framework's branch refs/heads/trunk from Mridul Pathak
[ https://gitbox.apache.org/repos/asf?p=ofbiz-framework.git;h=e76ac3bf8e ]

Fixed: Three regressions in the minilang-to-Groovy conversion of CostServices.groovy (OFBIZ-13617)

- calculateProductCosts() referenced the undeclared totalCostByType instead of totalCostsByType, silently dropping prior task-cost accumulation for repeated cost types.
- calculateProductAverageCost() rounded totals once at the end instead of after every iteration (HALF_EVEN, 2 decimals) as mini-lang's <calculate> defaults to, which can shift the final average by a cent.
- updateProductAverageCostOnReceiveInventory() read the nonexistent property finaccout.decimals instead of finaccount.decimals, silently falling back to a hardcoded default.


> Three regressions in the minilang-to-Groovy conversion of CostServices.groovy
> -----------------------------------------------------------------------------
>
>                 Key: OFBIZ-13617
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-13617
>             Project: OFBiz
>          Issue Type: Bug
>          Components: product/catalog
>    Affects Versions: Upcoming Branch, 24.09.07
>            Reporter: Mridul Pathak
>            Assignee: Mridul Pathak
>            Priority: Major
>
> h3. 1. {{calculateProductCosts()}} throws on a common routing shape
> {code:java}
> totalCostsByType."${entry.key}" = entry.value + totalCostByType."${entry.key}"
> {code}
> Typo: {{totalCostByType}} (missing "s") is never declared — the real map is {{totalCostsByType}}. Throws {{MissingPropertyException}} whenever a product's routing has 2+ tasks contributing to the same cost-component type.
> h3. 2. {{calculateProductAverageCost()}} lost mini-lang's per-iteration rounding
> Mini-lang's {{<calculate>}} elements default to {{decimal-scale="2"}}/{{HALF_EVEN}} when omitted (confirmed in {{Calculate.java}}), so each loop iteration rounds the running total. The Groovy conversion accumulates unrounded and rounds only once at the end. Empirically confirmed with 3 items each contributing 0.125: mini-lang-style yields {{0.36}}, Groovy's single-round yields {{0.38}} — a materially different average cost whenever several inventory items have sub-cent-level contributions.
> h3. 3. {{updateProductAverageCostOnReceiveInventory()}} ignores the configured rounding precision
> {code:java}
> int roundingDecimal = UtilProperties.getPropertyAsInteger('arithmetic', 'finaccout.decimals', 2)
> {code}
> Typo'd property key ({{finaccout.decimals}}, missing "n") never matches the real {{finaccount.decimals}} key in {{arithmetic.properties}}, so this always silently falls back to the hardcoded default of 2, regardless of what an admin configures.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)