svn commit: r831099 - in /ofbiz/trunk/applications: manufacturing/data/ product/data/ product/entitydef/ product/script/org/ofbiz/product/cost/ product/servicedef/ product/webapp/catalog/WEB-INF/ product/widget/catalog/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r831099 - in /ofbiz/trunk/applications: manufacturing/data/ product/data/ product/entitydef/ product/script/org/ofbiz/product/cost/ product/servicedef/ product/webapp/catalog/WEB-INF/ product/widget/catalog/

jacopoc
Author: jacopoc
Date: Thu Oct 29 21:38:18 2009
New Revision: 831099

URL: http://svn.apache.org/viewvc?rev=831099&view=rev
Log:
Added the ability to define cost component formulae to a product: new ProductCostComponentCalc entity and crud services, and ui to manage the information. Modified standard costing calculation service to use the new entity. Also implemented a custom method (cost formula) that adds a percentage based adjustment

Modified:
    ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml
    ofbiz/trunk/applications/product/data/ProductTypeData.xml
    ofbiz/trunk/applications/product/entitydef/entitymodel.xml
    ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml
    ofbiz/trunk/applications/product/servicedef/services_cost.xml
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
    ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml
    ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml

Modified: ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml?rev=831099&r1=831098&r2=831099&view=diff
==============================================================================
--- ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml (original)
+++ ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml Thu Oct 29 21:38:18 2009
@@ -44,7 +44,6 @@
     <WorkEffortAssoc workEffortIdFrom="DEFAULT_ROUTING" workEffortIdTo="DEFAULT_TASK" workEffortAssocTypeId="ROUTING_COMPONENT" sequenceNum="10" fromDate="2004-09-24 15:09:38.736"/>
 
     <!-- Formulae -->
-    <CustomMethodType customMethodTypeId="COST_FORMULA" description="Formula for calculating costs for tasks"/>
     <CustomMethodType customMethodTypeId="TASK_FORMULA" description="Formula for calculating time estimates for tasks"/>
     <CustomMethodType customMethodTypeId="BOM_FORMULA" description="Formula for calculating material estimates for boms"/>
     <CustomMethodType customMethodTypeId="DEPRECIATION_FORMULA" description="Formula for calculating depreciatiion for fixed asset"/>
@@ -52,7 +51,7 @@
     <!--Depreciation Formulae-->
     <CustomMethod customMethodId="STR_LINE_DEP_FORMULA" customMethodTypeId="DEPRECIATION_FORMULA" customMethodName="straightLineDepreciation" description="Straight Line depreciatiion algorithm for fixed asset((purchaseCost - salvageCost)/expectedLifeInYears)"/>
     <CustomMethod customMethodId="DBL_DECL_DEP_FORMULA" customMethodTypeId="DEPRECIATION_FORMULA" customMethodName="doubleDecliningBalanceDepreciation" description="Double decline depreciatiion algorithm for fixed asset((NetBookValue - salvageCost)*2/remainingLifeInYears)"/>
-
+    
     <WebSite webSiteId="MANUFACTURING" siteName="Manufacturing Manager" visualThemeSetId="BACKOFFICE"/>
 
 </entity-engine-xml>

Modified: ofbiz/trunk/applications/product/data/ProductTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductTypeData.xml?rev=831099&r1=831098&r2=831099&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/data/ProductTypeData.xml (original)
+++ ofbiz/trunk/applications/product/data/ProductTypeData.xml Thu Oct 29 21:38:18 2009
@@ -22,16 +22,24 @@
     <CostComponentType costComponentTypeId="MAT_COST" description="Materials Cost" hasTable="N" parentTypeId=""/>
     <CostComponentType costComponentTypeId="ROUTE_COST" description="Route (fixed asset usage) Cost" hasTable="N" parentTypeId=""/>
     <CostComponentType costComponentTypeId="LABOR_COST" description="Labor Cost" hasTable="N" parentTypeId=""/>
