Hi Emad,

I really appreciate the answer especially when I wasn't clear with my screen 
shot. You answered my question.

I have some follow up questions:

1) The productCostPercentageFormula definition does the calculation via the 
"calcop" element. Where can I find information regarding how this mechanism 
works? i.e. What operations are allowed and syntax?

 2) I am trying to undestand the Ofbiz theory of cost calculations. I can see 
the screens for "Costs" in the Product listing. There is a lot of functionality 
there. Is there any good documentation on how to use that functionality?

3) Another qustion about custom extensions. When I look at the example Routing 
Tasks call TASK_COST there is an Estimate Calc Method called " Example task 
formula (qty * estimatedMilliSeconds * 10)". I have only found the string 
localization for this in CustomMethod.description.6000. But I don't know where 
the actual custom method is?

Thanks.

-----Original Message-----
From: Emad Radwan <eradwan1...@gmail.com> 
Sent: Saturday, July 13, 2024 2:21 AM
To: user@ofbiz.apache.org
Subject: Re: Cost calculations for product manufacturing

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