[OFBiz] SVN: r7806 - in trunk/applications: order/config order/src/org/ofbiz/order/order order/src/org/ofbiz/order/shoppingcart order/src/org/ofbiz/order/shoppingcart/product order/src/org/ofbiz/order/shoppinglist order/webapp/ordermgr/WEB-INF/actions/entry order/webapp/ordermgr/entry/cart pos/src/org/ofbiz/pos
jonesde@svn.ofbiz.org
jonesde at svn.ofbiz.org
Fri Jun 16 04:30:23 CDT 2006
Author: jonesde
Date: 2006-06-16 04:29:55 -0500 (Fri, 16 Jun 2006)
New Revision: 7806
Modified:
trunk/applications/order/config/OrderUiLabels.properties
trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java
trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java
trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java
trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/showcart.bsh
trunk/applications/order/webapp/ordermgr/entry/cart/showcart.ftl
trunk/applications/pos/src/org/ofbiz/pos/PosTransaction.java
Log:
Added support in the Order Manager PO entry UI to specify order item types; this required changes to underlying ShoppingCart and ShoppingCartItem structures, which of course cascade to various other methods there because of various funny design decisions; having become sufficient fatigued by certain of these, I also took this chance to review the dozens of nearly duplicate methods and eliminate most of them, this simplifies the API but forces consideration of more fields when calling the methods; to help with this I revised and improved some of the JavaDocs; yes, this does mean it is not backward compatible, but that was the case anyway as the new itemType parameter needed to be added in many places, just as the itemGroup and many others before it
Modified: trunk/applications/order/config/OrderUiLabels.properties
===================================================================
--- trunk/applications/order/config/OrderUiLabels.properties 2006-06-16 04:43:33 UTC (rev 7805)
+++ trunk/applications/order/config/OrderUiLabels.properties 2006-06-16 09:29:55 UTC (rev 7806)
@@ -195,6 +195,7 @@
OrderOrderId = Order Id
OrderOrderInclude=Include
OrderOrderItems = Order Items
+OrderOrderItemType = Item Type
OrderOrderList = Order List
OrderOrderManagerApplication = Order Manager Application
OrderOrderNeedingAttention = Orders Needing Attention
Modified: trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java 2006-06-16 04:43:33 UTC (rev 7805)
+++ trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java 2006-06-16 09:29:55 UTC (rev 7806)
@@ -2809,7 +2809,7 @@
// add in the new product
try {
- ShoppingCartItem item = ShoppingCartItem.makeItem(null, productId, 0.00, quantity.doubleValue(), null, null, null, dispatcher, cart);
+ ShoppingCartItem item = ShoppingCartItem.makeItem(null, productId, null, quantity.doubleValue(), null, null, null, null, null, null, null, null, null, null, null, null, dispatcher, cart, null, null);
if (basePrice != null&&overridePrice!=null) {
item.setBasePrice(basePrice.doubleValue());
// special hack to make sure we re-calc the promos after a price change
@@ -3281,7 +3281,7 @@
Locale locale = (Locale) context.get("locale");
ShoppingCart cart = new ShoppingCart(dctx.getDelegator(), "9000", "webStore", locale, "USD");
try {
- cart.addOrIncreaseItem("GZ-1005", 1, null, null, "DemoCatalog", dctx.getDispatcher());
+ cart.addOrIncreaseItem("GZ-1005", null, 1, null, null, null, null, null, null, null, "DemoCatalog", null, null, null, dctx.getDispatcher());
} catch (CartItemModifyException e) {
Debug.logError(e, module);
} catch (ItemNotFoundException e) {
Modified: trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java 2006-06-16 04:43:33 UTC (rev 7805)
+++ trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java 2006-06-16 09:29:55 UTC (rev 7806)
@@ -424,20 +424,25 @@
* @return the new/increased item index
* @throws CartItemModifyException
*/
- public int addOrIncreaseItem(String productId, double selectedAmount, double quantity, Timestamp reservStart, double reservLength, double reservPersons,
+ public int addOrIncreaseItem(String productId, Double selectedAmountDbl, double quantity, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl,
Timestamp shipBeforeDate, Timestamp shipAfterDate, Map features, Map attributes, String prodCatalogId,
- ProductConfigWrapper configWrapper, String itemGroupNumber, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
+ ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
if (isReadOnlyCart()) {
throw new CartItemModifyException("Cart items cannot be changed");
}
+ double selectedAmount = selectedAmountDbl == null ? 0.0 : selectedAmountDbl.doubleValue();
+ double reservLength = reservLengthDbl == null ? 0.0 : reservLengthDbl.doubleValue();
+ double reservPersons = reservPersonsDbl == null ? 0.0 : reservPersonsDbl.doubleValue();
+
ShoppingCart.ShoppingCartItemGroup itemGroup = this.getItemGroupByNumber(itemGroupNumber);
GenericValue supplierProduct = null;
// Check for existing cart item.
for (int i = 0; i < this.cartLines.size(); i++) {
ShoppingCartItem sci = (ShoppingCartItem) cartLines.get(i);
- if (sci.equals(productId, reservStart, reservLength, reservPersons, features, attributes, prodCatalogId, configWrapper, itemGroup, selectedAmount)) {
+
+ if (sci.equals(productId, reservStart, reservLength, reservPersons, features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, selectedAmount)) {
double newQuantity = sci.getQuantity() + quantity;
if (Debug.verboseOn()) Debug.logVerbose("Found a match for id " + productId + " on line " + i + ", updating quantity to " + newQuantity, module);
@@ -460,36 +465,25 @@
//GenericValue productSupplier = null;
supplierProduct = getSupplierProduct(productId, quantity, dispatcher);
if (supplierProduct != null || "_NA_".equals(this.getPartyId())) {
- return this.addItem(0, ShoppingCartItem.makePurchaseOrderItem(new Integer(0), productId, selectedAmount, quantity, features, attributes, prodCatalogId, configWrapper, itemGroup, dispatcher, this, supplierProduct, shipBeforeDate, shipAfterDate));
+ return this.addItem(0, ShoppingCartItem.makePurchaseOrderItem(new Integer(0), productId, selectedAmountDbl, quantity, features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, dispatcher, this, supplierProduct, shipBeforeDate, shipAfterDate));
} else {
throw new CartItemModifyException("SupplierProduct not found");
}
} else {
- return this.addItem(0, ShoppingCartItem.makeItem(new Integer(0), productId, selectedAmount, quantity, 0.0,
- reservStart, reservLength, reservPersons, shipBeforeDate, shipAfterDate,
- features, attributes, prodCatalogId, configWrapper, itemGroup, dispatcher, this, true, true));
+ return this.addItem(0, ShoppingCartItem.makeItem(new Integer(0), productId, selectedAmountDbl, quantity, null,
+ reservStart, reservLengthDbl, reservPersonsDbl, shipBeforeDate, shipAfterDate,
+ features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, dispatcher, this, Boolean.TRUE, Boolean.TRUE));
}
}
- public int addOrIncreaseItem(String productId, double selectedAmount, double quantity, Map features, Map attributes, String prodCatalogId, String itemGroupNumber, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
- return addOrIncreaseItem(productId, 0.00, quantity, null, 0.00 ,0.00, null, null, features, attributes, prodCatalogId, null, itemGroupNumber, dispatcher);
- }
- public int addOrIncreaseItem(String productId, double quantity, Map features, Map attributes, String prodCatalogId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
- return addOrIncreaseItem(productId, 0.00, quantity, null, 0.00 ,0.00, null, null, features, attributes, prodCatalogId, null, null, dispatcher);
- }
- public int addOrIncreaseItem(String productId, double quantity, Timestamp reservStart, double reservLength, double reservPersons, Map features, Map attributes, String prodCatalogId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
- return addOrIncreaseItem(productId, 0.00, quantity, reservStart, reservLength, reservPersons, null, null, features, attributes, prodCatalogId, null, null, dispatcher);
- }
- public int addOrIncreaseItem(String productId, double quantity, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
- return addOrIncreaseItem(productId, quantity, null, null, null, dispatcher);
- }
/** Add a non-product item to the shopping cart.
* @return the new item index
* @throws CartItemModifyException
*/
- public int addNonProductItem(String itemType, String description, String categoryId, double price, double quantity, Map attributes, String prodCatalogId, String itemGroupNumber, LocalDispatcher dispatcher) throws CartItemModifyException {
+ public int addNonProductItem(String itemType, String description, String categoryId, Double price, double quantity,
+ Map attributes, String prodCatalogId, String itemGroupNumber, LocalDispatcher dispatcher) throws CartItemModifyException {
ShoppingCart.ShoppingCartItemGroup itemGroup = this.getItemGroupByNumber(itemGroupNumber);
- return this.addItem(0, ShoppingCartItem.makeItem(new Integer(0), itemType, description, categoryId, price, 0.00, quantity, attributes, prodCatalogId, itemGroup, dispatcher, this, true));
+ return this.addItem(0, ShoppingCartItem.makeItem(new Integer(0), itemType, description, categoryId, price, null, quantity, attributes, prodCatalogId, itemGroup, dispatcher, this, Boolean.TRUE));
}
/** Add an item to the shopping cart. */
@@ -506,21 +500,11 @@
}
/** Add an item to the shopping cart. */
- public int addItemToEnd(String productId, double amount, double quantity, HashMap features, HashMap attributes, String prodCatalogId, LocalDispatcher dispatcher, boolean triggerExternalOps) throws CartItemModifyException, ItemNotFoundException {
- return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, features, attributes, prodCatalogId, null, dispatcher, this, triggerExternalOps));
+ public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
+ return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, null, null, null, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules));
}
/** Add an item to the shopping cart. */
- public int addItemToEnd(String productId, double amount, double quantity, double unitPrice, HashMap features, HashMap attributes, String prodCatalogId, LocalDispatcher dispatcher, boolean triggerExternalOps, boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
- return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, null, 0.00, 0.00, null, null, features, attributes, prodCatalogId, null, null, dispatcher, this, triggerExternalOps, triggerPriceRules));
- }
-
- /** Add an item to the shopping cart. */
- public int addItemToEnd(String productId, double amount, double quantity, HashMap features, HashMap attributes, String prodCatalogId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
- return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, features, attributes, prodCatalogId, dispatcher, this));
- }
-
- /** Add an item to the shopping cart. */
public int addItemToEnd(ShoppingCartItem item) throws CartItemModifyException {
if (isReadOnlyCart()) {
throw new CartItemModifyException("Cart items cannot be changed");
Modified: trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java 2006-06-16 04:43:33 UTC (rev 7805)
+++ trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java 2006-06-16 09:29:55 UTC (rev 7806)
@@ -125,7 +125,7 @@
String itemDescription = null;
String productCategoryId = null;
String priceStr = null;
- double price = 0.00;
+ Double price = null;
String quantityStr = null;
double quantity = 0;
String reservStartStr = null;
@@ -133,9 +133,9 @@
java.sql.Timestamp reservStart = null;
java.sql.Timestamp reservEnd = null;
String reservLengthStr = null;
- double reservLength = 0;
+ Double reservLength = null;
String reservPersonsStr = null;
- double reservPersons = 0;
+ Double reservPersons = null;
String shipBeforeStr = null;
String shipBeforeDateStr = null;
String shipAfterDateStr = null;
@@ -263,7 +263,7 @@
}
if (reservStart != null && reservEnd != null) {
- reservLength = UtilDateTime.getInterval(reservStart,reservEnd)/86400000;
+ reservLength = new Double(UtilDateTime.getInterval(reservStart,reservEnd)/86400000);
}
@@ -272,11 +272,11 @@
reservLengthStr = (String) paramMap.remove("reservLength");
// parse the reservation Length
try {
- reservLength = nf.parse(reservLengthStr).doubleValue();
+ reservLength = new Double(nf.parse(reservLengthStr).doubleValue());
} catch (Exception e) {
Debug.logWarning(e,"Problems parsing reservation length string: "
+ reservLengthStr, module);
- reservLength = 1;
+ reservLength = new Double(1);
request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderReservationLengthShouldBeAPositiveNumber", locale));
return "error";
}
@@ -286,10 +286,10 @@
reservPersonsStr = (String) paramMap.remove("reservPersons");
// parse the number of persons
try {
- reservPersons = nf.parse(reservPersonsStr).doubleValue();
+ reservPersons = new Double(nf.parse(reservPersonsStr).doubleValue());
} catch (Exception e) {
Debug.logWarning(e,"Problems parsing reservation number of persons string: " + reservPersonsStr, module);
- reservPersons = 1;
+ reservPersons = new Double(1);
request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderNumberOfPersonsShouldBeOneOrLarger", locale));
return "error";
}
@@ -308,10 +308,10 @@
// parse the price
try {
- price = nf.parse(priceStr).doubleValue();
+ price = new Double(nf.parse(priceStr).doubleValue());
} catch (Exception e) {
Debug.logWarning(e, "Problems parsing price string: " + priceStr, module);
- price = 0.00;
+ price = null;
}
// parse the quantity
@@ -331,13 +331,13 @@
}
// parse the amount
- double amount = 0.00;
+ Double amount = null;
if (selectedAmountStr != null && selectedAmountStr.length() > 0) {
try {
- amount = nf.parse(selectedAmountStr).doubleValue();
+ amount = new Double(nf.parse(selectedAmountStr).doubleValue());
} catch (Exception e) {
Debug.logWarning(e, "Problem parsing amount string: " + selectedAmountStr, module);
- amount = 0.00;
+ amount = null;
}
}
@@ -1304,13 +1304,13 @@
}
// parse the amount
- double amount = 0.00;
+ Double amount = null;
if (selectedAmountStr != null && selectedAmountStr.length() > 0) {
try {
- amount = NumberFormat.getNumberInstance().parse(selectedAmountStr).doubleValue();
+ amount = new Double(NumberFormat.getNumberInstance().parse(selectedAmountStr).doubleValue());
} catch (Exception e) {
Debug.logWarning(e, "Problem parsing amount string: " + selectedAmountStr, module);
- amount = 0.00;
+ amount = null;
}
}
@@ -1324,7 +1324,7 @@
Debug.logInfo("Attempting to add to cart with productId = " + productId + ", categoryId = " + productCategoryId +
" and quantity = " + quantity, module);
result = cartHelper.addToCart(catalogId, shoppingListId, shoppingListItemSeqId, productId, productCategoryId,
- "", "", 0.00, amount, quantity, null, 0.00, 0.00, null, null, null, itemGroupNumber, itemAttributes);
+ null, "", null, amount, quantity, null, null, null, null, null, null, itemGroupNumber, itemAttributes);
// no values for itemType, itemDescription, price, and paramMap (a context for adding attributes)
controlDirective = processResult(result, request);
if (controlDirective.equals(ERROR)){ // if the add to cart failed, then get out of this loop right away
Modified: trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java 2006-06-16 04:43:33 UTC (rev 7805)
+++ trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java 2006-06-16 09:29:55 UTC (rev 7806)
@@ -96,14 +96,14 @@
/** Event to add an item to the shopping cart. */
public Map addToCart(String catalogId, String shoppingListId, String shoppingListItemSeqId, String productId,
String productCategoryId, String itemType, String itemDescription,
- double price, double amount, double quantity,
- java.sql.Timestamp reservStart, double reservLength, double reservPersons,
+ Double price, Double amount, double quantity,
+ java.sql.Timestamp reservStart, Double reservLength, Double reservPersons,
java.sql.Timestamp shipBeforeDate, java.sql.Timestamp shipAfterDate,
ProductConfigWrapper configWrapper, String itemGroupNumber, Map context) {
Map result = null;
Map attributes = null;
// price sanity check
- if (productId == null && price < 0) {
+ if (productId == null && price != null && price.doubleValue() < 0) {
String errMsg = UtilProperties.getMessage(resource, "cart.price_not_positive_number", this.cart.getLocale());
result = ServiceUtil.returnError(errMsg);
return result;
@@ -117,8 +117,8 @@
}
// amount sanity check
- if (amount < 0) {
- amount = 0;
+ if (amount != null && amount.doubleValue() < 0) {
+ amount = null;
}
// check desiredDeliveryDate syntax and remove if empty
@@ -173,7 +173,7 @@
Debug.logError(e, "Unable to lookup product : " + productId, module);
}
if (product == null || product.get("requireAmount") == null || "N".equals(product.getString("requireAmount"))) {
- amount = 0;
+ amount = null;
}
}
@@ -182,7 +182,7 @@
int itemId = -1;
if (productId != null) {
itemId = cart.addOrIncreaseItem(productId, amount, quantity, reservStart, reservLength, reservPersons, shipBeforeDate, shipAfterDate,
- null, attributes, catalogId, configWrapper, itemGroupNumber, dispatcher);
+ null, attributes, catalogId, configWrapper, itemType, itemGroupNumber, dispatcher);
} else {
itemId = cart.addNonProductItem(itemType, itemDescription, productCategoryId, price, quantity, attributes, catalogId, itemGroupNumber, dispatcher);
}
@@ -244,14 +244,10 @@
continue;
// never read: int itemId = -1;
if (orderItem.get("productId") != null && orderItem.get("quantity") != null) {
- double amount = 0.00;
- if (orderItem.get("selectedAmount") != null) {
- amount = orderItem.getDouble("selectedAmount").doubleValue();
- }
+ Double amount = orderItem.getDouble("selectedAmount");
try {
- this.cart.addOrIncreaseItem(orderItem.getString("productId"),
- amount, orderItem.getDouble("quantity").doubleValue(),
- null, null, catalogId, itemGroupNumber, dispatcher);
+ this.cart.addOrIncreaseItem(orderItem.getString("productId"), amount, orderItem.getDouble("quantity").doubleValue(),
+ null, null, null, null, null, null, null, catalogId, null, orderItemTypeId, itemGroupNumber, dispatcher);
noItems = false;
} catch (CartItemModifyException e) {
errorMsgs.add(e.getMessage());
@@ -285,13 +281,11 @@
}
if (orderItem != null) {
if (orderItem.get("productId") != null && orderItem.get("quantity") != null) {
- double amount = 0.00;
- if (orderItem.get("selectedAmount") != null) {
- amount = orderItem.getDouble("selectedAmount").doubleValue();
- }
+ Double amount = orderItem.getDouble("selectedAmount");
try {
this.cart.addOrIncreaseItem(orderItem.getString("productId"), amount,
- orderItem.getDouble("quantity").doubleValue(), null, null, catalogId, itemGroupNumber, dispatcher);
+ orderItem.getDouble("quantity").doubleValue(), null, null, null, null, null, null, null,
+ catalogId, null, orderItem.getString("orderItemTypeId"), itemGroupNumber, dispatcher);
noItems = false;
} catch (CartItemModifyException e) {
errorMsgs.add(e.getMessage());
@@ -380,7 +374,7 @@
if (quantity > 0.0) {
try {
if (Debug.verboseOn()) Debug.logVerbose("Bulk Adding to cart [" + quantity + "] of [" + productId + "] in Item Group [" + itemGroupNumber + "]", module);
- this.cart.addOrIncreaseItem(productId, 0.0, quantity, null, null, catalogId, itemGroupNumberToUse, dispatcher);
+ this.cart.addOrIncreaseItem(productId, null, quantity, null, null, null, null, null, null, null, catalogId, null, null, itemGroupNumberToUse, dispatcher);
} catch (CartItemModifyException e) {
return ServiceUtil.returnError(e.getMessage());
} catch (ItemNotFoundException e) {
@@ -459,7 +453,7 @@
}
try {
if (Debug.verboseOn()) Debug.logVerbose("Bulk Adding to cart requirement [" + quantity + "] of [" + productId + "]", module);
- int index = this.cart.addOrIncreaseItem(productId, 0.00, quantity, null, null, catalogId, itemGroupNumber, dispatcher);
+ int index = this.cart.addOrIncreaseItem(productId, null, quantity, null, null, null, null, null, null, null, catalogId, null, null, itemGroupNumber, dispatcher);
ShoppingCartItem sci = (ShoppingCartItem)this.cart.items().get(index);
sci.setRequirementId(requirementId);
} catch (CartItemModifyException e) {
@@ -522,7 +516,8 @@
if (quantity != null && quantity.doubleValue() > 0.0) {
try {
this.cart.addOrIncreaseItem(productCategoryMember.getString("productId"),
- 0.00, quantity.doubleValue(), null, null, catalogId, itemGroupNumber, dispatcher);
+ null, quantity.doubleValue(), null, null, null, null, null, null, null,
+ catalogId, null, null, itemGroupNumber, dispatcher);
totalQuantity += quantity.doubleValue();
} catch (CartItemModifyException e) {
errorMsgs.add(e.getMessage());
@@ -664,6 +659,10 @@
quantString += " 00:00:00.000";
item.setShipAfterDate(Timestamp.valueOf(quantString));
}
+ } else if (parameterName.startsWith("itemType")) {
+ if (item != null && quantString.length() > 0) {
+ item.setItemType(quantString);
+ }
} else {
quantity = nf.parse(quantString).doubleValue();
if (quantity < 0) {
Modified: trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java 2006-06-16 04:43:33 UTC (rev 7805)
+++ trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java 2006-06-16 09:29:55 UTC (rev 7806)
@@ -133,155 +133,6 @@
private List featuresForSupplier = new LinkedList();
/**
- * Makes a ShoppingCartItem and adds it to the cart.
- * NOTE: This method will get the product entity and check to make sure it can be purchased.
- *
- * @param cartLocation The location to place this item; null will place at the end
- * @param productId The primary key of the product being added
- * @param quantity The quantity to add
- * @param additionalProductFeatureAndAppls Product feature/appls map
- * @param attributes All unique attributes for this item (NOT features)
- * @param prodCatalogId The catalog this item was added from
- * @param dispatcher LocalDispatcher object for doing promotions, etc
- * @param cart The parent shopping cart object this item will belong to
- * @return a new ShoppingCartItem object
- * @throws CartItemModifyException
- */
- public static ShoppingCartItem makeItem(Integer cartLocation, String productId, double selectedAmount, double quantity, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, LocalDispatcher dispatcher, ShoppingCart cart) throws CartItemModifyException, ItemNotFoundException {
- return ShoppingCartItem.makeItem(cartLocation, productId, selectedAmount, quantity, additionalProductFeatureAndAppls, attributes, prodCatalogId, null, dispatcher, cart);
- }
-
- /**
- * Makes a ShoppingCartItem and adds it to the cart.
- * NOTE: This method will get the product entity and check to make sure it can be purchased.
- *
- * @param cartLocation The location to place this item; null will place at the end
- * @param productId The primary key of the product being added
- * @param selectedAmount ?
- * @param quantity The quantity to add
- * @param additionalProductFeatureAndAppls Product feature/appls map
- * @param attributes All unique attributes for this item (NOT features)
- * @param prodCatalogId The catalog this item was added from
- * @param configWrapper The product configuration wrapper (null if the product is not configurable)
- * @param dispatcher LocalDispatcher object for doing promotions, etc
- * @param cart The parent shopping cart object this item will belong to
- * @return a new ShoppingCartItem object
- * @throws CartItemModifyException
- */
- public static ShoppingCartItem makeItem(Integer cartLocation, String productId, double selectedAmount, double quantity, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher, ShoppingCart cart) throws CartItemModifyException, ItemNotFoundException {
- return ShoppingCartItem.makeItem(cartLocation, productId, selectedAmount, quantity, null, 0.00, 0.00, null, null, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, dispatcher, cart);
- }
-
- /**
- * Makes a ShoppingCartItem and adds it to the cart.
- * NOTE: This method will get the product entity and check to make sure it can be purchased.
- *
- * @param cartLocation The location to place this item; null will place at the end
- * @param productId The primary key of the product being added
- * @param selectedAmount ?
- * @param quantity The quantity to add
- * @param additionalProductFeatureAndAppls Product feature/appls map
- * @param attributes All unique attributes for this item (NOT features)
- * @param prodCatalogId The catalog this item was added from
- * @param configWrapper The product configuration wrapper (null if the product is not configurable)
- * @param dispatcher LocalDispatcher object for doing promotions, etc
- * @param cart The parent shopping cart object this item will belong to
- * @return a new ShoppingCartItem object
- * @throws CartItemModifyException
- */
- public static ShoppingCartItem makeItem(Integer cartLocation, String productId, double selectedAmount, double quantity, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher, ShoppingCart cart, boolean triggerExternalOps) throws CartItemModifyException, ItemNotFoundException {
- return ShoppingCartItem.makeItem(cartLocation, productId, selectedAmount, quantity, null, 0.00, 0.00, null, null, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, dispatcher, cart, triggerExternalOps);
- }
-
- /**
- * Makes a ShoppingCartItem and adds it to the cart.
- * NOTE: This method will get the product entity and check to make sure it can be purchased.
- *
- * @param cartLocation The location to place this item; null will place at the end
- * @param productId The primary key of the product being added
- * @param selectedAmount ?
- * @param quantity The quantity to add
- * @param reservStart start of the reservation
- * @param reservLength length of the reservation
- * @param reservPersons nbr of persons taking advantage of the reservation
- * @param shipBeforeDate The date to ship the order by
- * @param shipAfterDate Wait until this date to ship
- * @param additionalProductFeatureAndAppls Product feature/appls map
- * @param attributes All unique attributes for this item (NOT features)
- * @param prodCatalogId The catalog this item was added from
- * @param configWrapper The product configuration wrapper (null if the product is not configurable)
- * @param dispatcher LocalDispatcher object for doing promotions, etc
- * @param cart The parent shopping cart object this item will belong to
- * @return a new ShoppingCartItem object
- * @throws CartItemModifyException
- */
- public static ShoppingCartItem makeItem(Integer cartLocation, String productId, double selectedAmount, double quantity, Timestamp reservStart, double reservLength, double reservPersons, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher, ShoppingCart cart) throws CartItemModifyException, ItemNotFoundException {
- return ShoppingCartItem.makeItem(cartLocation, productId, selectedAmount, quantity, reservStart, reservLength, reservPersons, shipBeforeDate, shipAfterDate, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, dispatcher, cart, true);
- }
-
- public static ShoppingCartItem makeItem(Integer cartLocation, String productId, double selectedAmount, double quantity, Timestamp reservStart, double reservLength, double reservPersons, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher, ShoppingCart cart, boolean triggerExternalOps) throws CartItemModifyException, ItemNotFoundException {
- return ShoppingCartItem.makeItem(cartLocation, productId, selectedAmount, quantity, 0.00, reservStart, reservLength, reservPersons, shipBeforeDate, shipAfterDate, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, null, dispatcher, cart, triggerExternalOps, true);
- }
- /**
- * Makes a ShoppingCartItem and adds it to the cart.
- * NOTE: This method will get the product entity and check to make sure it can be purchased.
- *
- * @param cartLocation The location to place this item; null will place at the end
- * @param productId The primary key of the product being added
- * @param selectedAmount ?
- * @param quantity The quantity to add
- * @param reservStart start of the reservation
- * @param reservLength length of the reservation
- * @param reservPersons nbr of persons taking advantage of the reservation
- * @param shipBeforeDate The date to ship the order by
- * @param shipAfterDate Wait until this date to ship
- * @param additionalProductFeatureAndAppls Product feature/appls map
- * @param attributes All unique attributes for this item (NOT features)
- * @param prodCatalogId The catalog this item was added from
- * @param configWrapper The product configuration wrapper (null if the product is not configurable)
- * @param dispatcher LocalDispatcher object for doing promotions, etc
- * @param cart The parent shopping cart object this item will belong to
- * @return a new ShoppingCartItem object
- * @throws CartItemModifyException
- */
- public static ShoppingCartItem makeItem(Integer cartLocation, String productId, double selectedAmount, double quantity, double unitPrice,
- Timestamp reservStart, double reservLength, double reservPersons, Timestamp shipBeforeDate, Timestamp shipAfterDate,
- Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper,
- ShoppingCart.ShoppingCartItemGroup itemGroup, LocalDispatcher dispatcher, ShoppingCart cart, boolean triggerExternalOps, boolean triggerProductPrice)
- throws CartItemModifyException, ItemNotFoundException {
- GenericDelegator delegator = cart.getDelegator();
- GenericValue product = null;
-
- try {
- product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId));
-
- // first see if there is a purchase allow category and if this product is in it or not
- String purchaseProductCategoryId = CatalogWorker.getCatalogPurchaseAllowCategoryId(delegator, prodCatalogId);
- if (product != null && purchaseProductCategoryId != null) {
- if (!CategoryWorker.isProductInCategory(delegator, product.getString("productId"), purchaseProductCategoryId)) {
- // a Purchase allow productCategoryId was found, but the product is not in the category, axe it...
- product = null;
- }
- }
- } catch (GenericEntityException e) {
- Debug.logWarning(e.toString(), module);
- product = null;
- }
-
- if (product == null) {
- Map messageMap = UtilMisc.toMap("productId", productId );
-
- String excMsg = UtilProperties.getMessage(resource, "item.product_not_found",
- messageMap , cart.getLocale() );
-
- Debug.logWarning(excMsg, module);
- throw new ItemNotFoundException(excMsg);
- }
-
- return makeItem(cartLocation, product, selectedAmount, quantity, unitPrice, reservStart, reservLength, reservPersons, shipBeforeDate, shipAfterDate, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, itemGroup, dispatcher, cart, triggerExternalOps, triggerProductPrice);
- }
-
- /**
* Makes a ShoppingCartItem for a purchase order item and adds it to the cart.
* NOTE: This method will get the product entity and check to make sure it can be purchased.
*
@@ -300,8 +151,8 @@
* @return a new ShoppingCartItem object
* @throws CartItemModifyException
*/
- public static ShoppingCartItem makePurchaseOrderItem(Integer cartLocation, String productId, double selectedAmount, double quantity,
- Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, ShoppingCart.ShoppingCartItemGroup itemGroup,
+ public static ShoppingCartItem makePurchaseOrderItem(Integer cartLocation, String productId, Double selectedAmountDbl, double quantity,
+ Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup,
LocalDispatcher dispatcher, ShoppingCart cart, GenericValue supplierProduct, Timestamp shipBeforeDate, Timestamp shipAfterDate)
throws CartItemModifyException, ItemNotFoundException {
GenericDelegator delegator = cart.getDelegator();
@@ -323,7 +174,7 @@
Debug.logWarning(excMsg, module);
throw new ItemNotFoundException(excMsg);
}
- ShoppingCartItem newItem = new ShoppingCartItem(product, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, cart.getLocale(), itemGroup);
+ ShoppingCartItem newItem = new ShoppingCartItem(product, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, cart.getLocale(), itemType, itemGroup);
// check to see if product is virtual
if ("Y".equals(product.getString("isVirtual"))) {
@@ -354,8 +205,8 @@
cart.addItem(cartLocation.intValue(), newItem);
}
- if (selectedAmount > 0) {
- newItem.setSelectedAmount(selectedAmount);
+ if (selectedAmountDbl != null) {
+ newItem.setSelectedAmount(selectedAmountDbl.doubleValue());
}
// set the ship before/after dates. this needs to happen before setQuantity because setQuantity causes the ship group's dates to be
@@ -383,45 +234,71 @@
return newItem;
}
- /**
- * Makes a ShoppingCartItem and adds it to the cart.
- * WARNING: This method does not check if the product is in a purchase category.
- *
- * @param cartLocation The location to place this item; null will place at the end
- * @param product The product entity relating to the product being added
- * @param quantity The quantity to add
- * @param additionalProductFeatureAndAppls Product feature/appls map
- * @param attributes All unique attributes for this item (NOT features)
- * @param prodCatalogId The catalog this item was added from
- * @param dispatcher LocalDispatcher object for doing promotions, etc
- * @param cart The parent shopping cart object this item will belong to
- * @param triggerExternalOps Indicates if we should run external operations (promotions, auto-save, etc)
- * @return a new ShoppingCartItem object
- * @throws CartItemModifyException
- */
- public static ShoppingCartItem makeItem(Integer cartLocation, GenericValue product, double selectedAmount, double quantity, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, LocalDispatcher dispatcher, ShoppingCart cart, boolean triggerExternalOps) throws CartItemModifyException {
- return ShoppingCartItem.makeItem(cartLocation, product, selectedAmount, quantity, additionalProductFeatureAndAppls, attributes, prodCatalogId, null, dispatcher, cart, triggerExternalOps);
- }
/**
* Makes a ShoppingCartItem and adds it to the cart.
- * WARNING: This method does not check if the product is in a purchase category.
+ * NOTE: This method will get the product entity and check to make sure it can be purchased.
*
* @param cartLocation The location to place this item; null will place at the end
- * @param product The product entity relating to the product being added
- * @param quantity The quantity to add
- * @param additionalProductFeatureAndAppls Product feature/appls map
- * @param attributes All unique attributes for this item (NOT features)
- * @param prodCatalogId The catalog this item was added from
- * @param configWrapper The product configuration wrapper (null if the product is not configurable)
- * @param dispatcher LocalDispatcher object for doing promotions, etc
- * @param cart The parent shopping cart object this item will belong to
- * @param triggerExternalOps Indicates if we should run external operations (promotions, auto-save, etc)
+ * @param productId The primary key of the product being added
+ * @param selectedAmountDbl Optional. Defaults to 0.0. If a selectedAmount is needed (complements the quantity value), pass it in here.
+ * @param quantity Required. The quantity to add.
+ * @param unitPriceDbl Optional. Defaults to 0.0, which causes calculation of price.
+ * @param reservStart Optional. The start of the reservation.
+ * @param reservLengthDbl Optional. The length of the reservation.
+ * @param reservPersonsDbl Optional. The number of persons taking advantage of the reservation.
+ * @param shipBeforeDate Optional. The date to ship the order by.
+ * @param shipAfterDate Optional. Wait until this date to ship.
+ * @param additionalProductFeatureAndAppls Optional. Product feature/appls map.
+ * @param attributes Optional. All unique attributes for this item (NOT features).
+ * @param prodCatalogId Optional, but strongly recommended. The catalog this item was added from.
+ * @param configWrapper Optional. The product configuration wrapper (null if the product is not configurable).
+ * @param itemType Optional. Specifies the type of cart item, corresponds to an OrderItemType and should be a valid orderItemTypeId.
+ * @param itemGroup Optional. Specifies which item group in the cart this should belong to, if item groups are needed/desired.
+ * @param dispatcher Required (for price calculation, promos, etc). LocalDispatcher object for doing promotions, etc.
+ * @param cart Required. The parent shopping cart object this item will belong to.
+ * @param triggerExternalOpsBool Optional. Defaults to true. Trigger external operations (like promotions and such)?
+ * @param triggerPriceRulesBool Optional. Defaults to true. Trigger the price rules to calculate the price for this item?
+ *
* @return a new ShoppingCartItem object
* @throws CartItemModifyException
*/
- public static ShoppingCartItem makeItem(Integer cartLocation, GenericValue product, double selectedAmount, double quantity, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher, ShoppingCart cart, boolean triggerExternalOps) throws CartItemModifyException {
- return ShoppingCartItem.makeItem(cartLocation, product, selectedAmount, quantity, null, 0.00, 0.00, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, dispatcher, cart, triggerExternalOps);
+ public static ShoppingCartItem makeItem(Integer cartLocation, String productId, Double selectedAmountDbl, double quantity, Double unitPriceDbl,
+ Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl, Timestamp shipBeforeDate, Timestamp shipAfterDate,
+ Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper,
+ String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, LocalDispatcher dispatcher, ShoppingCart cart, Boolean triggerExternalOpsBool, Boolean triggerPriceRulesBool)
+ throws CartItemModifyException, ItemNotFoundException {
+ GenericDelegator delegator = cart.getDelegator();
+ GenericValue product = null;
+
+ try {
+ product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId));
+
+ // first see if there is a purchase allow category and if this product is in it or not
+ String purchaseProductCategoryId = CatalogWorker.getCatalogPurchaseAllowCategoryId(delegator, prodCatalogId);
+ if (product != null && purchaseProductCategoryId != null) {
+ if (!CategoryWorker.isProductInCategory(delegator, product.getString("productId"), purchaseProductCategoryId)) {
+ // a Purchase allow productCategoryId was found, but the product is not in the category, axe it...
+ product = null;
+ }
+ }
+ } catch (GenericEntityException e) {
+ Debug.logWarning(e.toString(), module);
+ product = null;
+ }
+
+ if (product == null) {
+ Map messageMap = UtilMisc.toMap("productId", productId );
+ String excMsg = UtilProperties.getMessage(resource, "item.product_not_found", messageMap , cart.getLocale() );
+
+ Debug.logWarning(excMsg, module);
+ throw new ItemNotFoundException(excMsg);
+ }
+
+ return makeItem(cartLocation, product, selectedAmountDbl, quantity, unitPriceDbl,
+ reservStart, reservLengthDbl, reservPersonsDbl, shipBeforeDate, shipAfterDate,
+ additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper,
+ itemType, itemGroup, dispatcher, cart, triggerExternalOpsBool, triggerPriceRulesBool);
}
/**
@@ -431,30 +308,43 @@
*
* @param cartLocation The location to place this item; null will place at the end
* @param product The product entity relating to the product being added
- * @param quantity The quantity to add
- * @param reservStart the start of the reservation
- * @param reservLength the reservation length
- * @param reservPersons the number of persons using the reservation
- * @param shipBeforeDate The date to ship the order by
- * @param shipAfterDate Wait until this date to ship
- * @param additionalProductFeatureAndAppls Product feature/appls map
- * @param attributes All unique attributes for this item (NOT features)
- * @param prodCatalogId The catalog this item was added from
- * @param configWrapper The product configuration wrapper (null if the product is not configurable)
- * @param dispatcher LocalDispatcher object for doing promotions, etc
- * @param cart The parent shopping cart object this item will belong to
- * @param triggerExternalOps Indicates if we should run external operations (promotions, auto-save, etc)
+ * @param selectedAmountDbl Optional. Defaults to 0.0. If a selectedAmount is needed (complements the quantity value), pass it in here.
+ * @param quantity Required. The quantity to add.
+ * @param unitPriceDbl Optional. Defaults to 0.0, which causes calculation of price.
+ * @param reservStart Optional. The start of the reservation.
+ * @param reservLengthDbl Optional. The length of the reservation.
+ * @param reservPersonsDbl Optional. The number of persons taking advantage of the reservation.
+ * @param shipBeforeDate Optional. The date to ship the order by.
+ * @param shipAfterDate Optional. Wait until this date to ship.
+ * @param additionalProductFeatureAndAppls Optional. Product feature/appls map.
+ * @param attributes Optional. All unique attributes for this item (NOT features).
+ * @param prodCatalogId Optional, but strongly recommended. The catalog this item was added from.
+ * @param configWrapper Optional. The product configuration wrapper (null if the product is not configurable).
+ * @param itemType Optional. Specifies the type of cart item, corresponds to an OrderItemType and should be a valid orderItemTypeId.
+ * @param itemGroup Optional. Specifies which item group in the cart this should belong to, if item groups are needed/desired.
+ * @param dispatcher Required (for price calculation, promos, etc). LocalDispatcher object for doing promotions, etc.
+ * @param cart Required. The parent shopping cart object this item will belong to.
+ * @param triggerExternalOpsBool Optional. Defaults to true. Trigger external operations (like promotions and such)?
+ * @param triggerPriceRulesBool Optional. Defaults to true. Trigger the price rules to calculate the price for this item?
+ *
* @return a new ShoppingCartItem object
* @throws CartItemModifyException
*/
- //public static ShoppingCartItem makeItem(Integer cartLocation, GenericValue product, double selectedAmount, double quantity, Timestamp reservStart, double reservLength, double reservPersons, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher, ShoppingCart cart, boolean triggerExternalOps) throws CartItemModifyException {
- public static ShoppingCartItem makeItem(Integer cartLocation, GenericValue product, double selectedAmount,
- double quantity, double unitPrice, Timestamp reservStart, double reservLength, double reservPersons,
+ public static ShoppingCartItem makeItem(Integer cartLocation, GenericValue product, Double selectedAmountDbl,
+ double quantity, Double unitPriceDbl, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl,
Timestamp shipBeforeDate, Timestamp shipAfterDate, Map additionalProductFeatureAndAppls, Map attributes,
- String prodCatalogId, ProductConfigWrapper configWrapper, ShoppingCart.ShoppingCartItemGroup itemGroup, LocalDispatcher dispatcher,
- ShoppingCart cart, boolean triggerExternalOps, boolean triggerPriceRules) throws CartItemModifyException {
- ShoppingCartItem newItem = new ShoppingCartItem(product, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, cart.getLocale(), itemGroup);
-
+ String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, LocalDispatcher dispatcher,
+ ShoppingCart cart, Boolean triggerExternalOpsBool, Boolean triggerPriceRulesBool) throws CartItemModifyException {
+
+ ShoppingCartItem newItem = new ShoppingCartItem(product, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, cart.getLocale(), itemType, itemGroup);
+
+ double selectedAmount = selectedAmountDbl == null ? 0.0 : selectedAmountDbl.doubleValue();
+ double unitPrice = unitPriceDbl == null ? 0.0 : unitPriceDbl.doubleValue();
+ double reservLength = reservLengthDbl == null ? 0.0 : reservLengthDbl.doubleValue();
+ double reservPersons = reservPersonsDbl == null ? 0.0 : reservPersonsDbl.doubleValue();
+ boolean triggerPriceRules = triggerPriceRulesBool == null ? true : triggerPriceRulesBool.booleanValue();
+ boolean triggerExternalOps = triggerExternalOpsBool == null ? true : triggerExternalOpsBool.booleanValue();
+
// check to see if product is virtual
if ("Y".equals(product.getString("isVirtual"))) {
String excMsg = "Tried to add the Virtual Product " + product.getString("productName") +
@@ -573,20 +463,6 @@
return newItem;
}
- // Calls makeItem(...) setting a default value, 0.00, for the selectedAmount
- public static ShoppingCartItem makeItem(Integer cartLocation, GenericValue product, double quantity,
- Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, LocalDispatcher dispatcher,
- ShoppingCart cart, boolean triggerExternalOps) throws CartItemModifyException {
- return makeItem(cartLocation, product, 0.00, quantity, additionalProductFeatureAndAppls, attributes, prodCatalogId, dispatcher, cart, triggerExternalOps);
- }
-
- // Calls makeItem(...) setting a default value, 0.00, for unitPrice and setting the triggerProductPrice to true;
- // in this way, the prices and price rules are automatically set by the updatePrice(...) method
- public static ShoppingCartItem makeItem(Integer cartLocation, GenericValue product, double selectedAmount, double quantity,
- Timestamp reservStart, double reservLength, double reservPersons, Map additionalProductFeatureAndAppls, Map attributes,
- String prodCatalogId, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher, ShoppingCart cart, boolean triggerExternalOps) throws CartItemModifyException {
- return makeItem(cartLocation, product, selectedAmount, quantity, 0.0, reservStart, reservLength, reservPersons, null, null, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, null, dispatcher, cart, triggerExternalOps, true);
- }
/**
* Makes a non-product ShoppingCartItem and adds it to the cart.
* NOTE: This is only for non-product items; items without a product entity (work items, bulk items, etc)
@@ -607,8 +483,9 @@
* @throws CartItemModifyException
*/
public static ShoppingCartItem makeItem(Integer cartLocation, String itemType, String itemDescription, String productCategoryId,
- double basePrice, double selectedAmount, double quantity, Map attributes, String prodCatalogId, ShoppingCart.ShoppingCartItemGroup itemGroup,
- LocalDispatcher dispatcher, ShoppingCart cart, boolean triggerExternalOps) throws CartItemModifyException {
+ Double basePrice, Double selectedAmount, double quantity, Map attributes, String prodCatalogId, ShoppingCart.ShoppingCartItemGroup itemGroup,
+ LocalDispatcher dispatcher, ShoppingCart cart, Boolean triggerExternalOpsBool) throws CartItemModifyException {
+
GenericDelegator delegator = cart.getDelegator();
ShoppingCartItem newItem = new ShoppingCartItem(delegator, itemType, itemDescription, productCategoryId, basePrice, attributes, prodCatalogId, cart.getLocale(), itemGroup);
@@ -618,6 +495,8 @@
} else {
cart.addItem(cartLocation.intValue(), newItem);
}
+
+ boolean triggerExternalOps = triggerExternalOpsBool == null ? true : triggerExternalOpsBool.booleanValue();
try {
newItem.setQuantity(quantity, dispatcher, cart, triggerExternalOps);
@@ -626,8 +505,8 @@
throw e;
}
- if (selectedAmount > 0) {
- newItem.setSelectedAmount(selectedAmount);
+ if (selectedAmount != null) {
+ newItem.setSelectedAmount(selectedAmount.doubleValue());
}
return newItem;
}
@@ -684,8 +563,8 @@
protected ShoppingCartItem() {}
/** Creates new ShoppingCartItem object. */
- protected ShoppingCartItem(GenericValue product, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, Locale locale, ShoppingCart.ShoppingCartItemGroup itemGroup) {
- this(product, additionalProductFeatureAndAppls, attributes, prodCatalogId, null, locale, itemGroup);
+ protected ShoppingCartItem(GenericValue product, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, Locale locale, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup) {
+ this(product, additionalProductFeatureAndAppls, attributes, prodCatalogId, null, locale, itemType, itemGroup);
if (product != null) {
String productName = ProductContentWrapper.getProductContentAsText(product, "PRODUCT_NAME", this.locale);
// if the productName is null or empty, see if there is an associated virtual product and get the productName of that product
@@ -705,13 +584,17 @@
}
/** Creates new ShoppingCartItem object. */
- protected ShoppingCartItem(GenericValue product, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, Locale locale, ShoppingCart.ShoppingCartItemGroup itemGroup) {
+ protected ShoppingCartItem(GenericValue product, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, Locale locale, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup) {
this._product = product;
this.productId = _product.getString("productId");
- if (_product.getString("productTypeId").equals("ASSET_USAGE")) {
- this.itemType = "RENTAL_ORDER_ITEM"; // will create additional workeffort/asset usage records
+ if (UtilValidate.isEmpty(itemType)) {
+ if (_product.getString("productTypeId").equals("ASSET_USAGE")) {
+ this.itemType = "RENTAL_ORDER_ITEM"; // will create additional workeffort/asset usage records
+ } else {
+ this.itemType = "PRODUCT_ORDER_ITEM";
+ }
} else {
- this.itemType = "PRODUCT_ORDER_ITEM";
+ this.itemType = itemType;
}
this.itemGroup = itemGroup;
this.prodCatalogId = prodCatalogId;
@@ -724,14 +607,16 @@
}
/** Creates new ShopingCartItem object. */
- protected ShoppingCartItem(GenericDelegator delegator, String itemTypeId, String description, String categoryId, double basePrice, Map attributes, String prodCatalogId, Locale locale, ShoppingCart.ShoppingCartItemGroup itemGroup) {
+ protected ShoppingCartItem(GenericDelegator delegator, String itemTypeId, String description, String categoryId, Double basePrice, Map attributes, String prodCatalogId, Locale locale, ShoppingCart.ShoppingCartItemGroup itemGroup) {
this.delegator = delegator;
this.itemType = itemTypeId;
this.itemGroup = itemGroup;
this.itemDescription = description;
this.productCategoryId = categoryId;
- this.setBasePrice(basePrice);
- this.setDisplayPrice(basePrice);
+ if (basePrice != null) {
+ this.setBasePrice(basePrice.doubleValue());
+ this.setDisplayPrice(basePrice.doubleValue());
+ }
this.attributes = attributes;
this.prodCatalogId = prodCatalogId;
this.delegatorName = delegator.getDelegatorName();
@@ -1270,6 +1155,16 @@
return this.itemType;
}
+ /** Returns the item type. */
+ public GenericValue getItemTypeGenericValue() {
+ try {
+ return this.getDelegator().findByPrimaryKeyCache("OrderItemType", UtilMisc.toMap("orderItemTypeId", this.itemType));
+ } catch (GenericEntityException e) {
+ Debug.logError(e, "Error getting ShippingCartItem's OrderItemType", module);
+ return null;
+ }
+ }
+
/** Sets the item group. */
public void setItemGroup(ShoppingCart.ShoppingCartItemGroup itemGroup) {
this.itemGroup = itemGroup;
@@ -1677,7 +1572,7 @@
/** calculates for a reservation the percentage/100 extra for more than 1 person. */
// similar code at editShoppingList.bsh
public double getRentalAdjustment() {
- if (!this.itemType.equals("RENTAL_ORDER_ITEM")) {
+ if (!"RENTAL_ORDER_ITEM".equals(this.itemType)) {
// not a rental item?
return 1;
}
@@ -1938,31 +1833,33 @@
/** Compares the specified object with this cart item. */
public boolean equals(ShoppingCartItem item) {
if (item == null) return false;
- return this.equals(item.getProductId(), item.additionalProductFeatureAndAppls, item.attributes, item.prodCatalogId, item.selectedAmount, item.getItemGroup(), item.getIsPromo());
+ return this.equals(item.getProductId(), item.additionalProductFeatureAndAppls, item.attributes, item.prodCatalogId, item.selectedAmount, item.getItemType(), item.getItemGroup(), item.getIsPromo());
}
/** Compares the specified object with this cart item. Defaults isPromo to false. Default to no itemGroup. */
public boolean equals(String productId, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, double selectedAmount) {
- return equals(productId, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, null, false);
+ return equals(productId, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, null, null, false);
}
/** Compares the specified object with this cart item. Defaults isPromo to false. */
- public boolean equals(String productId, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, ShoppingCart.ShoppingCartItemGroup itemGroup, double selectedAmount) {
- return equals(productId, null, 0.00, 0.00, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, configWrapper, itemGroup, false);
+ public boolean equals(String productId, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, double selectedAmount) {
+ return equals(productId, null, 0.00, 0.00, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, configWrapper, itemType, itemGroup, false);
}
/** Compares the specified object with this cart item including rental data. Defaults isPromo to false. */
- public boolean equals(String productId, Timestamp reservStart, double reservLength, double reservPersons, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, ShoppingCart.ShoppingCartItemGroup itemGroup, double selectedAmount) {
- return equals(productId, reservStart, reservLength, reservPersons, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, configWrapper, itemGroup, false);
+ public boolean equals(String productId, Timestamp reservStart, double reservLength, double reservPersons, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, double selectedAmount) {
+ return equals(productId, reservStart, reservLength, reservPersons, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, configWrapper, itemType, itemGroup, false);
}
/** Compares the specified object with this cart item. Defaults isPromo to false. */
- public boolean equals(String productId, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, double selectedAmount, ShoppingCart.ShoppingCartItemGroup itemGroup, boolean isPromo) {
- return equals(productId, null, 0.00, 0.00, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, null, itemGroup, isPromo);
+ public boolean equals(String productId, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, double selectedAmount, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, boolean isPromo) {
+ return equals(productId, null, 0.00, 0.00, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, null, itemType, itemGroup, isPromo);
}
/** Compares the specified object with this cart item. */
- public boolean equals(String productId, Timestamp reservStart, double reservLength, double reservPersons, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, double selectedAmount, ProductConfigWrapper configWrapper, ShoppingCart.ShoppingCartItemGroup itemGroup, boolean isPromo) {
+ public boolean equals(String productId, Timestamp reservStart, double reservLength, double reservPersons,
+ Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, double selectedAmount,
+ ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, boolean isPromo) {
if (this.productId == null || productId == null) {
// all non-product items are unique
return false;
@@ -2017,6 +1914,10 @@
return false;
}
+ if (itemType != null && !itemType.equals(this.itemType)) {
+ return false;
+ }
+
if (itemGroup != null && !itemGroup.equals(this.itemGroup)) {
return false;
}
Modified: trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java 2006-06-16 04:43:33 UTC (rev 7805)
+++ trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java 2006-06-16 09:29:55 UTC (rev 7806)
@@ -24,6 +24,7 @@
*/
package org.ofbiz.order.shoppingcart;
+import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -277,9 +278,10 @@
if (amount == null) {
amount = new Double(0);
}
- Double quantity = OrderReadHelper.getOrderItemQuantity(item);
- if (quantity == null) {
- quantity = new Double(0);
+ double quantityDbl = 0;
+ BigDecimal quantity = OrderReadHelper.getOrderItemQuantityBd(item);
+ if (quantity != null) {
+ quantityDbl = quantity.doubleValue();
}
int itemIndex = -1;
if (item.get("productId") == null) {
@@ -288,7 +290,7 @@
String desc = item.getString("itemDescription");
try {
// TODO: passing in null now for itemGroupNumber, but should reproduce from OrderItemGroup records
- itemIndex = cart.addNonProductItem(itemType, desc, null, 0.00, quantity.doubleValue(), null, null, null, dispatcher);
+ itemIndex = cart.addNonProductItem(itemType, desc, null, null, quantity.doubleValue(), null, null, null, dispatcher);
} catch (CartItemModifyException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -298,7 +300,7 @@
String prodCatalogId = item.getString("prodCatalogId");
String productId = item.getString("productId");
try {
- itemIndex = cart.addItemToEnd(productId, amount.doubleValue(), quantity.doubleValue(), null, null, prodCatalogId, dispatcher);
+ itemIndex = cart.addItemToEnd(productId, amount, quantityDbl, null, null, null, prodCatalogId, item.getString("orderItemTypeId"), dispatcher, null, null);
} catch (ItemNotFoundException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -542,7 +544,7 @@
String desc = item.getString("comments");
try {
// note that passing in null for itemGroupNumber as there is no real grouping concept in the quotes right now
- itemIndex = cart.addNonProductItem(null, desc, null, 0.00, quantity.doubleValue(), null, null, null, dispatcher);
+ itemIndex = cart.addNonProductItem(null, desc, null, null, quantity.doubleValue(), null, null, null, dispatcher);
} catch (CartItemModifyException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -551,7 +553,7 @@
// product item
String productId = item.getString("productId");
try {
- itemIndex = cart.addItemToEnd(productId, amount.doubleValue(), quantity.doubleValue(), quoteUnitPrice.doubleValue(), null, null, null, dispatcher, !applyQuoteAdjustments, (quoteUnitPrice.doubleValue() == 0));
+ itemIndex = cart.addItemToEnd(productId, amount, quantity.doubleValue(), quoteUnitPrice, null, null, null, null, dispatcher, new Boolean(!applyQuoteAdjustments), new Boolean(quoteUnitPrice.doubleValue() == 0));
} catch (ItemNotFoundException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -686,7 +688,7 @@
// product item
String productId = item.getString("productId");
try {
- itemIndex = cart.addItemToEnd(productId, 0.0, quantity.doubleValue(), null, new HashMap(), null, dispatcher);
+ itemIndex = cart.addItemToEnd(productId, null, quantity.doubleValue(), null, null, null, null, null, dispatcher, Boolean.TRUE, Boolean.TRUE);
} catch (ItemNotFoundException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
Modified: trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java 2006-06-16 04:43:33 UTC (rev 7805)
+++ trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java 2006-06-16 09:29:55 UTC (rev 7806)
@@ -1178,7 +1178,7 @@
try {
// just leave the prodCatalogId null, this line won't be associated with a catalog
String prodCatalogId = null;
- gwpItem = ShoppingCartItem.makeItem(null, product, quantity, null, null, prodCatalogId, dispatcher, cart, false);
+ gwpItem = ShoppingCartItem.makeItem(null, product, null, quantity, null, null, null, null, null, null, null, null, prodCatalogId, null, null, null, dispatcher, cart, Boolean.FALSE, Boolean.TRUE);
if (optionProductIds.size() > 0) {
gwpItem.setAlternativeOptionProductIds(optionProductIds);
} else {
Modified: trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java 2006-06-16 04:43:33 UTC (rev 7805)
+++ trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java 2006-06-16 09:29:55 UTC (rev 7806)
@@ -283,10 +283,11 @@
// TODO: add code to check for survey response requirement
// i cannot get the addOrDecrease function to accept a null reservStart field: i get a null pointer exception a null constant works....
- if (reservStart == null)
- cart.addOrIncreaseItem(productId, quantity.doubleValue(), null,0,0, null, attributes, prodCatalogId, dispatcher);
- else
- cart.addOrIncreaseItem(productId, quantity.doubleValue(), reservStart, reservLength.doubleValue(), reservPersons.doubleValue(), null, attributes, prodCatalogId, dispatcher);
+ if (reservStart == null) {
+ cart.addOrIncreaseItem(productId, null, quantity.doubleValue(), null, null, null, null, null, null, attributes, prodCatalogId, null, null, null, dispatcher);
+ } else {
+ cart.addOrIncreaseItem(productId, null, quantity.doubleValue(), reservStart, reservLength, reservPersons, null, null, null, attributes, prodCatalogId, null, null, null, dispatcher);
+ }
Map messageMap = UtilMisc.toMap("productId", productId);
errMsg = UtilProperties.getMessage(resource,"shoppinglistevents.added_product_to_cart", messageMap, cart.getLocale());
eventMessage.append(errMsg + "\n");
Modified: trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java 2006-06-16 04:43:33 UTC (rev 7805)
+++ trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java 2006-06-16 09:29:55 UTC (rev 7806)
@@ -436,12 +436,14 @@
String productId = shoppingListItem.getString("productId");
Double quantity = shoppingListItem.getDouble("quantity");
Timestamp reservStart = shoppingListItem.getTimestamp("reservStart");
- double reservLength = 0.00;
- if (shoppingListItem.get("reservLength") != null)
- reservLength = shoppingListItem.getDouble("reservLength").doubleValue();
- double reservPersons = 0.00;
- if (shoppingListItem.get("reservPersons") != null)
- reservPersons = shoppingListItem.getDouble("reservPersons").doubleValue();
+ Double reservLength = null;
+ if (shoppingListItem.get("reservLength") != null) {
+ reservLength = shoppingListItem.getDouble("reservLength");
+ }
+ Double reservPersons = null;;
+ if (shoppingListItem.get("reservPersons") != null) {
+ reservPersons = shoppingListItem.getDouble("reservPersons");
+ }
if (UtilValidate.isNotEmpty(productId) && quantity != null) {
// list items are noted in the shopping cart
String listId = shoppingListItem.getString("shoppingListId");
@@ -449,7 +451,7 @@
Map attributes = UtilMisc.toMap("shoppingListId", listId, "shoppingListItemSeqId", itemId);
try {
- listCart.addOrIncreaseItem(productId, quantity.doubleValue(), reservStart, reservLength, reservPersons, null, attributes, null, dispatcher);
+ listCart.addOrIncreaseItem(productId, null, quantity.doubleValue(), reservStart, reservLength, reservPersons, null, null, null, attributes, null, null, null, null, dispatcher);
} catch (CartItemModifyException e) {
Debug.logError(e, "Unable to add product to List Cart - " + productId, module);
} catch (ItemNotFoundException e) {
Modified: trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/showcart.bsh
===================================================================
--- trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/showcart.bsh 2006-06-16 04:43:33 UTC (rev 7805)
+++ trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/showcart.bsh 2006-06-16 09:29:55 UTC (rev 7806)
@@ -89,3 +89,7 @@
inventorySummary = dispatcher.runSync("getProductInventorySummaryForItems", UtilMisc.toMap("orderItems", shoppingCart.makeOrderItems()));
context.put("availableToPromiseMap", inventorySummary.get("availableToPromiseMap"));
context.put("quantityOnHandMap", inventorySummary.get("quantityOnHandMap"));
+
+// get purchase order item types
+purchaseOrderItemTypeList = delegator.findByAndCache("OrderItemType", UtilMisc.toMap("parentTypeId", "PURCHASE_SPECIFIC"));
+context.put("purchaseOrderItemTypeList", purchaseOrderItemTypeList);
Modified: trunk/applications/order/webapp/ordermgr/entry/cart/showcart.ftl
===================================================================
--- trunk/applications/order/webapp/ordermgr/entry/cart/showcart.ftl 2006-06-16 04:43:33 UTC (rev 7805)
+++ trunk/applications/order/webapp/ordermgr/entry/cart/showcart.ftl 2006-06-16 09:29:55 UTC (rev 7806)
@@ -1,5 +1,5 @@
<#--
- * Copyright (c) 2003-2005 The Open For Business Project - www.ofbiz.org
+ * Copyright (c) 2003-2006 The Open For Business Project - www.ofbiz.org
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -161,7 +161,22 @@
</div>
</td>
</tr>
+ <#if shoppingCart.getOrderType() == "PURCHASE_ORDER">
<tr>
+ <td align="right"><div class="tableheadtext">${uiLabelMap.OrderOrderItemType} :</div></td>
+ <td>
+ <div class="tabletext">
+ <select name="add_item_type" class="selectBox">
+ <option value=""> </option>
+ <#list purchaseOrderItemTypeList as orderItemType>
+ <option value="${orderItemType.orderItemTypeId}">${orderItemType.description}</option>
+ </#list>
+ </select>
+ </div>
+ </td>
+ </tr>
+ </#if>
+ <tr>
<td align="right"><div class="tableheadtext">${uiLabelMap.CommonComment} :</div></td>
<td>
<div class="tabletext">
@@ -185,7 +200,7 @@
<td>
<form method="post" action="<@ofbizUrl>additem</@ofbizUrl>" name="bulkworkaddform" style="margin: 0;">
<div class="tableheadtext">
- ${uiLabelMap.ProductItem}: ${uiLabelMap.ProductType}: <select name="add_item_type" class="selectBox"><option value="BULK_ORDER_ITEM">${uiLabelMap.ProductBulkItem}</option><option value="WORK_ORDER_ITEM">${uiLabelMap.ProductWorkItem}</option></select>
+ ${uiLabelMap.CommonOrderItemType}: <select name="add_item_type" class="selectBox"><option value="BULK_ORDER_ITEM">${uiLabelMap.ProductBulkItem}</option><option value="WORK_ORDER_ITEM">${uiLabelMap.ProductWorkItem}</option></select>
${uiLabelMap.ProductProductCategory}: <select name="add_category_id" class="selectBox">
<option></option>
<#list productCategoryList as productCategory>
@@ -309,7 +324,7 @@
<input size="60" class="inputBox" type="text" name="description_${cartLineIndex}" value="${cartLine.getName()?default("")}"/><br/>
<i>${cartLine.getDescription()?if_exists}</i>
<#if shoppingCart.getOrderType() != "PURCHASE_ORDER">
- <#-- only applies to sales orders, not purchase orders
+ <#-- only applies to sales orders, not purchase orders -->
<#-- if inventory is not required check to see if it is out of stock and needs to have a message shown about that... -->
<#assign itemProduct = cartLine.getProduct()>
<#assign isStoreInventoryNotRequiredAndNotAvailable = Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryRequiredAndAvailable(request, itemProduct, cartLine.getQuantity(), false, false)>
@@ -377,9 +392,32 @@
</td>
</tr>
</#if>
+ <#if shoppingCart.getOrderType() == "PURCHASE_ORDER">
+ <#assign currentOrderItemType = cartLine.getItemTypeGenericValue()?if_exists/>
+ <tr>
+ <td align="left">
+ <div class="tabletext">
+ ${uiLabelMap.OrderOrderItemType}:
+ <select name="itemType_${cartLineIndex}" class="selectBox">
+ <#if currentOrderItemType?has_content>
+ <option value="${currentOrderItemType.orderItemTypeId}">${currentOrderItemType.description}</option>
+ <option value="${currentOrderItemType.orderItemTypeId}">---</option>
+ </#if>
+ <option value=""> </option>
+ <#list purchaseOrderItemTypeList as orderItemType>
+ <option value="${orderItemType.orderItemTypeId}">${orderItemType.description}</option>
+ </#list>
+ </select>
+ </div>
+ </td>
+ </tr>
+ </#if>
+
<#-- ship before/after date -->
<tr>
- <td colspan="2"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>
+ <td colspan="2">
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
<td align="left">
<div class="tabletext">${uiLabelMap.OrderShipAfterDate}
<input type="text" class="inputBox" size="20" maxlength="30" name="shipAfterDate_${cartLineIndex}"
@@ -395,7 +433,9 @@
<a href="javascript:call_cal(document.cartform.shipBeforeDate_${cartLineIndex},'${shoppingCart.getShipBeforeDate()?default("")}');"><img src="/images/cal.gif" width="16" height="16" border="0" alt="${uiLabelMap.calendar_click_here_for_calendar}"/></a>
</div>
</td>
- </tr></table></td>
+ </tr>
+ </table>
+ </td>
</tr>
</table>
Modified: trunk/applications/pos/src/org/ofbiz/pos/PosTransaction.java
===================================================================
--- trunk/applications/pos/src/org/ofbiz/pos/PosTransaction.java 2006-06-16 04:43:33 UTC (rev 7805)
+++ trunk/applications/pos/src/org/ofbiz/pos/PosTransaction.java 2006-06-16 09:29:55 UTC (rev 7806)
@@ -1,5 +1,5 @@
/*
- * $Id: $
+ * $Id$
*
* Copyright 2001-2006 The Apache Software Foundation
*
@@ -350,7 +350,7 @@
public void addItem(String productId, double quantity) throws CartItemModifyException, ItemNotFoundException {
trace("add item", productId + "/" + quantity);
try {
- cart.addOrIncreaseItem(productId, quantity, session.getDispatcher());
+ cart.addOrIncreaseItem(productId, null, quantity, null, null, null, null, null, null, null, null, null, null, null, session.getDispatcher());
} catch (ItemNotFoundException e) {
trace("item not found", e);
throw e;
More information about the Svn
mailing list