+    <CostComponentType costComponentTypeId="GEN_COST" description="General Cost" hasTable="N" parentTypeId=""/>
+    <CostComponentType costComponentTypeId="IND_COST" description="Indirect Cost" hasTable="N" parentTypeId=""/>
     <CostComponentType costComponentTypeId="OTHER_COST" description="Other Cost" hasTable="N" parentTypeId=""/>
     <CostComponentType costComponentTypeId="EST_STD_MAT_COST" description="Estimated Standard Materials Cost" hasTable="N" parentTypeId="MAT_COST"/>
     <CostComponentType costComponentTypeId="EST_STD_ROUTE_COST" description="Estimated Standard Route (fixed asset usage) Cost" hasTable="N" parentTypeId="ROUTE_COST"/>
     <CostComponentType costComponentTypeId="EST_STD_LABOR_COST" description="Estimated Standard Labor Cost" hasTable="N" parentTypeId="LABOR_COST"/>
+    <CostComponentType costComponentTypeId="EST_STD_GEN_COST" description="Estimated Standard General Cost" hasTable="N" parentTypeId="GEN_COST"/>
+    <CostComponentType costComponentTypeId="EST_STD_IND_COST" description="Estimated Standard Indirect Cost" hasTable="N" parentTypeId="IND_COST"/>
     <CostComponentType costComponentTypeId="EST_STD_OTHER_COST" description="Estimated Standard Other Cost" hasTable="N" parentTypeId="OTHER_COST"/>
     <CostComponentType costComponentTypeId="ACTUAL_MAT_COST" description="Actual Materials Cost" hasTable="N" parentTypeId="MAT_COST"/>
     <CostComponentType costComponentTypeId="ACTUAL_ROUTE_COST" description="Actual Route (fixed asset usage) Cost" hasTable="N" parentTypeId="ROUTE_COST"/>
     <CostComponentType costComponentTypeId="ACTUAL_LABOR_COST" description="Actual Labor Cost" hasTable="N" parentTypeId="LABOR_COST"/>
     <CostComponentType costComponentTypeId="ACTUAL_OTHER_COST" description="Actual Other Cost" hasTable="N" parentTypeId="OTHER_COST"/>
 
+    <!-- Cost Formulae -->
+    <CustomMethodType customMethodTypeId="COST_FORMULA" description="Formula for calculating costs for tasks and products"/>
+    <CustomMethod customMethodId="PROD_PERC_FORMULA" customMethodTypeId="COST_FORMULA" customMethodName="productCostPercentageFormula" description="Formula that creates a cost component equal to a percentage of total product cost"/>
+
     <EnumerationType description="Product Price Parent Enum Type" enumTypeId="PROD_PRICE" hasTable="N" parentTypeId=""/>
     <EnumerationType description="Product Price Input Parameter" enumTypeId="PROD_PRICE_IN_PARAM" hasTable="N" parentTypeId="PROD_PRICE"/>
     <Enumeration description="Product" enumCode="PRODUCT_ID" enumId="PRIP_PRODUCT_ID" sequenceId="01" enumTypeId="PROD_PRICE_IN_PARAM"/>

Modified: ofbiz/trunk/applications/product/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel.xml?rev=831099&r1=831098&r2=831099&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/product/entitydef/entitymodel.xml Thu Oct 29 21:38:18 2009
@@ -893,6 +893,28 @@
             <key-map field-name="costCustomMethodId" rel-field-name="customMethodId"/>
         </relation>
     </entity>
