You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2006/09/11 13:29:45 UTC

svn commit: r442180 - in /incubator/ofbiz/trunk/applications: order/src/org/ofbiz/order/shoppingcart/ order/webapp/ordermgr/entry/ product/servicedef/ product/src/org/ofbiz/product/supplier/

Author: jacopoc
Date: Mon Sep 11 04:29:44 2006
New Revision: 442180

URL: http://svn.apache.org/viewvc?view=rev&rev=442180
Log:
Implemented support for "always drop-ship" products: if such a product is added to a sales cart, it is automatically assigned into a ship group with the supplier set (if needed, the ship group is also created).

Modified:
    incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
    incubator/ofbiz/trunk/applications/order/webapp/ordermgr/entry/optionsettings.ftl
    incubator/ofbiz/trunk/applications/product/servicedef/services_view.xml
    incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java

Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?view=diff&rev=442180&r1=442179&r2=442180
==============================================================================
--- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java (original)
+++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java Mon Sep 11 04:29:44 2006
@@ -893,7 +893,59 @@
         // set the item ship group
         if (resetShipGroup) {
             cart.clearItemShipInfo(this);
-            cart.setItemShipGroupQty(this, quantity, 0);
+            int shipGroupIndex = -1;
+            if ("PURCHASE_ORDER".equals(cart.getOrderType())) {
+                shipGroupIndex = 0;
+            } else {
+                if (_product != null && "PRODRQM_DS".equals(_product.getString("requirementMethodEnumId"))) {
+                    // this is a drop-ship only product: we need a ship group with supplierPartyId set
+                    Map supplierProductsResult = null;
+                    try {
+                        supplierProductsResult = dispatcher.runSync("getSuppliersForProduct", UtilMisc.toMap("productId", _product.getString("productId"),
+                                                                                                                 "quantity", new Double(quantity),
+                                                                                                                 "currencyUomId", cart.getCurrency(),
+                                                                                                                 "canDropShip", "Y",
+                                                                                                                 "userLogin", cart.getUserLogin()));
+                        List productSuppliers = (List)supplierProductsResult.get("supplierProducts");
+                        GenericValue supplierProduct = EntityUtil.getFirst(productSuppliers);
+                        if (supplierProduct != null) {
+                            String supplierPartyId = supplierProduct.getString("partyId");
+                            List shipGroups = cart.getShipGroups();
+                            for(int i = 0; i < shipGroups.size(); i++) {
+                                ShoppingCart.CartShipInfo csi = (ShoppingCart.CartShipInfo)shipGroups.get(i);
+                                if (supplierPartyId.equals(csi.getSupplierPartyId())) {
+                                    shipGroupIndex = i;
+                                    break;
+                                }
+                            }
+                            if (shipGroupIndex == -1) {
+                                // create a new ship group
+                                shipGroupIndex = cart.addShipInfo();
+                                cart.setSupplierPartyId(shipGroupIndex, supplierPartyId);
+                            }
+                        }
+                    } catch (Exception e) {
+                        Debug.logWarning("Error calling getSuppliersForProduct service, result is: " + supplierProductsResult, module);
+                    }
+                }
+                // TODO: implement auto drop-ship on low qoh
+
+                if (shipGroupIndex == -1) {
+                    List shipGroups = cart.getShipGroups();
+                    for(int i = 0; i < shipGroups.size(); i++) {
+                        ShoppingCart.CartShipInfo csi = (ShoppingCart.CartShipInfo)shipGroups.get(i);
+                        if (csi.getSupplierPartyId() == null) {
+                            shipGroupIndex = i;
+                            break;
+                        }
+                    }
+                    if (shipGroupIndex == -1) {
+                        // create a new ship group
+                        shipGroupIndex = cart.addShipInfo();
+                    }
+                }
+            }
+            cart.setItemShipGroupQty(this, quantity, shipGroupIndex);
         }
     }
 

Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/entry/optionsettings.ftl
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/entry/optionsettings.ftl?view=diff&rev=442180&r1=442179&r2=442180
==============================================================================
--- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/entry/optionsettings.ftl (original)
+++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/entry/optionsettings.ftl Mon Sep 11 04:29:44 2006
@@ -31,11 +31,13 @@
 <#if cart.getShipmentMethodTypeId(shipGroupIndex)?exists && cart.getCarrierPartyId(shipGroupIndex)?exists>
     <#assign chosenShippingMethod = cart.getShipmentMethodTypeId(shipGroupIndex) + '@' + cart.getCarrierPartyId(shipGroupIndex)>
 </#if>
+<#assign supplierPartyId = cart.getSupplierPartyId(shipGroupIndex)?if_exists>
+<#assign supplier =  delegator.findByPrimaryKey("PartyGroup", Static["org.ofbiz.base.util.UtilMisc"].toMap("partyId", supplierPartyId))?if_exists />
 <hr class="sepbar"/>
               <table width="100%" cellpadding="1" border="0" cellpadding="0" cellspacing="0">
               <tr>
                 <td colspan="2">
-                    <div class="head1"><b>${uiLabelMap.OrderShipGroup} # ${currIndex}</b></div>
+                    <div class="head1"><b>${uiLabelMap.OrderShipGroup} # ${currIndex}</b><#if supplier?has_content> - ${supplier.description?default(supplier.partyId)}</#if></div>
                 </td>
               </tr>
 

Modified: incubator/ofbiz/trunk/applications/product/servicedef/services_view.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/servicedef/services_view.xml?view=diff&rev=442180&r1=442179&r2=442180
==============================================================================
--- incubator/ofbiz/trunk/applications/product/servicedef/services_view.xml (original)
+++ incubator/ofbiz/trunk/applications/product/servicedef/services_view.xml Mon Sep 11 04:29:44 2006
@@ -85,6 +85,7 @@
         <attribute name="partyId" type="String" mode="IN" optional="true"/>
         <attribute name="currencyUomId" type="String" mode="IN" optional="true"/>
         <attribute name="quantity" type="Double" mode="IN" optional="true"/>  
+        <attribute name="canDropShip" type="String" mode="IN" optional="true"/>  
         <attribute name="supplierProducts" type="java.util.List" mode="OUT" optional="false"/>
     </service>
     <service name="convertFeaturesForSupplier" engine="java"

Modified: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java?view=diff&rev=442180&r1=442179&r2=442180
==============================================================================
--- incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java (original)
+++ incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java Mon Sep 11 04:29:44 2006
@@ -62,6 +62,7 @@
         String partyId = (String) context.get("partyId");
         String currencyUomId = (String) context.get("currencyUomId");
         Double quantity =(Double) context.get("quantity");
+        String canDropShip = (String) context.get("canDropShip");
         try {
             product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId));
             if (product == null) {
@@ -95,7 +96,12 @@
                 //minimumOrderQuantity
                 supplierProducts = EntityUtil.filterByCondition(supplierProducts, new EntityExpr("minimumOrderQuantity", EntityOperator.LESS_THAN_EQUAL_TO, quantity));
             }
-            
+
+            // filter the list down by the canDropShip if one is provided
+            if (canDropShip != null) {
+                supplierProducts = EntityUtil.filterByAnd(supplierProducts, UtilMisc.toMap("canDropShip", canDropShip));
+            }
+
             // filter the list down again by date before returning it
             supplierProducts = EntityUtil.filterByDate(supplierProducts, UtilDateTime.nowTimestamp(), "availableFromDate", "availableThruDate", true);