From 1cff71175f2edf4a600fd7cfeb45d92da2eab064 Mon Sep 17 00:00:00 2001 From: Jacopo Cappellato Date: Tue, 12 Sep 2006 09:07:29 +0000 Subject: [PATCH] Implemented association between sales order items and drop shipment purchase order items (thru OrderItemassociation). git-svn-id: https://svn.apache.org/repos/asf/incubator/ofbiz/trunk@442536 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/ofbiz/order/order/OrderServices.java | 22 ++++++++++------- .../order/shoppingcart/ShoppingCart.java | 8 ++++++- .../order/shoppingcart/ShoppingCartItem.java | 24 +++++++++++++++++++ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/applications/order/src/org/ofbiz/order/order/OrderServices.java b/applications/order/src/org/ofbiz/order/order/OrderServices.java index 8b9938a944..76bc5c8bd8 100644 --- a/applications/order/src/org/ofbiz/order/order/OrderServices.java +++ b/applications/order/src/org/ofbiz/order/order/OrderServices.java @@ -3581,15 +3581,19 @@ public class OrderServices { 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()); } diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java index 67412f66c2..41eafc3e6d 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java @@ -3427,7 +3427,6 @@ public class ShoppingCart implements Serializable { 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)); @@ -3444,6 +3443,13 @@ public class ShoppingCart implements Serializable { 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); + } } } return allOrderItemAssociations; diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java index 3e787f7c02..183c69b1f2 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java @@ -112,6 +112,8 @@ public class ShoppingCartItem implements java.io.Serializable { 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 @@ public class ShoppingCartItem implements java.io.Serializable { 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; @@ -1362,6 +1366,26 @@ public class ShoppingCartItem implements java.io.Serializable { 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() { return this.statusId; }