+    <entity entity-name="ProductCostComponentCalc"
+            package-name="org.ofbiz.product.cost"
+            title="Product Cost Calculation Entity">
+        <field name="productId" type="id-ne"></field>
+        <field name="costComponentTypeId" type="id-ne"></field>
+        <field name="costComponentCalcId" type="id-ne"></field>
+        <field name="fromDate" type="date-time"></field>
+        <field name="sequenceNum" type="numeric"></field>
+        <field name="thruDate" type="date-time"></field>
+        <prim-key field="productId"/>
+        <prim-key field="costComponentTypeId"/>
+        <prim-key field="fromDate"/>
+        <relation type="one" fk-name="PR_COS_COMPCALC" rel-entity-name="Product">
+            <key-map field-name="productId"/>
+        </relation>
+        <relation type="one" fk-name="PR_COS_CCT" rel-entity-name="CostComponentType">
+            <key-map field-name="costComponentTypeId"/>
+        </relation>
+        <relation type="one" fk-name="PR_COS_CCC" rel-entity-name="CostComponentCalc">
+            <key-map field-name="costComponentCalcId"/>
+        </relation>
+    </entity>
 
     <!-- ========================================================= -->
     <!-- org.ofbiz.product.facility -->

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml?rev=831099&r1=831098&r2=831099&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml Thu Oct 29 21:38:18 2009
@@ -388,6 +388,37 @@
             <set from-field="totalCostAmount" field="callSvcMap.cost"/>
             <call-service service-name="recreateCostComponent" in-map-name="callSvcMap"/>
         </iterate-map>
+
+        <!-- Now compute the costs derived from CostComponentCalc records associated with the product -->
+        <entity-condition entity-name="ProductCostComponentCalc" list="productCostComponentCalcs" filter-by-date="true">
+            <condition-expr field-name="productId" from-field="parameters.productId"/>
+            <order-by field-name="sequenceNum"/>
+        </entity-condition>
+        <iterate entry="productCostComponentCalc" list="productCostComponentCalcs">
+            <get-related-one relation-name="CostComponentCalc" to-value-field="costComponentCalc" value-field="productCostComponentCalc"/>
+            <get-related-one relation-name="CustomMethod" to-value-field="customMethod" value-field="costComponentCalc"/>
+            <if-empty field="customMethod">
+                <!-- TODO: not supported for CostComponentCalc entries directly associated to a product -->
+            <else>
+                <clear-field field="customMethodParameters"/>
+                <set field="customMethodParameters.productCostComponentCalc" from-field="productCostComponentCalc"/>
+                <set field="customMethodParameters.costComponentCalc" from-field="costComponentCalc"/>
+                <set from-field="parameters.currencyUomId" field="customMethodParameters.currencyUomId"/>
+                <set from-field="parameters.costComponentTypePrefix" field="customMethodParameters.costComponentTypePrefix"/>
+                <set from-field="totalCost" field="customMethodParameters.baseCost"/>
+                <call-service service-name="${customMethod.customMethodName}" in-map-name="customMethodParameters">
+                    <result-to-field result-name="productCostAdjustment"/>
+                </call-service>
+                <clear-field field="callSvcMap"/>
+                <set value="${parameters.costComponentTypePrefix}_${productCostComponentCalc.costComponentTypeId}" field="callSvcMap.costComponentTypeId"/>
+                <set from-field="productCostComponentCalc.productId" field="callSvcMap.productId"/>
+                <set from-field="parameters.currencyUomId" field="callSvcMap.costUomId"/>
+                <set from-field="productCostAdjustment" field="callSvcMap.cost"/>
+                <call-service service-name="recreateCostComponent" in-map-name="callSvcMap"/>
+                <set field="totalCost" value="${totalCost + productCostAdjustment}" type="BigDecimal"/>
+            </else>
+            </if-empty>
+        </iterate>
         
         <field-to-result field="totalCost"/>
     </simple-method>
@@ -567,4 +598,17 @@
         </if-not-empty>
         <field-to-result field="unitCost"/>
     </simple-method>
+
+    <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"/>
+        <field-to-result field="productCostAdjustment"/>
+    </simple-method>
 </simple-methods>

