Now inventory levels work for both Serialized and Non Serialized inventory items.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@559988 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Anil Patel
2007-07-26 21:23:24 +00:00
parent be33e85573
commit 4d1cb7d506
@@ -107,11 +107,11 @@ public class OagisInventoryServices {
String authId = UtilXml.childElementValue(docSenderElement, "of:AUTHID");
// data area elements
Element dataAreaElement = UtilXml.firstChildElement(syncInventoryRootElement, "n:DATAAREA");
Element syncInventoryElement = UtilXml.firstChildElement(dataAreaElement, "n:SYNC_INVENTORY");
Element dataAreaElement = UtilXml.firstChildElement(syncInventoryRootElement, "ns:DATAAREA");
Element syncInventoryElement = UtilXml.firstChildElement(dataAreaElement, "ns:SYNC_INVENTORY");
// get Inventory elements from message
List syncInventoryElementList = UtilXml.childElementList(syncInventoryElement, "n:INVENTORY");
List syncInventoryElementList = UtilXml.childElementList(syncInventoryElement, "ns:INVENTORY");
if (UtilValidate.isNotEmpty(syncInventoryElementList)) {
Iterator syncInventoryElementIter = syncInventoryElementList.iterator();
while (syncInventoryElementIter.hasNext()) {
@@ -135,6 +135,14 @@ public class OagisInventoryServices {
if (!isAvailable) {
statusId = "INV_ON_HOLD";
}
String invItemType = null;
try {
GenericValue invItem = EntityUtil.getFirst(delegator.findByAnd("InventoryItem", UtilMisc.toMap("productId", productId)));
invItemType = invItem.getString("inventoryItemTypeId");
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
String snapshotDateStr = UtilXml.childElementValue(inventoryElement, "os:DATETIMEISO");
@@ -154,7 +162,7 @@ public class OagisInventoryServices {
double quantityOnHandTotal = 0.0;
// only if looking for available inventory find the non-serialized QOH total
if (isAvailable) {
if (invItemType.equals("NON_SERIAL_INV_ITEM")) {
EntityCondition condition = new EntityConditionList(UtilMisc.toList(
new EntityExpr("effectiveDate", EntityOperator.LESS_THAN_EQUAL_TO, snapshotDate),
new EntityExpr("productId", EntityOperator.EQUALS, productId),
@@ -171,22 +179,22 @@ public class OagisInventoryServices {
errorMapList.add(UtilMisc.toMap("reasonCode", "GenericEntityException", "description", errMsg));
Debug.logError(e, errMsg, module);
}
}
// now regardless of AVAILABLE or NOTAVAILABLE check serialized inventory, just use the corresponding statusId as set above
EntityCondition serInvCondition = new EntityConditionList(UtilMisc.toList(
new EntityExpr("statusDatetime", EntityOperator.LESS_THAN_EQUAL_TO, snapshotDate),
new EntityExpr(new EntityExpr("statusEndDatetime", EntityOperator.GREATER_THAN, snapshotDate), EntityOperator.OR, new EntityExpr("statusEndDatetime", EntityOperator.EQUALS, null)),
new EntityExpr("productId", EntityOperator.EQUALS, productId),
new EntityExpr("statusId", EntityOperator.EQUALS, statusId),
new EntityExpr("facilityId", EntityOperator.EQUALS, facilityId)), EntityOperator.AND);
try {
long invItemQuantCount = delegator.findCountByCondition("InventoryItemStatusForCount", serInvCondition, null);
quantityOnHandTotal += invItemQuantCount;
} catch (GenericEntityException e) {
String errMsg = "Error Getting Inventory Item by Status Count: " + e.toString();
errorMapList.add(UtilMisc.toMap("reasonCode", "GenericEntityException", "description", errMsg));
Debug.logError(e, errMsg, module);
} else {
// now regardless of AVAILABLE or NOTAVAILABLE check serialized inventory, just use the corresponding statusId as set above
EntityCondition serInvCondition = new EntityConditionList(UtilMisc.toList(
new EntityExpr("statusDatetime", EntityOperator.LESS_THAN_EQUAL_TO, snapshotDate),
new EntityExpr(new EntityExpr("statusEndDatetime", EntityOperator.GREATER_THAN, snapshotDate), EntityOperator.OR, new EntityExpr("statusEndDatetime", EntityOperator.EQUALS, null)),
new EntityExpr("productId", EntityOperator.EQUALS, productId),
new EntityExpr("statusId", EntityOperator.EQUALS, statusId),
new EntityExpr("facilityId", EntityOperator.EQUALS, facilityId)), EntityOperator.AND);
try {
long invItemQuantCount = delegator.findCountByCondition("InventoryItemStatusForCount", serInvCondition, null);
quantityOnHandTotal += invItemQuantCount;
} catch (GenericEntityException e) {
String errMsg = "Error Getting Inventory Item by Status Count: " + e.toString();
errorMapList.add(UtilMisc.toMap("reasonCode", "GenericEntityException", "description", errMsg));
Debug.logError(e, errMsg, module);
}
}
// check for mismatch in quantity
@@ -256,7 +264,6 @@ public class OagisInventoryServices {
Map bodyParameters = UtilMisc.toMap("inventoryMapList", inventoryMapList, "locale", locale);
sendMap.put("bodyParameters", bodyParameters);
sendMap.put("userLogin", userLogin);
// send the notification
Map sendResp = null;
try {