svn commit: r782190 - in /ofbiz/trunk/applications/product: script/org/ofbiz/shipment/shipment/ShipmentServices.xml src/org/ofbiz/shipment/packing/PackingSession.java src/org/ofbiz/shipment/verify/VerifyPickSession.java

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

svn commit: r782190 - in /ofbiz/trunk/applications/product: script/org/ofbiz/shipment/shipment/ShipmentServices.xml src/org/ofbiz/shipment/packing/PackingSession.java src/org/ofbiz/shipment/verify/VerifyPickSession.java

jonesde
Author: jonesde
Date: Sat Jun  6 05:01:28 2009
New Revision: 782190

URL: http://svn.apache.org/viewvc?rev=782190&view=rev
Log:
Applied patch from Pranay Pandey in Jira #OFBIZ-2570 to improve how the Shipment partyIdTo/From fields are populated

Modified:
    ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java
    ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml?rev=782190&r1=782189&r2=782190&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/shipment/shipment/ShipmentServices.xml Sat Jun  6 05:01:28 2009
@@ -1462,6 +1462,36 @@
                      for Purchase Shipment, the facilityId parameter is the destinationFacilityId, and the initial status is "CREATED" -->
                 <if><condition><if-compare field="orderHeader.orderTypeId" operator="equals" value="SALES_ORDER"/></condition>
                   <then>