Modified: ofbiz/trunk/applications/product/servicedef/services_cost.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_cost.xml?rev=831099&r1=831098&r2=831099&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_cost.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_cost.xml Thu Oct 29 21:38:18 2009
@@ -56,6 +56,20 @@
         <attribute mode="IN" name="costUomId" optional="true" type="String"/>
         <attribute mode="IN" name="costComponentTypeId" optional="true" type="String"/>
     </service>
+    <service name="createProductCostComponentCalc" default-entity-name="ProductCostComponentCalc" engine="entity-auto" invoke="create" auth="true">
+        <description>Create a ProductCostComponentCalc</description>
+        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+    </service>
+    <service name="updateProductCostComponentCalc" default-entity-name="ProductCostComponentCalc" engine="entity-auto" invoke="update" auth="true">
+        <description>Update a ProductCostComponentCalc</description>
+        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+    </service>
+    <service name="deleteProductCostComponentCalc" default-entity-name="ProductCostComponentCalc" engine="entity-auto" invoke="delete" auth="true">
+        <description>Delete a Example</description>
+        <auto-attributes include="pk" mode="IN" optional="false"/>
+    </service>
     <service name="getProductCost" engine="simple" auth="true"
                 location="component://product/script/org/ofbiz/product/cost/CostServices.xml" invoke="getProductCost">
         <description>Gets the product's costs from CostComponent entries</description>
@@ -99,4 +113,19 @@
         <attribute name="productAverageCost" type="BigDecimal" mode="OUT" optional="true"/>
         <attribute name="currencyUomId" type="String" mode="OUT" optional="true"/>
     </service>
+
+    <service name="productCostCalcInterface" engine="interface">
+        <description>Interface to describe base parameters for Product Cost Calculation Services</description>
+        <attribute name="productCostComponentCalc" type="GenericValue" mode="IN" optional="false"/>
+        <attribute name="costComponentCalc" type="GenericValue" mode="IN" optional="false"/>
+        <attribute name="currencyUomId" type="String" mode="IN" optional="false"/>
+        <attribute name="costComponentTypePrefix" type="String" mode="IN" optional="false"/>
+        <attribute name="baseCost" type="BigDecimal" mode="IN" optional="false"/>
+        <attribute name="productCostAdjustment" type="BigDecimal" mode="OUT" optional="false"/>
+    </service>
+    <service name="productCostPercentageFormula" engine="simple"
+                location="component://product/script/org/ofbiz/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>
 </services>

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml?rev=831099&r1=831098&r2=831099&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml Thu Oct 29 21:38:18 2009
@@ -841,6 +841,24 @@
         <response name="success" type="view" value="EditProductCosts"/>
         <response name="error" type="view" value="EditProductCosts"/>
     </request-map>
+    <request-map uri="createProductCostComponentCalc">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="createProductCostComponentCalc"/>
+        <response name="success" type="view" value="EditProductCosts"/>
+        <response name="error" type="view" value="EditProductCosts"/>
+    </request-map>
+    <request-map uri="updateProductCostComponentCalc">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="updateProductCostComponentCalc"/>
+        <response name="success" type="view" value="EditProductCosts"/>
+        <response name="error" type="view" value="EditProductCosts"/>
+    </request-map>
+    <request-map uri="deleteProductCostComponentCalc">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="deleteProductCostComponentCalc"/>
+        <response name="success" type="view" value="EditProductCosts"/>
+        <response name="error" type="view" value="EditProductCosts"/>
+    </request-map>
     <request-map uri="calculateProductCosts">
         <security https="true" auth="true"/>
         <event type="service" invoke="calculateProductCosts"/>

Modified: ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml?rev=831099&r1=831098&r2=831099&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml Thu Oct 29 21:38:18 2009
@@ -1171,6 +1171,49 @@
             </hyperlink>
         </field>
     </form>
