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 2007/04/03 09:51:17 UTC

svn commit: r525074 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java

Author: jacopoc
Date: Tue Apr  3 00:51:16 2007
New Revision: 525074

URL: http://svn.apache.org/viewvc?view=rev&rev=525074
Log:
When items are added to the cart from requirements, the shipBeforeDate is set equal to the Requirement.requiredByDate.

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java?view=diff&rev=525074&r1=525073&r2=525074
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java Tue Apr  3 00:51:16 2007
@@ -428,6 +428,15 @@
                 productId = (String) context.get("productId" + thisSuffix);
                 quantStr = (String) context.get("quantity" + thisSuffix);
                 requirementId = (String) context.get("requirementId" + thisSuffix);
+                GenericValue requirement = null;
+                try {
+                    requirement = delegator.findByPrimaryKey("Requirement", UtilMisc.toMap("requirementId", requirementId));
+                } catch(GenericEntityException gee) {
+                }
+                if (requirement == null) {
+                    return ServiceUtil.returnError("Requirement with id [" + requirementId + "] doesn't exist.");
+                }
+
                 if (quantStr != null && quantStr.length() > 0) {
                     double quantity = 0;
                     try {
@@ -446,12 +455,12 @@
                             }
                         }
                         if (requirementAlreadyInCart) {
-                            if (Debug.warningOn()) Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderTheRequirementIsAlreadyInTheCartNotAdding", UtilMisc.toMap("requirementId",requirementId), cart.getLocale()), module);
+                            if (Debug.warningOn()) Debug.logWarning(UtilProperties.getMessage(resource_error, "OrderTheRequirementIsAlreadyInTheCartNotAdding", UtilMisc.toMap("requirementId",requirementId), cart.getLocale()), module);
                             continue;
                         }
                         try {
                             if (Debug.verboseOn()) Debug.logVerbose("Bulk Adding to cart requirement [" + quantity + "] of [" + productId + "]", module);
-                            int index = this.cart.addOrIncreaseItem(productId, null, quantity, null, null, null, null, null, null, null, catalogId, null, null, itemGroupNumber, null, dispatcher);
+                            int index = this.cart.addOrIncreaseItem(productId, null, quantity, null, null, null, requirement.getTimestamp("requiredByDate"), null, null, null, catalogId, null, null, itemGroupNumber, null, dispatcher);
                             ShoppingCartItem sci = (ShoppingCartItem)this.cart.items().get(index);
                             sci.setRequirementId(requirementId);
                         } catch (CartItemModifyException e) {