svn commit: r485750 - 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: r485750 - in /incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order: order/OrderServices.java shoppingcart/ShoppingCart.java shoppingcart/ShoppingCartItem.java

jacopoc
Author: jacopoc
Date: Mon Dec 11 08:50:23 2006
New Revision: 485750

URL: http://svn.apache.org/viewvc?view=rev&rev=485750
Log:
Improved support for new OrderItemAssoc entity: now drop shipped items are associated to their purchase order items by an entry in the OrderItemAssoc entity of type "DROP_SHIPMENT".

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=485750&r1=485749&r2=485750
==============================================================================
--- 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 Mon Dec 11 08:50:23 2006
@@ -3655,6 +3655,7 @@
                                 ShoppingCartItem sci = cart.findCartItem(itemIndex);
                                 sci.setAssociatedOrderId(orderId);
                                 sci.setAssociatedOrderItemSeqId(item.getString("orderItemSeqId"));
+                                sci.setOrderItemAssocTypeId("DROP_SHIPMENT");
                                 // 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=485750&r1=485749&r2=485750
==============================================================================
--- 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 Mon Dec 11 08:50:23 2006
@@ -3447,41 +3447,39 @@
     public List makeAllOrderItemAssociations() {
         List allOrderItemAssociations = new LinkedList();
 
-        if (getOrderType().equals("PURCHASE_ORDER")) {
-            Iterator itemIter = cartLines.iterator();
+        Iterator itemIter = cartLines.iterator();
 
-            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));
-                        // TODO: multiple commitments for the same requirement are still not supported
-                        GenericValue commitment = EntityUtil.getFirst(commitments);
-                        if (commitment != null) {
-                            GenericValue orderItemAssociation = getDelegator().makeValue("OrderItemAssoc", null);
-                            orderItemAssociation.set("orderId", commitment.getString("orderId"));
-                            orderItemAssociation.set("orderItemSeqId", commitment.getString("orderItemSeqId"));
-                            orderItemAssociation.set("shipGroupSeqId", "_NA_");
-                            orderItemAssociation.set("toOrderItemSeqId", item.getOrderItemSeqId());
-                            orderItemAssociation.set("toShipGroupSeqId", "_NA_");
-                            orderItemAssociation.set("orderItemAssocTypeId", "PURCHASE_ORDER");
-                            allOrderItemAssociations.add(orderItemAssociation);
-                        }
-                    } catch (GenericEntityException e) {
-                        Debug.logError(e, "Unable to load OrderRequirementCommitment records for requirement ID : " + requirementId, module);
+        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));
+                    // TODO: multiple commitments for the same requirement are still not supported
+                    GenericValue commitment = EntityUtil.getFirst(commitments);
+                    if (commitment != null) {
+                        GenericValue orderItemAssociation = getDelegator().makeValue("OrderItemAssoc", null);
+                        orderItemAssociation.set("orderId", commitment.getString("orderId"));
+                        orderItemAssociation.set("orderItemSeqId", commitment.getString("orderItemSeqId"));
+                        orderItemAssociation.set("shipGroupSeqId", "_NA_");
+                        orderItemAssociation.set("toOrderItemSeqId", item.getOrderItemSeqId());
+                        orderItemAssociation.set("toShipGroupSeqId", "_NA_");
+                        orderItemAssociation.set("orderItemAssocTypeId", "PURCHASE_ORDER");
+                        allOrderItemAssociations.add(orderItemAssociation);
                     }
+                } 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("OrderItemAssoc", null);
-                    orderItemAssociation.set("orderId", item.getAssociatedOrderId());
-                    orderItemAssociation.set("orderItemSeqId", item.getAssociatedOrderItemSeqId());
-                    orderItemAssociation.set("shipGroupSeqId", "_NA_");
-                    orderItemAssociation.set("toOrderItemSeqId", item.getOrderItemSeqId());
-                    orderItemAssociation.set("toShipGroupSeqId", "_NA_");
-                    orderItemAssociation.set("orderItemAssocTypeId", "PURCHASE_ORDER");
-                    allOrderItemAssociations.add(orderItemAssociation);
-                }
+            }
+            if (item.getAssociatedOrderId() != null && item.getAssociatedOrderItemSeqId() != null) {
+                GenericValue orderItemAssociation = getDelegator().makeValue("OrderItemAssoc", null);
+                orderItemAssociation.set("orderId", item.getAssociatedOrderId());
+                orderItemAssociation.set("orderItemSeqId", item.getAssociatedOrderItemSeqId());
+                orderItemAssociation.set("shipGroupSeqId", "_NA_");
+                orderItemAssociation.set("toOrderItemSeqId", item.getOrderItemSeqId());
+                orderItemAssociation.set("toShipGroupSeqId", "_NA_");
+                orderItemAssociation.set("orderItemAssocTypeId", item.getOrderItemAssocTypeId());
+                allOrderItemAssociations.add(orderItemAssociation);
             }
         }
         return allOrderItemAssociations;

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=485750&r1=485749&r2=485750
==============================================================================
--- 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 Dec 11 08:50:23 2006
@@ -109,8 +109,11 @@
     private String requirementId = null;
     private String quoteId = null;
     private String quoteItemSeqId = null;
+    // The following three optional fields are used to collect information for the OrderItemAssoc entity
     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 orderItemAssocTypeId = "PURCHASE_ORDER"; // the type of association between this item and an external item; by default, for backward compatibility, a PURCHASE association is used (i.e. the extarnal order is a sales order and this item is a purchase order item created to fulfill the sales order item
+
     private String statusId = null;
     private Map orderItemAttributes = null;
     private Map attributes = null;
@@ -569,6 +572,7 @@
         this.quoteItemSeqId = item.getQuoteItemSeqId();
         this.associatedOrderId = item.getAssociatedOrderId();
         this.associatedOrderItemSeqId = item.getAssociatedOrderItemSeqId();
+        this.orderItemAssocTypeId = item.getOrderItemAssocTypeId();
         this.isPromo = item.getIsPromo();
         this.promoQuantityUsed = item.promoQuantityUsed;
         this.locale = item.locale;
@@ -1395,7 +1399,19 @@
         return this.quoteItemSeqId;
     }
 
-    /** Sets the asociatedOrderId. */
+    /** Sets the orderItemAssocTypeId. */
+    public void setOrderItemAssocTypeId(String orderItemAssocTypeId) {
+        if (orderItemAssocTypeId != null) {
+            this.orderItemAssocTypeId = orderItemAssocTypeId;
+        }
+    }
+
+    /** Returns the OrderItemAssocTypeId. */
+    public String getOrderItemAssocTypeId() {
+        return this.orderItemAssocTypeId;
+    }
+
+    /** Sets the associatedOrderId. */
     public void setAssociatedOrderId(String associatedOrderId) {
         this.associatedOrderId = associatedOrderId;
     }