Author: mor
Date: Fri May 29 10:54:48 2009 New Revision: 779926 URL: http://svn.apache.org/viewvc?rev=779926&view=rev Log: Improve the Return Status process so that it also take into account the ReturnItem status change. Slightly modified patch from Awdesh Singh Parihar, part of OFBIZ-2541 (https://issues.apache.org/jira/browse/OFBIZ-2541) Modified: ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderReturnServices.xml ofbiz/trunk/applications/order/servicedef/secas.xml ofbiz/trunk/applications/order/servicedef/services_return.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java ofbiz/trunk/applications/order/webapp/ordermgr/return/ReturnForms.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=779926&r1=779925&r2=779926&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 29 10:54:48 2009 @@ -443,8 +443,11 @@ <find-by-and entity-name="ReturnItem" map="lookupPKMap" list="returnItems"/> <iterate entry="item" list="returnItems"> <set field="item.statusId" from-field="parameters.statusId"/> + <set-service-fields service-name="updateReturnItem" map="item" to-map="serviceInMap"/> + <call-service service-name="updateReturnItem" in-map-name="serviceInMap"/> + <clear-field field="serviceInMap"/> + <clear-field field="item"/> </iterate> - <store-list list="returnItems"/> </simple-method> <simple-method method-name="removeReturnItem" short-description="Remove Return Item"> <check-permission permission="ORDERMGR" action="_DELETE"><fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunRemoveQuoteItem"/></check-permission> @@ -526,15 +529,17 @@ <field-map field-name="returnItemSeqId" from-field="receipt.returnItemSeqId"/> </entity-one> <set field="returnItem.receivedQuantity" from-field="${totalsMap.receipt.returnItemSeqId}" type="BigDecimal"/> + <set-service-fields service-name="updateReturnItem" map="returnItem" to-map="serviceInMap"/> <if-compare-field field="totalsMap.receipt.returnItemSeqId" to-field="returnItem.returnQuantity" operator="greater-equals" type="BigDecimal"> <!-- update the status for the item --> - <set field="returnItem.statusId" value="RETURN_RECEIVED"/> - <store-value value-field="returnItem"/> + <set field="serviceInMap.statusId" value="RETURN_RECEIVED"/> + <call-service service-name="updateReturnItem" in-map-name="serviceInMap"/> </if-compare-field> <!-- update the returnItem with at least receivedQuantity, and also statusId if applicable --> - <store-value value-field="returnItem"/> + <call-service service-name="updateReturnItem" in-map-name="serviceInMap"/> + <clear-field field="serviceInMap"/> </iterate> <!-- check to see if all items have been received --> @@ -1084,17 +1089,21 @@ </if-not-empty> </simple-method> - <simple-method method-name="createReturnStatus" short-description="Create Return Status"> - <entity-one value-field="returnHeader" entity-name="ReturnHeader"> - <field-map field-name="returnId" from-field="parameters.returnId"/> - </entity-one> + <simple-method method-name="createReturnStatus" short-description="Create ReturnHeader and ReturnItem Status"> <make-value entity-name="ReturnStatus" value-field="newEntity"/> + <if-empty field="parameters.returnItemSeqId"> + <entity-one entity-name="ReturnHeader" value-field="returnHeader"/> + <set field="newEntity.statusId" from-field="returnHeader.statusId"/> + <else> + <entity-one entity-name="ReturnItem" value-field="returnItem"/> + <set field="newEntity.returnItemSeqId" from-field="returnItem.returnItemSeqId"/> + <set field="newEntity.statusId" from-field="returnItem.statusId"/> + </else> + </if-empty> <sequenced-id sequence-name="ReturnStatus" field="newEntity.returnStatusId"/> <set field="newEntity.returnId" from-field="parameters.returnId"/> - <set field="newEntity.statusId" from-field="returnHeader.statusId"/> <set field="newEntity.changeByUserLoginId" from-field="userLogin.userLoginId"/> <now-timestamp field="newEntity.statusDatetime"/> <create-value value-field="newEntity"/> </simple-method> - </simple-methods> \ No newline at end of file Modified: ofbiz/trunk/applications/order/servicedef/secas.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=779926&r1=779925&r2=779926&view=diff ============================================================================== --- ofbiz/trunk/applications/order/servicedef/secas.xml (original) +++ ofbiz/trunk/applications/order/servicedef/secas.xml Fri May 29 10:54:48 2009 @@ -210,7 +210,6 @@ <action service="processRepairReplacementReturn" mode="sync"/> <action service="processCreditReturn" mode="sync"/> <action service="processRefundOnlyReturn" mode="sync"/> - <action service="createReturnStatus" mode="sync"/> </eca> <eca service="updateReturnStatusFromReceipt" event="global-commit"> <condition field-name="returnHeaderStatus" operator="equals" value="RETURN_RECEIVED"/> @@ -376,4 +375,12 @@ <condition field-name="leadPartyId" operator="is-not-empty"/> <action service="createSalesOpportunityLeadRole" mode="sync"/> </eca> + <eca service="createReturnItem" event="commit"> + <action service="createReturnStatus" mode="sync"/> + </eca> + <eca service="updateReturnItem" event="commit"> + <condition field-name="statusId" operator="is-not-empty"/> + <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/> + <action service="createReturnStatus" mode="sync"/> + </eca> </service-eca> \ No newline at end of file Modified: ofbiz/trunk/applications/order/servicedef/services_return.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services_return.xml?rev=779926&r1=779925&r2=779926&view=diff ============================================================================== --- ofbiz/trunk/applications/order/servicedef/services_return.xml (original) +++ ofbiz/trunk/applications/order/servicedef/services_return.xml Fri May 29 10:54:48 2009 @@ -1,4 +1,3 @@ -<?xml version="1.0" encoding="UTF-8" ?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file @@ -339,9 +338,10 @@ <attribute name="returnId" type="String" mode="IN" optional="true"/> <attribute name="inventoryItemId" type="String" mode="IN" optional="true"/> </service> - <service name="createReturnStatus" default-entity-name="ReturnHeader" engine="simple" + <service name="createReturnStatus" engine="simple" location="component://order/script/org/ofbiz/order/order/OrderReturnServices.xml" invoke="createReturnStatus"> <description>Create Return Status</description> <attribute name="returnId" type="String" mode="IN" optional="false"/> + <attribute name="returnItemSeqId" type="String" mode="IN" optional="true"/> </service> </services> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java?rev=779926&r1=779925&r2=779926&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java Fri May 29 10:54:48 2009 @@ -781,31 +781,19 @@ String itemResponseId = (String) serviceResults.get("returnItemResponseId"); // loop through the items again to update them and store a status change history - List toBeStored = new ArrayList(); for (Iterator itemsIter = returnItems.iterator(); itemsIter.hasNext(); ) { GenericValue item = (GenericValue) itemsIter.next(); - - // set the response on the item and flag the item to be stored - item.set("returnItemResponseId", itemResponseId); - item.set("statusId", "RETURN_COMPLETED"); - toBeStored.add(item); - - // create the status change history and set it to be stored - String returnStatusId = delegator.getNextSeqId("ReturnStatus"); - GenericValue returnStatus = delegator.makeValue("ReturnStatus", UtilMisc.toMap("returnStatusId", returnStatusId)); - returnStatus.set("statusId", item.get("statusId")); - returnStatus.set("returnId", item.get("returnId")); - returnStatus.set("returnItemSeqId", item.get("returnItemSeqId")); - returnStatus.set("statusDatetime", now); - toBeStored.add(returnStatus); - } - - // store the item changes (attached responseId) - try { - delegator.storeAll(toBeStored); - } catch (GenericEntityException e) { - Debug.logError(e, "Problem storing ReturnItem updates", module); - return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderProblemStoringReturnItemUpdates", locale)); + Map returnItemMap = UtilMisc.toMap("returnItemResponseId", itemResponseId, "returnId", item.get("returnId"), "returnItemSeqId", item.get("returnItemSeqId"), "statusId", "RETURN_COMPLETED", "userLogin", userLogin); + // store the item changes (attached responseId) + try { + serviceResults = dispatcher.runSync("updateReturnItem", returnItemMap); + if (ServiceUtil.isError(serviceResults)) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderProblemStoringReturnItemUpdates", locale), null, null, serviceResults); + } + } catch (GenericServiceException e) { + Debug.logError(e, "Problem storing ReturnItem updates", module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderProblemStoringReturnItemUpdates", locale)); + } } // create the PaymentApplication for the billing account @@ -1164,22 +1152,15 @@ Iterator itemsIter = items.iterator(); while (itemsIter.hasNext()) { GenericValue item = (GenericValue) itemsIter.next(); - item.set("returnItemResponseId", responseId); - item.set("statusId", returnItemStatusId); - - // Create the status history - String returnStatusId = delegator.getNextSeqId("ReturnStatus"); - GenericValue returnStatus = delegator.makeValue("ReturnStatus", UtilMisc.toMap("returnStatusId", returnStatusId)); - returnStatus.set("statusId", item.get("statusId")); - returnStatus.set("returnId", item.get("returnId")); - returnStatus.set("returnItemSeqId", item.get("returnItemSeqId")); - returnStatus.set("statusDatetime", now); - + + Map returnItemMap = UtilMisc.toMap("returnItemResponseId", responseId, "returnId", item.get("returnId"), "returnItemSeqId", item.get("returnItemSeqId"), "statusId", returnItemStatusId, "userLogin", userLogin); //Debug.log("Updating item status", module); try { - item.store(); - delegator.create(returnStatus); - } catch (GenericEntityException e) { + serviceResults = dispatcher.runSync("updateReturnItem", returnItemMap); + if (ServiceUtil.isError(serviceResults)) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderProblemUpdatingReturnItemReturnItemResponseId", locale), null, null, serviceResults); + } + } catch (GenericServiceException e) { Debug.logError("Problem updating the ReturnItem entity", module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderProblemUpdatingReturnItemReturnItemResponseId", locale)); } Modified: ofbiz/trunk/applications/order/webapp/ordermgr/return/ReturnForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/return/ReturnForms.xml?rev=779926&r1=779925&r2=779926&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/return/ReturnForms.xml (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/return/ReturnForms.xml Fri May 29 10:54:48 2009 @@ -180,7 +180,8 @@ <form name="ReturnStatusHistory" type="list" list-name="orderReturnStatusHistories" odd-row-style="alternate-row" header-row-style="header-row-2" default-table-style="basic-table hover-bar"> - <field name="returnId"><display description="${returnId}"/></field> + <field name="returnId"><display/></field> + <field name="returnItemSeqId"><display/></field> <field name="statusId"><display-entity entity-name="StatusItem" description="${description}"/></field> <field name="statusDatetime" title="${uiLabelMap.CommonDate}"><display/></field> <field name="changeByUserLoginId" title="${uiLabelMap.FormFieldTitle_modifiedByUserLoginId}"><display/></field> |
Free forum by Nabble | Edit this page |