svn commit: r551503 - in /ofbiz/trunk/specialpurpose/oagis: config/oagis.properties servicedef/services.xml src/org/ofbiz/oagis/OagisShipmentServices.java webapp/oagis/message/ReceiveDelivery.ftl widget/MessageInfoScreens.xml

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

svn commit: r551503 - in /ofbiz/trunk/specialpurpose/oagis: config/oagis.properties servicedef/services.xml src/org/ofbiz/oagis/OagisShipmentServices.java webapp/oagis/message/ReceiveDelivery.ftl widget/MessageInfoScreens.xml

apatel-2
Author: apatel
Date: Thu Jun 28 01:31:10 2007
New Revision: 551503

URL: http://svn.apache.org/viewvc?view=rev&rev=551503
Log:
Added receive delivery message service.

Added:
    ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ReceiveDelivery.ftl
Modified:
    ofbiz/trunk/specialpurpose/oagis/config/oagis.properties
    ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml
    ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java
    ofbiz/trunk/specialpurpose/oagis/widget/MessageInfoScreens.xml

Modified: ofbiz/trunk/specialpurpose/oagis/config/oagis.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/config/oagis.properties?view=diff&rev=551503&r1=551502&r2=551503
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/config/oagis.properties (original)
+++ ofbiz/trunk/specialpurpose/oagis/config/oagis.properties Thu Jun 28 01:31:10 2007
@@ -24,6 +24,7 @@
 CNTROLAREA.SENDER.AUTHID=Ofbiz
 
 Oagis.Template.ConfirmBod=component://oagis/widget/MessageInfoScreens.xml#ConfirmBod
+Oagis.Template.ReceiveDelivery=component://oagis/widget/MessageInfoScreens.xml#ReceiveDelivery
 
 # URLs for outgoing messages
 url.send.processShipment=https://foo.bar.baz/oagis/control/processShipment

Modified: ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml?view=diff&rev=551503&r1=551502&r2=551503
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml Thu Jun 28 01:31:10 2007
@@ -99,5 +99,10 @@
         <attribute name="referenceId" mode="IN" type="String" optional="false"/>
         <attribute name="sentDate" mode="IN" type="Timestamp" optional="false"/>
     </service>
+    <service name="receiveDelivery" max-retry="0" engine="java"
+        location="org.ofbiz.oagis.OagisShipmentServices" invoke="receiveDelivery">
+        <description>Receive Delivery</description>
+        <attribute name="returnId" mode="IN" type="String" optional="false"/>
+    </service>
 
 </services>

Modified: ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java?view=diff&rev=551503&r1=551502&r2=551503
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java Thu Jun 28 01:31:10 2007
@@ -30,6 +30,8 @@
 import java.util.List;
 import java.util.Map;
 import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.text.DateFormat;
 
 import javolution.util.FastMap;
 import javolution.util.FastList;
@@ -37,6 +39,7 @@
 import org.w3c.dom.Document;
 
 import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ServiceUtil;
 import org.ofbiz.base.util.*;
@@ -368,5 +371,113 @@
             return ServiceUtil.returnError("error in creating message info" + e.getMessage());
         }
         return ServiceUtil.returnSuccess();
