svn commit: r442536 - in /incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order: order/OrderServices.java shoppingcart/ShoppingCart.java shoppingcart/ShoppingCartItem.java

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

svn commit: r442536 - in /incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order: order/OrderServices.java shoppingcart/ShoppingCart.java shoppingcart/ShoppingCartItem.java

jacopoc
Author: jacopoc
Date: Tue Sep 12 02:07:29 2006
New Revision: 442536

URL: http://svn.apache.org/viewvc?view=rev&rev=442536
Log:
Implemented association between sales order items and drop shipment purchase order items (thru OrderItemassociation).

Modified:
    incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
    incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
    incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java

Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?view=diff&rev=442536&r1=442535&r2=442536
==============================================================================
--- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Tue Sep 12 02:07:29 2006
@@ -3581,15 +3581,19 @@
                         while (items.hasNext()) {
                             GenericValue item = (GenericValue)items.next();
                             try {
-                            cart.addOrIncreaseItem(item.getString("productId"),
-                                                   null, // amount
-                                                   item.getDouble("quantity").doubleValue(),
-                                                   null, null, null, // reserv
-                                                   item.getTimestamp("shipBeforeDate"),
-                                                   item.getTimestamp("shipAfterDate"),
-                                                   null, null, null,
-                                                   null, null, null,
-                                                   dispatcher);
+                                int itemIndex = cart.addOrIncreaseItem(item.getString("productId"),
+                                                                       null, // amount
+                                                                       item.getDouble("quantity").doubleValue(),
+                                                                       null, null, null, // reserv
+                                                                       item.getTimestamp("shipBeforeDate"),
+                                                                       item.getTimestamp("shipAfterDate"),
+                                                                       null, null, null,
+                                                                       null, null, null,
+                                                                       dispatcher);
+                                ShoppingCartItem sci = cart.findCartItem(itemIndex);
+                                sci.setAssociatedOrderId(orderId);
+                                sci.setAssociatedOrderItemSeqId(item.getString("orderItemSeqId"));
+                                // TODO: we should consider also the ship group in the association between sales and purchase orders
                             } catch(Exception e) {
                                 ServiceUtil.returnError("The following error occurred creating drop shipments for order [" + orderId + "]: " + e.getMessage());
                             }

Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?view=diff&rev=442536&r1=442535&r2=442536
==============================================================================
--- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Tue Sep 12 02:07:29 2006
@@ -3427,7 +3427,6 @@
             while (itemIter.hasNext()) {
                 ShoppingCartItem item = (ShoppingCartItem) itemIter.next();
                 String requirementId = item.getRequirementId();
-
                 if (requirementId != null) {
                     try {
                         List commitments = getDelegator().findByAnd("OrderRequirementCommitment", UtilMisc.toMap("requirementId", requirementId));
@@ -3443,6 +3442,13 @@
                     } catch (GenericEntityException e) {
                         Debug.logError(e, "Unable to load OrderRequirementCommitment records for requirement ID : " + requirementId, module);
                     }
+                }
+                if (item.getAssociatedOrderId() != null && item.getAssociatedOrderItemSeqId() != null) {
+                    GenericValue orderItemAssociation = getDelegator().makeValue("OrderItemAssociation", null);
+                    orderItemAssociation.set("salesOrderId", item.getAssociatedOrderId());
+                    orderItemAssociation.set("soItemSeqId", item.getAssociatedOrderItemSeqId());
+                    orderItemAssociation.set("poItemSeqId", item.getOrderItemSeqId());
+                    allOrderItemAssociations.add(orderItemAssociation);
                 }
             }
         }

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=442536&r1=442535&r2=442536
==============================================================================
--- 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 Tue Sep 12 02:07:29 2006
@@ -112,6 +112,8 @@
     private String requirementId = null;
     private String quoteId = null;
     private String quoteItemSeqId = null;
+    private String associatedOrderId = null; // the order Id, if any, to which the given item is associated (typically a sales order item can be associated to a purchase order item, for example in drop shipments)
+    private String associatedOrderItemSeqId = null; // the order item Id, if any, to which the given item is associated
     private String statusId = null;
     private Map orderItemAttributes = null;
     private Map attributes = null;
@@ -566,6 +568,8 @@
         this.requirementId = item.getRequirementId();
         this.quoteId = item.getQuoteId();
         this.quoteItemSeqId = item.getQuoteItemSeqId();
+        this.associatedOrderId = item.getAssociatedOrderId();
+        this.associatedOrderItemSeqId = item.getAssociatedOrderItemSeqId();
         this.isPromo = item.getIsPromo();
         this.promoQuantityUsed = item.promoQuantityUsed;
         this.locale = item.locale;
@@ -1360,6 +1364,26 @@
     /** Returns the quoteItemSeqId. */
     public String getQuoteItemSeqId() {
         return this.quoteItemSeqId;
+    }
+
+    /** Sets the asociatedOrderId. */
+    public void setAssociatedOrderId(String associatedOrderId) {
+        this.associatedOrderId = associatedOrderId;
+    }
+
+    /** Returns the associatedId. */
+    public String getAssociatedOrderId() {
+        return this.associatedOrderId;
+    }
+
+    /** Sets the associatedOrderItemSeqId. */
+    public void setAssociatedOrderItemSeqId(String associatedOrderItemSeqId) {
+        this.associatedOrderItemSeqId = associatedOrderItemSeqId;
+    }
+
+    /** Returns the associatedOrderItemSeqId. */
+    public String getAssociatedOrderItemSeqId() {
+        return this.associatedOrderItemSeqId;
     }
 
     public String getStatusId() {