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)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@779926 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vikas Mayur
2009-05-29 10:54:48 +00:00
parent beb12298fc
commit f9810fbfee
5 changed files with 49 additions and 51 deletions
@@ -443,8 +443,11 @@ under the License.
<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 @@ under the License.
<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 @@ under the License.
</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>
+8 -1
View File
@@ -210,7 +210,6 @@ under the License.
<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 @@ under the License.
<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>
@@ -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 @@ under the License.
<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>
@@ -781,31 +781,19 @@ public class OrderReturnServices {
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 @@ public class OrderReturnServices {
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));
}
@@ -180,7 +180,8 @@ under the License.
<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>