Author: mor
Date: Fri May 22 05:53:29 2009 New Revision: 777387 URL: http://svn.apache.org/viewvc?rev=777387&view=rev Log: Modified the addProductsBackToCategory service to better handle the case of a recevied product not associated to any category, for example the raw material products MAT_A_COST, MAT_B_COST does not belongs any category. Modified: ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml Modified: ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml?rev=777387&r1=777386&r2=777387&view=diff ============================================================================== --- ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml (original) +++ ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml Fri May 22 05:53:29 2009 @@ -1060,23 +1060,24 @@ </else> </if> </simple-method> - - <simple-method method-name="addProductsBackToCategory" short-description="When one or more product is received directly through receive inventory or refund return then add these product(s) back to category, if they do not have any active category"> + + <simple-method method-name="addProductsBackToCategory" short-description="When one or more product is received directly through receive inventory or refund return then add these product(s) back to category, if they does not have any active category"> <if-not-empty field="parameters.inventoryItemId"> <entity-one entity-name="InventoryItem" value-field="inventoryItem"/> - <entity-and entity-name="ProductCategoryMember" list="productCategoryMembers"> - <field-map field-name="productId" from-field="inventoryItem.productId"/> - <order-by field-name="-thruDate"/> - </entity-and> - <filter-list-by-date list="productCategoryMembers" to-list="pcms"/> - <if-empty field="pcms"> - <first-from-list list="productCategoryMembers" entry="pcm"/> - <if-not-empty field="pcm"> + <get-related-one relation-name="Product" value-field="inventoryItem" to-value-field="product"/> + <set field="orderBy[]" value="-thruDate"/> + <get-related relation-name="ProductCategoryMember" value-field="product" list="productCategoryMembers" order-by-list="orderBy"/> + <!-- check whether this product is associated to any category, if not just skip --> + <if-not-empty field="productCategoryMembers"> + <filter-list-by-date list="productCategoryMembers" to-list="pcms"/> + <!-- check if this product is associated to any active category, if not found then activate the most recent expired category --> + <if-empty field="pcms"> + <first-from-list list="productCategoryMembers" entry="pcm"/> <clear-field field="pcm.thruDate"/> <set-service-fields service-name="updateProductToCategory" map="pcm" to-map="updateProductToCategoryMap"/> <call-service service-name="updateProductToCategory" in-map-name="updateProductToCategoryMap"/> - </if-not-empty> - </if-empty> + </if-empty> + </if-not-empty> <else> <if-not-empty field="parameters.returnId"> <entity-and entity-name="ReturnItem" list="returnItems"> @@ -1085,23 +1086,24 @@ </entity-and> <if-not-empty field="returnItems"> <iterate list="returnItems" entry="returnItem"> - <entity-and entity-name="ProductCategoryMember" list="productCategoryMembers"> - <field-map field-name="productId" from-field="returnItem.productId"/> - <order-by field-name="-thruDate"/> - </entity-and> - <filter-list-by-date list="productCategoryMembers" to-list="pcms"/> - <if-empty field="pcms"> - <first-from-list list="productCategoryMembers" entry="pcm"/> - <if-not-empty field="pcm"> + <get-related-one relation-name="Product" value-field="returnItem" to-value-field="product"/> + <set field="orderBy[]" value="-thruDate"/> + <get-related relation-name="ProductCategoryMember" value-field="product" list="productCategoryMembers" order-by-list="orderBy"/> + <!-- check whether this product is associated to any category, if not just skip --> + <if-not-empty field="productCategoryMembers"> + <filter-list-by-date list="productCategoryMembers" to-list="pcms"/> + <!-- check if this product is associated to any active category, if not found then activate the most recent expired category --> + <if-empty field="pcms"> + <first-from-list list="productCategoryMembers" entry="pcm"/> <clear-field field="pcm.thruDate"/> <set-service-fields service-name="updateProductToCategory" map="pcm" to-map="updateProductToCategoryMap"/> <call-service service-name="updateProductToCategory" in-map-name="updateProductToCategoryMap"/> - </if-not-empty> - </if-empty> + </if-empty> + </if-not-empty> </iterate> </if-not-empty> </if-not-empty> </else> </if-not-empty> - </simple-method> + </simple-method> </simple-methods> \ No newline at end of file |
Free forum by Nabble | Edit this page |