Author: apatel
Date: Wed Sep 9 01:28:33 2009 New Revision: 812744 URL: http://svn.apache.org/viewvc?rev=812744&view=rev Log: Update to average cost calculation process. Patch from OFBIZ-2914. Thanks Ratnesh for implementation. Modified: ofbiz/trunk/applications/accounting/servicedef/services_cost.xml ofbiz/trunk/applications/product/script/org/ofbiz/product/cost/CostServices.xml Modified: ofbiz/trunk/applications/accounting/servicedef/services_cost.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_cost.xml?rev=812744&r1=812743&r2=812744&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/services_cost.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/services_cost.xml Wed Sep 9 01:28:33 2009 @@ -98,6 +98,7 @@ <description>Update a Product Average Cost record on receive inventory</description> <permission-service service-name="acctgCostPermissionCheck" main-action="UPDATE"/> <attribute name="facilityId" type="String" mode="IN" optional="false"/> + <attribute name="quantityAccepted" type="String" mode="IN" optional="false"/> <attribute name="productId" type="String" mode="IN" optional="false"/> <attribute name="inventoryItemId" type="String" mode="IN" optional="false"/> </service> 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=812744&r1=812743&r2=812744&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 Wed Sep 9 01:28:33 2009 @@ -525,8 +525,13 @@ <set-service-fields service-name="updateProductAverageCost" map="productAverageCost" to-map="updateProductAverageCostMap"/> <now-timestamp field="updateProductAverageCostMap.thruDate"/> <call-service service-name="updateProductAverageCost" in-map-name="updateProductAverageCostMap"/> - - <set field="productAverageCostMap.averageCost" value="${(productAverageCost.averageCost + inventoryItem.unitCost)/2}" type="BigDecimal"/> + <set field="serviceInMap.productId" from-field="parameters.productId"/> + <set field="serviceInMap.facilityId" from-field="parameters.facilityId"/> + <call-service service-name="getInventoryAvailableByFacility" in-map-name="serviceInMap"> + <result-to-field result-name="quantityOnHandTotal"/> + </call-service> + <set field="oldProductQuantity" value="${quantityOnHandTotal - parameters.quantityAccepted}"/> + <set field="productAverageCostMap.averageCost" value="${((productAverageCost.averageCost * oldProductQuantity) + (inventoryItem.unitCost * parameters.quantityAccepted))/(quantityOnHandTotal)}" type="BigDecimal"/> <property-to-field resource="arithmetic" property="finaccount.decimals" field="roundingDecimals" default="2"/> <property-to-field resource="arithmetic" property="finaccount.roundingSimpleMethod" field="roundingMode" default="HalfUp"/> <calculate field="productAverageCostMap.averageCost" type="BigDecimal" decimal-scale="${roundingDecimals}" rounding-mode="${roundingMode}"> |
Free forum by Nabble | Edit this page |