+                    <if-not-empty field="orderItemShipGroup.vendorPartyId">
+                      <set field="partyIdFrom" from-field="orderItemShipGroup.vendorPartyId"/>
+                    <else>
+                      <entity-one entity-name="Facility" value-field="facility" auto-field-map="false">
+                        <field-map field-name="facilityId" from-field="orderItemShipGrpInvResFacilityId"/>
+                      </entity-one>
+                      <if-not-empty field="facility.ownerPartyId">
+                        <set field="partyIdFrom" from-field="facility.ownerPartyId"/>
+                      </if-not-empty>
+                      <if-empty field="partyIdFrom">
+                        <entity-and entity-name="OrderRole" list="orderRoles">
+                          <field-map field-name="orderId" from-field="orderHeader.orderId"/>
+                          <field-map field-name="roleTypeId" value="SHIP_FROM_VENDOR"/>
+                        </entity-and>
+                        <if-not-empty field="orderRoles">
+                          <first-from-list list="orderRoles" entry="orderRole"/>
+                          <set field="partyIdFrom" from-field="orderRole.partyId"/>
+                        <else>
+                          <entity-and entity-name="OrderRole" list="orderRoles">
+                            <field-map field-name="orderId" from-field="orderHeader.orderId"/>
+                            <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/>
+                          </entity-and>
+                          <first-from-list list="orderRoles" entry="orderRole"/>
+                          <set field="partyIdFrom" from-field="orderRole.partyId"/>
+                        </else>
+                        </if-not-empty>
+                      </if-empty>
+                    </else>
+                    </if-not-empty>
+                    <set field="shipmentContext.partyIdFrom" from-field="partyIdFrom"/>
                     <set from-field="orderItemShipGrpInvResFacilityId" field="shipmentContext.originFacilityId"/>
                     <set value="SHIPMENT_INPUT" field="shipmentContext.statusId"/>
                   </then>

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=782190&r1=782189&r2=782190&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java Sat Jun  6 05:01:28 2009
@@ -709,6 +709,7 @@
 
     protected void createShipment() throws GeneralException {
         // first create the shipment
+        GenericDelegator delegator = this.getDelegator();
         Map<String, Object> newShipment = FastMap.newInstance();
         newShipment.put("originFacilityId", this.facilityId);
         newShipment.put("primaryShipGroupSeqId", primaryShipGrp);
@@ -719,6 +720,30 @@
         newShipment.put("picklistBinId", picklistBinId);
         newShipment.put("additionalShippingCharge", additionalShippingCharge);
         newShipment.put("userLogin", userLogin);
+        GenericValue orderRoleShipTo = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", primaryOrderId, "roleTypeId", "SHIP_TO_CUSTOMER")));
+        if (UtilValidate.isNotEmpty(orderRoleShipTo)) {
+            newShipment.put("partyIdTo", orderRoleShipTo.getString("partyId"));
+        }
+        String partyIdFrom = null;
+        GenericValue orderItemShipGroup = EntityUtil.getFirst(delegator.findByAnd("OrderItemShipGroup", UtilMisc.toMap("orderId", primaryOrderId, "shipGroupSeqId", primaryShipGrp)));
+        if (UtilValidate.isNotEmpty(orderItemShipGroup.getString("vendorPartyId"))) {
+            partyIdFrom = orderItemShipGroup.getString("vendorPartyId");
+        } else if (UtilValidate.isNotEmpty(orderItemShipGroup.getString("facilityId"))) {
+            GenericValue facility = delegator.findOne("Facility", UtilMisc.toMap("facilityId", orderItemShipGroup.getString("facilityId")), false);
+            if (UtilValidate.isNotEmpty(facility.getString("ownerPartyId"))) {
+                partyIdFrom = facility.getString("ownerPartyId");
+            }
+        }
+        if (UtilValidate.isEmpty(partyIdFrom)) {
+            GenericValue orderRoleShipFrom = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", primaryOrderId, "roleTypeId", "SHIP_FROM_VENDOR")));
+            if (UtilValidate.isNotEmpty(orderRoleShipFrom)) {
+                partyIdFrom = orderRoleShipFrom.getString("partyId");
+            } else {
+                orderRoleShipFrom = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", primaryOrderId, "roleTypeId", "BILL_FROM_VENDOR")));
+                partyIdFrom = orderRoleShipFrom.getString("partyId");
+            }
+        }
+        newShipment.put("partyIdFrom", partyIdFrom);
         Debug.log("Creating new shipment with context: " + newShipment, module);
         Map<String, Object> newShipResp = this.getDispatcher().runSync("createShipment", newShipment);
 

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java?rev=782190&r1=782189&r2=782190&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/verify/VerifyPickSession.java Sat Jun  6 05:01:28 2009
@@ -360,10 +360,26 @@
         if (UtilValidate.isNotEmpty(orderRoleShipTo)) {
             newShipment.put("partyIdTo", orderRoleShipTo.getString("partyId"));
         }
-        GenericValue orderRoleShipFrom = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "SHIP_FROM_VENDOR")));
-        if (UtilValidate.isNotEmpty(orderRoleShipFrom)) {
-            newShipment.put("partyIdFrom", orderRoleShipFrom.getString("partyId"));
+        String partyIdFrom = null;
+        GenericValue orderItemShipGroup = EntityUtil.getFirst(delegator.findByAnd("OrderItemShipGroup", UtilMisc.toMap("orderId", orderId, "shipGroupSeqId", line.getShipGroupSeqId())));
+        if (UtilValidate.isNotEmpty(orderItemShipGroup.getString("vendorPartyId"))) {
+            partyIdFrom = orderItemShipGroup.getString("vendorPartyId");
+        } else if (UtilValidate.isNotEmpty(orderItemShipGroup.getString("facilityId"))) {
+            GenericValue facility = delegator.findOne("Facility", UtilMisc.toMap("facilityId", orderItemShipGroup.getString("facilityId")), false);
+            if (UtilValidate.isNotEmpty(facility.getString("ownerPartyId"))) {
+                partyIdFrom = facility.getString("ownerPartyId");
+            }
         }
+        if (UtilValidate.isEmpty(partyIdFrom)) {
+            GenericValue orderRoleShipFrom = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "SHIP_FROM_VENDOR")));
+            if (UtilValidate.isNotEmpty(orderRoleShipFrom)) {
+                partyIdFrom = orderRoleShipFrom.getString("partyId");
+            } else {
+                orderRoleShipFrom = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "BILL_FROM_VENDOR")));
+                partyIdFrom = orderRoleShipFrom.getString("partyId");
+            }
+        }
+        newShipment.put("partyIdFrom", partyIdFrom);
         Map<String, Object> newShipResp = this.getDispatcher().runSync("createShipment", newShipment);
         if (ServiceUtil.isError(newShipResp)) {
             throw new GeneralException(ServiceUtil.getErrorMessage(newShipResp));