Thanks for everyone's feedback.

I have gone through most of the online documentation for both users and devs. 

Emad, I think your overall sentiment that I need to dig into DB and code is 
sound.

Regarding using the CostComponentCalculations I am also stuck with our current 
business model. I am trying to at least have a plan for how I would implement 
our current business practices even if I take it slowly with some 
simplifications.

Our business model has us doing most sales (and thus production) annually for 
our customers. This also drives our supplier costs in that we use our renewal 
forecasts to set our production targets which sets our volume discounts from 
our suppliers.

I am in the process of setting this up in Ofbiz.

In SFA create Sales Forecasts for each renewal target customer. With a break 
down of product volume that they will purchase.

In Products set up the supplier component prices. Set up Price Rules based 
mostly on volumes.

Set up the Costing Rules based on taking the Forecasts and calculating how much 
it would cost to manufacture an amount to meet the Sales Forecasts.


-----Original Message-----
From: Emad Radwan <eradwan1...@gmail.com> 
Sent: Sunday, July 14, 2024 1:51 AM
To: user@ofbiz.apache.org
Subject: Re: Cost calculations for product manufacturing

Hi,

I agree that the concept of Custom Methods is a great way to customize specific 
calculations but I also think it's an advanced concept that you only tackle if 
needed. Make sure first that your requirements can't be covered in 
CostComponentCalculations. Ofbiz provides many structures to configure costs on 
the level of BOM - Material -, Routing Task, and Product in general. The code 
first considers these configurations before checking if a custom method is 
defined.

From the demo data, costs are configured for product 'PROD_MANUF' that has a 
Routing, one Routing Task, and a Bill of Materials. You can check that in the 
relevant costs screens under Products, Fixed Assets and Manufacturing.

Or, if you like me understand better from the data itself, you can check the 
following tables - from web tools -:

ProductAssoc -> BOM
CostComponent
CostComponentCalculation
WorkEffortCostCalc -> links a routing task to a calculation 
ProductCostComponentCalc -> same but for product level

This is not the whole picture and maybe not 100% correct as I'm not an Ofbiz 
expert but it will tell generally how costs are configured.

The real challenge for me currently if someone can help is how to decide on the 
numbers in a cost calculation; I mean, based on what you put the fixed and 
variable parts in a cost calculation.

Regards,
Emad

On Sat, Jul 13, 2024 at 11:43 PM Omar Abdullwahhab < 
omar.abdullwah...@gmail.com> wrote:

> Also here is a link for the beginners  tutorial
>
> https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+Tutorial+-+A+B
> eginners+Development+Guide
>
> On Sat, Jul 13, 2024 at 11:28 PM Omar Abdullwahhab < 
> omar.abdullwah...@gmail.com> wrote:
>
> > Hi Jeff,
> > Here are some notes that may help.
> > 1. regarding the first question, what you have seen is in xml 
> > containing calcop element ,
> >      for ofbiz its called Minilang which you can call it an 
> > intermediate programming language that you can use it to make small 
> > programming tasks (business logic),
> >      and later this XML element will be interpreted by Java code, 
> > and for your information this MINIALNG will be deprecated as per the 
> > ofbiz community and will be replaced by groovy scripts.
> > ( 2. & 3 ) . regarding  to the second and third question I know that 
> > you seem to be very new to the OFBIZ like me , so take the time to 
> > read the getting started for both developers and business users, 
> > Here is a link 
> > https://cwiki.apache.org/confluence/display/OFBIZ/Home
> >
> >
> > On Sat, Jul 13, 2024 at 9:18 PM Jeff Christensen 
> > <jchristen...@1wa.org>
> > wrote:
> >
> >> 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?enti
> tyName=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
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >>
> >
> >
> > --
> >
> > *عـمــر عـبد الــوهــــاب*
> >
> > *جــوال : 0550677295*
> >
>
>
> --
>
> *عـمــر عـبد الــوهــــاب*
>
> *جــوال : 0550677295*
>

Reply via email to