+    <form name="ListProductCostComponentCalcs" type="list" title="" list-name="productCostComponentCalcs"
+        odd-row-style="alternate-row" default-table-style="basic-table" paginate-target="EditProductCosts">
+        <field name="productId"><hidden/></field>
+        <field name="costComponentTypeId">
+            <display-entity entity-name="CostComponentType"/>
+        </field>
+        <field name="costComponentCalcId" widget-style="buttontext">
+            <hyperlink target="/manufacturing/control/EditCostCalcs" also-hidden="false" target-type="inter-app" description="${costComponentCalcId}">
+                <parameter param-name="costComponentCalcId"/>
+            </hyperlink>
+        </field>
+        <field name="costComponentCalc" entry-name="costComponentCalcId">
+            <display-entity entity-name="CostComponentCalc" key-field-name="costComponentCalcId"/>
+        </field>
+        <field name="fromDate"><display/></field>
+        <field name="thruDate"><display/></field>
+        <field name="deleteProductCostComponentCalc" entry-name="productId" widget-style="buttontext">
+            <hyperlink target="deleteProductCostComponentCalc" also-hidden="false" description="${uiLabelMap.CommonDelete}">
+                <parameter param-name="productId"/>
+                <parameter param-name="costComponentTypeId"/>
+                <parameter param-name="fromDate"/>
+            </hyperlink>
+        </field>
+    </form>
+    <form name="AddProductCostComponentCalc" type="single" target="createProductCostComponentCalc" title=""
+        header-row-style="header-row" default-table-style="basic-table">
+        <auto-fields-service service-name="createProductCostComponentCalc"/>
+        <field name="productId"><hidden value="${product.productId}"/></field>
+        <field name="costComponentTypeId">
+            <drop-down allow-empty="false">
+                <entity-options entity-name="CostComponentType" description="${description}">
+                    <entity-constraint name="parentTypeId" operator="equals" env-name="nullField"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <field name="costComponentCalcId">
+            <drop-down allow-empty="false">
+                <entity-options entity-name="CostComponentCalc" description="${description}"/>
+            </drop-down>
+        </field>
+        <field name="fromDate" title="${uiLabelMap.CommonFromDate}"><date-time/></field>
+        <field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field>
+    </form>
     <form name="EditCostComponent" type="single" target="createCostComponent" title="" default-map-name="costComponent"
         header-row-style="header-row" default-table-style="basic-table">
         <alt-target use-when="costComponent!=null" target="updateCostComponent"/>

Modified: ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml?rev=831099&r1=831098&r2=831099&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml Thu Oct 29 21:38:18 2009
@@ -369,6 +369,10 @@
                     <field-map field-name="productId"/>
                     <order-by field-name="-fromDate"/>
                 </entity-and>
+                <entity-and entity-name="ProductCostComponentCalc" list="productCostComponentCalcs">
+                    <field-map field-name="productId"/>
+                    <order-by field-name="sequenceNum"/>
+                </entity-and>
             </actions>
             <widgets>
                 <decorator-screen name="CommonProductDecorator"  location="${parameters.mainDecoratorLocation}">
@@ -379,6 +383,12 @@
                         <screenlet title="${uiLabelMap.ProductAddCostComponent}">
                             <include-form name="EditCostComponent" location="component://product/widget/catalog/ProductForms.xml"/>
                         </screenlet>
+                        <screenlet title="${uiLabelMap.ProductCostComponentCalcs}">
+                            <include-form name="ListProductCostComponentCalcs" location="component://product/widget/catalog/ProductForms.xml"/>
+                        </screenlet>
+                        <screenlet title="${uiLabelMap.AddProductCostComponentCalc}">
+                            <include-form name="AddProductCostComponentCalc" location="component://product/widget/catalog/ProductForms.xml"/>
+                        </screenlet>
                         <screenlet title="${uiLabelMap.ProductAutoCreateCosts}">
                             <include-form name="CalculateProductCosts" location="component://product/widget/catalog/ProductForms.xml"/>
                         </screenlet>