[ http://issues.apache.org/jira/browse/OFBIZ-193?page=comments#action_12433165 ] Si Chen commented on OFBIZ-193: -------------------------------
There are some subtle differences now that I think about it: 1. ProductAverageCost is by organizationPartyId. ProductPrice is by productStoreGroupId -- so there may not be a good mapping between the two there. Many product stores could all be part of the same organization. 2. Also, ProductAverageCost is based on ShipmentReceipts' inventory unitCosts. That may or may not be what someone would want pricing to be based on . . . I think this is one of those features which should wait until someone who really needs, as the actual meaning of things would depend on requirements. > New service to automatically calculate the product's average cost > ----------------------------------------------------------------- > > Key: OFBIZ-193 > URL: http://issues.apache.org/jira/browse/OFBIZ-193 > Project: OFBiz (The Open for Business Project) > Issue Type: New Feature > Components: order, product > Reporter: Jacopo Cappellato > Priority: Minor > > Implement a service to automatically calculate the average cost > (ProductPrice.averageCost) based on previous purchases. > Right now the value is just set manually. These averages would have nothing > to do with what is used for inventory costing. The average could somewhat > easily be calculated from the order or invoice histories as a weighted sum > based on the quantity and price. (suggested By David Jones) > Such a service could be based on a SQL command like this one: > SELECT > PRODUCT_ID, SUM(UNIT_PRICE * QUANTITY) / SUM(QUANTITY) AS AVERAGE_COST > FROM > ORDER_ITEM AS OI, ORDER_HEADER AS OH > WHERE > OH.ORDER_ID = OI.ORDER_ID AND > OH.ORDER_TYPE_ID = 'PURCHASE_ORDER' AND > ORDER_DATE > '2004-12-31 00:00:00.0' > GROUP BY > PRODUCT_ID > However this is only a draft (e.g. we should also take into account cancelled > items, adjustments etc...) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