+    }
+    
+    public static Map receiveDelivery(DispatchContext dctx, Map context) {
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        GenericDelegator delegator = dctx.getDelegator();
+        String returnId = (String) context.get("returnId");
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
+        GenericValue returnHeader = null;
+        GenericValue postalAddress =null;
+        List returnItems = new ArrayList();
+        String partyId = null;
+        String orderId = null;
+        if (returnId != null) {
+            try {
+                returnHeader = delegator.findByPrimaryKey("ReturnHeader", UtilMisc.toMap("returnId", returnId));
+                String statusId = returnHeader.getString("statusId");
+                if (statusId.equals("RETURN_ACCEPTED")) {
+                    returnItems = delegator.findByAnd("ReturnItem", UtilMisc.toMap("returnId", returnId));
+                    postalAddress = delegator.findByPrimaryKey("PostalAddress", UtilMisc.toMap("contactMechId", returnHeader.getString("originContactMechId")));
+                            
+                    // calculate total qty of return items in a shipping unit received
+                    double itemQty = 0.0;
+                    double totalQty = 0.0;
+                    Iterator riIter = returnItems.iterator();
+                    while (riIter.hasNext()) {
+                        GenericValue returnItem = (GenericValue) riIter.next();
+                        itemQty = returnItem.getDouble("returnQuantity").doubleValue();
+                        totalQty = totalQty + itemQty;
+                        orderId = returnItem.getString("orderId");
+                    }
+                    partyId = returnHeader.getString("fromPartyId");
+                    List partyContactMechs = new ArrayList();
+                    GenericValue contactMech = null;
+                    GenericValue telecomNumber =null;
+                    String emailString = null;
+                    partyContactMechs = delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId));
+                    Iterator pcmIter = partyContactMechs.iterator();
+                    while (pcmIter.hasNext()) {
+                        GenericValue partyContactMech = (GenericValue) pcmIter.next();
+                        String contactMechId = partyContactMech.getString("contactMechId");
+                        contactMech = delegator.findByPrimaryKey("ContactMech", UtilMisc.toMap("contactMechId", contactMechId));
+                        String contactMechTypeId = contactMech.getString("contactMechTypeId");
+                        if(contactMechTypeId.equals("EMAIL_ADDRESS")) {
+                            emailString = contactMech.getString("infoString");
+                        }
+                        if(contactMechTypeId.equals("TELECOM_NUMBER")) {
+                            telecomNumber = delegator.findByPrimaryKey("TelecomNumber", UtilMisc.toMap("contactMechId", contactMechId));
+                        }
+                    }
+                    String logicalId = UtilProperties.getPropertyValue("oagis.properties", "CNTROLAREA.SENDER.LOGICALID");
+                    String authId = UtilProperties.getPropertyValue("oagis.properties", "CNTROLAREA.SENDER.AUTHID");
+                    String referenceId = delegator.getNextSeqId("OagisMessageInfo");
+                    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'Z");
+                    Timestamp timestamp = UtilDateTime.nowTimestamp();
+                    String sentDate = dateFormat.format(timestamp);
+                    Map bodyParameters = new HashMap();
+                    bodyParameters.put("returnId", returnId);
+                    bodyParameters.put("returnItems", returnItems);
+                    bodyParameters.put("totalQty", new Double(totalQty));
+                    bodyParameters.put("postalAddress", postalAddress);
+                    bodyParameters.put("telecomNumber", telecomNumber);
+                    bodyParameters.put("emailString", emailString);
+                    bodyParameters.put("logicalId", logicalId);
+                    bodyParameters.put("authId", authId);
+                    bodyParameters.put("referenceId", referenceId);
+                    bodyParameters.put("sentDate", sentDate);
+                    bodyParameters.put("returnId", returnId);
+                    String bodyScreenUri = UtilProperties.getPropertyValue("oagis.properties", "Oagis.Template.ReceiveDelivery");
+                    Map emfsCtx = new HashMap();
+                    emfsCtx.put("bodyParameters", bodyParameters);
+                    emfsCtx.put("bodyScreenUri", bodyScreenUri);
+                            
+                    // export the message
+                    try {
+                        dispatcher.runSync("exportMsgFromScreen", emfsCtx);
+                    } catch (GenericServiceException e) {
+                        Debug.logError("Error in exporting message" + e.getMessage(), module);
+                        return ServiceUtil.returnError("Error in exporting message");
+                    }
+                            
+                    // prepare map to store BOD information
+                    Map comiCtx = new HashMap();
+                    comiCtx.put("logicalId", logicalId);
+                    comiCtx.put("authId", authId);
+                    comiCtx.put("referenceId", referenceId);
+                    comiCtx.put("sentDate", timestamp);
+                    comiCtx.put("component", "INVENTORY");
+                    comiCtx.put("task", "RMA");  
+                    comiCtx.put("outgoingMessage", "Y");
+                    comiCtx.put("confirmation", "1");
+                    comiCtx.put("bsrVerb", "RECEIVE");
+                    comiCtx.put("bsrNoun", "DELIVERY");
+                    comiCtx.put("bsrRevision", "001");
+                    comiCtx.put("processingStatusId", statusId);        
+                    comiCtx.put("returnId", returnId);
+                    comiCtx.put("orderId", orderId);
+                    comiCtx.put("userLogin", userLogin);
+                    try {
+                        dispatcher.runSync("createOagisMessageInfo", comiCtx);
+                    } catch (GenericServiceException e) {
+                          return ServiceUtil.returnError("Error in creating message info" + e.getMessage());
+                    }
+                }
+            } catch (Exception e) {
+                  Debug.logError("Error in Processing" + e.getMessage(), module);
+            }
+        }
+        return ServiceUtil.returnSuccess("");
     }
 }

