Hello Jeff,

The screenshot you included isn't visible to me so I'll assume that you're
talking about cost component calculation 'GEN_COST_CALC' with the
description 'Overhead cost (5 percent of total cost) for general costs'.

This cost calculation references custom method 'Formula that creates a cost
component equal to a percentage of total product cost'  that needs to be
defined first in the CustomMethods entity. I'm not sure if there's a screen
to maintain that but you can see this from web tools.

https://demo-stable.ofbiz.apache.org/webtools/control/FindGeneric?entityName=CustomMethod

One of the fields in the custom method is CustomMethodName which in this
case 'productCostPercentageFormula' for custom method 'PROD_PERC_FORMULA'.

If you search in the code you'll find it as follows:

<service name="productCostPercentageFormula" engine="simple"
            
location="component://product/minilang/product/cost/CostServices.xml"
invoke="productCostPercentageFormula" auth="true">
    <description>Formula that creates a cost component equal to a
percentage of total product cost</description>
    <implements service="productCostCalcInterface"/>
</service>


<simple-method method-name="productCostPercentageFormula"
short-description="Formula that creates a cost component equal to a
percentage of total product cost">
    <set field="productCostComponentCalc"
from-field="parameters.productCostComponentCalc"/>
    <set field="costComponentCalc" from-field="parameters.costComponentCalc"/>
    <set field="inputMap.productId"
from-field="productCostComponentCalc.productId"/>
    <set field="inputMap.currencyUomId" from-field="parameters.currencyUomId"/>
    <set field="inputMap.costComponentTypePrefix"
from-field="parameters.costComponentTypePrefix"/>
    <call-service service-name="getProductCost" in-map-name="inputMap">
        <result-to-field result-name="productCost"/>
    </call-service>
    <!--set field="productCostAdjustment" value="${parameters.baseCost
* costComponentCalc.fixedCost}" type="BigDecimal"/-->
    <calculate field="productCostAdjustment" type="BigDecimal"
decimal-scale="6">
        <calcop operator="multiply" field="costComponentCalc.fixedCost">
            <calcop operator="get" field="parameters.baseCost"/>
        </calcop>
    </calculate>
    <field-to-result field="productCostAdjustment"/>
</simple-method>


So I believe this is the workflow for adding and using

mew custom methods.


Regards,

Emad


On Sat, Jul 13, 2024 at 12:14 AM Jeff Christensen <jchristen...@1wa.org>
wrote:

> I am trying to understand how Ofbiz can use custom cost calculations. This
> is probably a big picture question where I don’t understand how custom
> functions are created and installed.
>
>
>
> If I look at the demo data I see that there is an option for “Cost Custom
> Method ID”
>
>
>
>
>
> Where is that function defined?
>
>
>
> How could I make my own?
>
>
>
> Thanks
>
>
>
>
>
>
>

Reply via email to