svn commit: r559988 - /ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r559988 - /ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java

apatel-2
Author: apatel
Date: Thu Jul 26 14:23:24 2007
New Revision: 559988

URL: http://svn.apache.org/viewvc?view=rev&rev=559988
Log:
Now inventory levels work for both Serialized and Non Serialized inventory items.

Modified:
    ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java

Modified: ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java?view=diff&rev=559988&r1=559987&r2=559988
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java Thu Jul 26 14:23:24 2007
@@ -107,11 +107,11 @@
         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 @@
                 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 @@
                 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 @@
                         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 @@
             Map bodyParameters = UtilMisc.toMap("inventoryMapList", inventoryMapList, "locale", locale);
             sendMap.put("bodyParameters", bodyParameters);
             sendMap.put("userLogin", userLogin);
-
             // send the notification
             Map sendResp = null;
             try {