Added: ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ReceiveDelivery.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ReceiveDelivery.ftl?view=auto&rev=551503
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ReceiveDelivery.ftl (added)
+++ ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ReceiveDelivery.ftl Thu Jun 28 01:31:10 2007
@@ -0,0 +1,104 @@
+<?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
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+    
+    http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<n:RECEIVE_DELIVERY_001 xmlns:n="http://www.openapplications.org/197_receive_delivery_001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openapplications.org/197_receive_delivery_001 file:///C:/Documents%20and%20Settings/022523/My%20Documents/Vudu/XML%20Specs/OAG%20721/197_receive_delivery_001.xsd" xmlns:N1="http://www.openapplications.org/oagis_segments" xmlns:N2="http://www.openapplications.org/oagis_fields">
+  <N1:CNTROLAREA>
+    <N1:BSR>
+      <N2:VERB>RECEIVE</N2:VERB>
+      <N2:NOUN>DELIVERY</N2:NOUN>
+      <N2:REVISION>001</N2:REVISION>
+    </N1:BSR>
+    <N1:SENDER>
+      <N2:LOGICALID>${logicalId}</N2:LOGICALID>
+      <N2:COMPONENT>INVENTORY</N2:COMPONENT>
+      <N2:TASK>RMA</N2:TASK>
+      <N2:REFERENCEID>${referenceId?if_exists}</N2:REFERENCEID/>
+      <N2:CONFIRMATION>1</N2:CONFIRMATION>
+      <N2:LANGUAGE>ENG</N2:LANGUAGE>
+      <N2:CODEPAGE>NONE</N2:CODEPAGE>
+      <N2:AUTHID>${authId}</N2:AUTHID>
+    </N1:SENDER>
+    <N1:DATETIMEANY>${sentDate?if_exists}</N1:DATETIMEANY>
+  </N1:CNTROLAREA>
+  <n:DATAAREA>
+    <n:RECEIVE_DELIVERY>
+      <n:RECEIPTHDR>
+        <N1:DATETIMEANY>${sentDate?if_exists}</N1:DATETIMEANY>
+        <N2:RECEIPTID></N2:RECEIPTID>
+        <N2:CARRIER></N2:CARRIER>
+        <N2:NOTES></N2:NOTES>
+        <N2:RECEIPTYPE>RMA</N2:RECEIPTYPE>
+        <N1:PARTNER>
+          <N2:NAME>${postalAddress.toName?if_exists}</N2:NAME>
+          <N2:PARTNRTYPE>SHIPFROM</N2:PARTNRTYPE>
+          <N2:CURRENCY>USD</N2:CURRENCY>
+          <#if postalAddress?has_content>
+            <N1:ADDRESS>
+              <N2:ADDRLINE>${postalAddress.address1?if_exists}</N2:ADDRLINE>
+              <#if postalAddress.address2?exists>
+                <N2:ADDRLINE>${postalAddress.address2?if_exists}</N2:ADDRLINE>            
+              </#if>  
+              <N2:CITY>${postalAddress.city?if_exists}</N2:CITY>
+              <N2:COUNTRY>${postalAddress.countryGeoId?if_exists}</N2:COUNTRY>
+              <N2:FAX></N2:FAX>
+              <N2:POSTALCODE>${postalAddress.postalCode?if_exists}</N2:POSTALCODE>
+              <N2:STATEPROVN>${postalAddress.stateProvinceGeoId?if_exists}</N2:STATEPROVN>
+              <N2:TELEPHONE>${telecomNumber.countryCode?if_exists}${telecomNumber.areaCode?if_exists}-${telecomNumber.contactNumber?if_exists}</N2:TELEPHONE>
+            </N1:ADDRESS>
+            <N1:CONTACT>
+              <N2:NAME>${postalAddress.toName?if_exists}</N2:NAME>
+              <N2:EMAIL>${emailString?if_exists}</N2:EMAIL>
+              <N2:FAX></N2:FAX>
+              <N2:TELEPHONE>${telecomNumber.countryCode?if_exists}${telecomNumber.areaCode?if_exists}-${telecomNumber.contactNumber?if_exists}</N2:TELEPHONE>
+            </N1:CONTACT>
+          </#if>
+        </N1:PARTNER>
+      </n:RECEIPTHDR>
+      <n:RECEIPTUNT>
+        <N1:QUANTITY>
+          <N2:VALUE>${totalQty?if_exists}</N2:VALUE>
+          <N2:NUMOFDEC>0</N2:NUMOFDEC>
+          <N2:SIGN>+</N2:SIGN>
+          <N2:UOM>EACH</N2:UOM>
+        </N1:QUANTITY>
+        <n:RECEIPTITM>
+        <#list returnItems as returnItem>
+          <#assign returnReason = returnItem.getRelatedOne("ReturnReason")>
+          <N1:QUANTITY>
+            <N2:VALUE>${returnItem.returnQuantity?if_exists}</N2:VALUE>
+            <N2:NUMOFDEC>0</N2:NUMOFDEC>
+            <N2:SIGN>+</N2:SIGN>
+            <N2:UOM>EACH</N2:UOM>
+          </N1:QUANTITY>
+          <N2:ITEM>${returnItem.productId?if_exists}</N2:ITEM>
+          <N2:NOTES>${returnReason.description?if_exists}</N2:NOTES>
+          <N1:DOCUMNTREF>
+            <N2:DOCTYPE>RMA</N2:DOCTYPE>
+            <N2:DOCUMENTID></N2:DOCUMENTID>
+            <N2:LINENUM></N2:LINENUM>
+          </N1:DOCUMNTREF>
+          </#list>
+          <n:INVDETAIL>
+            <N2:SERIALNUM></N2:SERIALNUM>
+          </n:INVDETAIL>
+        </n:RECEIPTITM>
+      </n:RECEIPTUNT>
+    </n:RECEIVE_DELIVERY>
+  </n:DATAAREA>
+</n:RECEIVE_DELIVERY_001>

Modified: ofbiz/trunk/specialpurpose/oagis/widget/MessageInfoScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/widget/MessageInfoScreens.xml?view=diff&rev=551503&r1=551502&r2=551503
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/widget/MessageInfoScreens.xml (original)
+++ ofbiz/trunk/specialpurpose/oagis/widget/MessageInfoScreens.xml Thu Jun 28 01:31:10 2007
@@ -126,4 +126,14 @@
         </section>
     </screen>
     
+    <screen name="ReceiveDelivery">
+        <section>
+            <widgets>
+                <platform-specific>
+                    <html><html-template location="component://oagis/webapp/oagis/message/ReceiveDelivery.ftl"/></html>
+                </platform-specific>
+            </widgets>
+        </section>
+    </screen>
+    
 </screens>