Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=757091&r1=757090&r2=757091&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java Sat Mar 21 23:44:41 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -119,7 +119,7 @@ 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 + // 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 @@ -133,7 +133,7 @@ private Timestamp shipAfterDate = null; private Timestamp EstimatedShipDate = null; private Timestamp cancelBackOrderDate = null; - + private Map contactMechIdsMap = FastMap.newInstance(); private List orderItemPriceInfos = null; private List itemAdjustments = new LinkedList(); @@ -167,9 +167,9 @@ * @return a new ShoppingCartItem object * @throws CartItemModifyException */ - public static ShoppingCartItem makePurchaseOrderItem(Integer cartLocation, String productId, BigDecimal selectedAmount, BigDecimal quantity, - Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, - LocalDispatcher dispatcher, ShoppingCart cart, GenericValue supplierProduct, Timestamp shipBeforeDate, Timestamp shipAfterDate, Timestamp cancelBackOrderDate) + public static ShoppingCartItem makePurchaseOrderItem(Integer cartLocation, String productId, BigDecimal selectedAmount, BigDecimal quantity, + Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, + LocalDispatcher dispatcher, ShoppingCart cart, GenericValue supplierProduct, Timestamp shipBeforeDate, Timestamp shipAfterDate, Timestamp cancelBackOrderDate) throws CartItemModifyException, ItemNotFoundException { GenericDelegator delegator = cart.getDelegator(); GenericValue product = null; @@ -194,12 +194,12 @@ // check to see if product is virtual if ("Y".equals(product.getString("isVirtual"))) { - Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), - "productId", product.getString("productId")); + Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), + "productId", product.getString("productId")); String excMsg = UtilProperties.getMessage(resource_error, "item.cannot_add_product_virtual", messageMap , cart.getLocale() ); - + Debug.logWarning(excMsg, module); throw new CartItemModifyException(excMsg); } @@ -209,12 +209,12 @@ // check to see if the product is fully configured if ("AGGREGATED".equals(product.getString("productTypeId"))) { if (configWrapper == null || !configWrapper.isCompleted()) { - Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), - "productId", product.getString("productId")); + Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), + "productId", product.getString("productId")); String excMsg = UtilProperties.getMessage(resource_error, "item.cannot_add_product_not_configured_correctly", messageMap , cart.getLocale() ); - + Debug.logWarning(excMsg, module); throw new CartItemModifyException(excMsg); } @@ -230,7 +230,7 @@ if (selectedAmount != null) { newItem.setSelectedAmount(selectedAmount); } - + // set the ship before/after/dates and cancel back order date. this needs to happen before setQuantity because setQuantity causes the ship group's dates to be // checked versus the cart item's newItem.setShipBeforeDate(shipBeforeDate != null ? shipBeforeDate : cart.getDefaultShipBeforeDate()); @@ -282,41 +282,41 @@ * @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, String productId, BigDecimal selectedAmount, BigDecimal quantity, BigDecimal unitPrice, - Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, 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, String parentProductId, Boolean skipInventoryChecks, Boolean skipProductChecks) + public static ShoppingCartItem makeItem(Integer cartLocation, String productId, BigDecimal selectedAmount, BigDecimal quantity, BigDecimal unitPrice, + Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, 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, String parentProductId, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { - - return makeItem(cartLocation,productId,selectedAmount,quantity,unitPrice, - reservStart,reservLength,reservPersons,null,null,shipBeforeDate,shipAfterDate, - additionalProductFeatureAndAppls,attributes,prodCatalogId,configWrapper, + + return makeItem(cartLocation,productId,selectedAmount,quantity,unitPrice, + reservStart,reservLength,reservPersons,null,null,shipBeforeDate,shipAfterDate, + additionalProductFeatureAndAppls,attributes,prodCatalogId,configWrapper, itemType,itemGroup,dispatcher,cart,triggerExternalOpsBool,triggerPriceRulesBool, parentProductId,skipInventoryChecks,skipProductChecks); - + } - - /** + + /** * Makes a ShoppingCartItem and adds it to the cart. * @param accommodationMapId Optional. reservations add into workeffort * @param accommodationSpotId Optional. reservations add into workeffort */ - public static ShoppingCartItem makeItem(Integer cartLocation, String productId, BigDecimal selectedAmount, BigDecimal quantity, BigDecimal unitPrice, - Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons,String accommodationMapId,String accommodationSpotId, 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, String parentProductId, Boolean skipInventoryChecks, Boolean skipProductChecks) + public static ShoppingCartItem makeItem(Integer cartLocation, String productId, BigDecimal selectedAmount, BigDecimal quantity, BigDecimal unitPrice, + Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons,String accommodationMapId,String accommodationSpotId, 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, String parentProductId, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { GenericDelegator delegator = cart.getDelegator(); GenericValue product = null; GenericValue parentProduct = 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) { @@ -330,18 +330,18 @@ Debug.logWarning(e.toString(), module); product = null; } - + if (product == null) { Map messageMap = UtilMisc.toMap("productId", productId ); String excMsg = UtilProperties.getMessage(resource_error, "item.product_not_found", messageMap , cart.getLocale() ); - + Debug.logWarning(excMsg, module); throw new ItemNotFoundException(excMsg); } if (parentProductId != null) { - try + try { parentProduct = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", parentProductId)); } catch (GenericEntityException e) { @@ -349,9 +349,9 @@ parentProduct = null; } } - return makeItem(cartLocation, product, selectedAmount, quantity, unitPrice, - reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, - additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, + return makeItem(cartLocation, product, selectedAmount, quantity, unitPrice, + reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, + additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, itemType, itemGroup, dispatcher, cart, triggerExternalOpsBool, triggerPriceRulesBool, parentProduct, skipInventoryChecks, skipProductChecks); } @@ -380,33 +380,33 @@ * @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, BigDecimal selectedAmount, - BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, - Timestamp shipBeforeDate, Timestamp shipAfterDate, Map additionalProductFeatureAndAppls, Map attributes, - String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, LocalDispatcher dispatcher, + public static ShoppingCartItem makeItem(Integer cartLocation, GenericValue product, BigDecimal selectedAmount, + BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, + 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, GenericValue parentProduct, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException { - return makeItem(cartLocation,product,selectedAmount, - quantity,unitPrice,reservStart,reservLength,reservPersons, - null,null,shipBeforeDate,shipAfterDate,additionalProductFeatureAndAppls,attributes, - prodCatalogId,configWrapper,itemType,itemGroup,dispatcher,cart, + return makeItem(cartLocation,product,selectedAmount, + quantity,unitPrice,reservStart,reservLength,reservPersons, + null,null,shipBeforeDate,shipAfterDate,additionalProductFeatureAndAppls,attributes, + prodCatalogId,configWrapper,itemType,itemGroup,dispatcher,cart, triggerExternalOpsBool,triggerPriceRulesBool,parentProduct,skipInventoryChecks,skipProductChecks); } - - /** + + /** * Makes a ShoppingCartItem and adds it to the cart. * @param accommodationMapId Optional. reservations add into workeffort * @param accommodationSpotId Optional. reservations add into workeffort */ - public static ShoppingCartItem makeItem(Integer cartLocation, GenericValue product, BigDecimal selectedAmount, - BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, + public static ShoppingCartItem makeItem(Integer cartLocation, GenericValue product, BigDecimal selectedAmount, + BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, String accommodationMapId,String accommodationSpotId, - Timestamp shipBeforeDate, Timestamp shipAfterDate, Map additionalProductFeatureAndAppls, Map attributes, - String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, LocalDispatcher dispatcher, + 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, GenericValue parentProduct, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException { ShoppingCartItem newItem = new ShoppingCartItem(product, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, cart.getLocale(), itemType, itemGroup, parentProduct); @@ -417,11 +417,11 @@ reservPersons = reservPersons == null ? BigDecimal.ZERO : reservPersons; 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"))) { - Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), - "productId", product.getString("productId")); + if ("Y".equals(product.getString("isVirtual"))) { + Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), + "productId", product.getString("productId")); String excMsg = UtilProperties.getMessage(resource_error, "item.cannot_add_product_virtual", messageMap , cart.getLocale() ); @@ -431,15 +431,15 @@ } java.sql.Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); - + if (!skipProductChecks.booleanValue()) { // check to see if introductionDate hasn't passed yet if (product.get("introductionDate") != null && nowTimestamp.before(product.getTimestamp("introductionDate"))) { - Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), - "productId", product.getString("productId")); + Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), + "productId", product.getString("productId")); String excMsg = UtilProperties.getMessage(resource_error, "item.cannot_add_product_not_yet_available", - messageMap , cart.getLocale() ); + messageMap , cart.getLocale() ); Debug.logWarning(excMsg, module); throw new CartItemModifyException(excMsg); @@ -447,7 +447,7 @@ // check to see if salesDiscontinuationDate has passed if (product.get("salesDiscontinuationDate") != null && nowTimestamp.after(product.getTimestamp("salesDiscontinuationDate"))) { - Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), + Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), "productId", product.getString("productId")); String excMsg = UtilProperties.getMessage(resource_error, "item.cannot_add_product_no_longer_available", @@ -459,10 +459,10 @@ /* if (product.get("salesDiscWhenNotAvail") != null && "Y".equals(product.getString("salesDiscWhenNotAvail"))) { // check atp and if <= 0 then the product is no more available because - // all the units in warehouse are reserved by other sales orders and no new purchase orders will be done + // all the units in warehouse are reserved by other sales orders and no new purchase orders will be done // for this product. if (!newItem.isInventoryAvailableOrNotRequired(quantity, cart.getProductStoreId(), dispatcher)) { - Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), + Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), "productId", product.getString("productId")); String excMsg = UtilProperties.getMessage(resource_error, "item.cannot_add_product_no_longer_available", @@ -473,25 +473,25 @@ } } */ - + // check to see if the product is fully configured if ("AGGREGATED".equals(product.getString("productTypeId"))) { - if (configWrapper == null || !configWrapper.isCompleted()) { - Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), + if (configWrapper == null || !configWrapper.isCompleted()) { + Map messageMap = UtilMisc.toMap("productName", product.getString("productName"), "productId", product.getString("productId")); String excMsg = UtilProperties.getMessage(resource_error, "item.cannot_add_product_not_configured_correctly", messageMap , cart.getLocale() ); Debug.logWarning(excMsg, module); throw new CartItemModifyException(excMsg); } - } + } } - + // check to see if the product is a rental item if ("ASSET_USAGE".equals(product.getString("productTypeId"))) { if (reservStart == null) { String excMsg = UtilProperties.getMessage(resource_error, "item.missing_reservation_starting_date", - cart.getLocale() ); + cart.getLocale() ); throw new CartItemModifyException(excMsg); } @@ -504,19 +504,19 @@ if (reservLength.compareTo(BigDecimal.ONE) < 0) { String excMsg = UtilProperties.getMessage(resource_error, "item.number_of_days", - cart.getLocale() ); + cart.getLocale() ); throw new CartItemModifyException(excMsg); } newItem.setReservLength(reservLength); - + if (product.get("reservMaxPersons") != null) { BigDecimal reservMaxPersons = product.getBigDecimal("reservMaxPersons"); if (reservMaxPersons.compareTo(reservPersons) < 0) { - Map messageMap = UtilMisc.toMap("reservMaxPersons", product.getString("reservMaxPersons"), + Map messageMap = UtilMisc.toMap("reservMaxPersons", product.getString("reservMaxPersons"), "reservPersons", reservPersons); String excMsg = UtilProperties.getMessage(resource_error, "item.maximum_number_of_person_renting", messageMap, cart.getLocale() ); - + Debug.logInfo(excMsg,module); throw new CartItemModifyException(excMsg); } @@ -528,27 +528,27 @@ if (product.get("reservNthPPPerc") != null) newItem.setReservNthPPPerc(product.getBigDecimal("reservNthPPPerc")); - + if ((accommodationMapId != null) && (accommodationSpotId != null)) { newItem.setAccommodationId(accommodationMapId,accommodationSpotId); } - + // check to see if the related fixed asset is available for rent String isAvailable = checkAvailability(product.getString("productId"), quantity, reservStart, reservLength, cart); if (isAvailable.compareTo("OK") != 0) { - Map messageMap = UtilMisc.toMap("productId", product.getString("productId"), + Map messageMap = UtilMisc.toMap("productId", product.getString("productId"), "availableMessage", isAvailable); String excMsg = UtilProperties.getMessage(resource_error, "item.product_not_available", - messageMap, cart.getLocale() ); + messageMap, cart.getLocale() ); Debug.logInfo(excMsg, module); throw new CartItemModifyException(isAvailable); } } - + // set the ship before and after dates (defaults to cart ship before/after dates) newItem.setShipBeforeDate(shipBeforeDate != null ? shipBeforeDate : cart.getDefaultShipBeforeDate()); newItem.setShipAfterDate(shipAfterDate != null ? shipAfterDate : cart.getDefaultShipAfterDate()); - + // set the product unit price as base price // if triggerPriceRules is true this price will be overriden newItem.setBasePrice(unitPrice); @@ -599,8 +599,8 @@ * @return a new ShoppingCartItem object * @throws CartItemModifyException */ - public static ShoppingCartItem makeItem(Integer cartLocation, String itemType, String itemDescription, String productCategoryId, - BigDecimal basePrice, BigDecimal selectedAmount, BigDecimal quantity, Map attributes, String prodCatalogId, ShoppingCart.ShoppingCartItemGroup itemGroup, + public static ShoppingCartItem makeItem(Integer cartLocation, String itemType, String itemDescription, String productCategoryId, + BigDecimal basePrice, BigDecimal selectedAmount, BigDecimal quantity, Map attributes, String prodCatalogId, ShoppingCart.ShoppingCartItemGroup itemGroup, LocalDispatcher dispatcher, ShoppingCart cart, Boolean triggerExternalOpsBool) throws CartItemModifyException { GenericDelegator delegator = cart.getDelegator(); @@ -612,7 +612,7 @@ } else { cart.addItem(cartLocation.intValue(), newItem); } - + boolean triggerExternalOps = triggerExternalOpsBool == null ? true : triggerExternalOpsBool.booleanValue(); try { @@ -766,7 +766,7 @@ public String getExternalId() { return this.externalId; } - + /** Sets the user selected amount */ public void setSelectedAmount(BigDecimal selectedAmount) { this.selectedAmount = selectedAmount; @@ -858,7 +858,7 @@ selFixedAssetProduct = EntityUtil.filterByDate(allFixedAssetProduct, UtilDateTime.nowTimestamp(), "fromDate", "thruDate", true); } catch (GenericEntityException e) { Map messageMap = UtilMisc.toMap("productId", productId); - String msg = UtilProperties.getMessage(resource_error, "item.cannot_find_Fixed_Asset", messageMap , cart.getLocale()); + String msg = UtilProperties.getMessage(resource_error, "item.cannot_find_Fixed_Asset", messageMap , cart.getLocale()); return msg; } if (UtilValidate.isNotEmpty(selFixedAssetProduct)) { @@ -882,7 +882,7 @@ if (fixedAsset == null) { Map messageMap = UtilMisc.toMap("fixedAssetId", fixedAssetProduct.getString("fixedAssetId")); String msg = UtilProperties.getMessage(resource_error, "item.fixed_Asset_not_found", messageMap , cart.getLocale()); - return msg; + return msg; } //Debug.logInfo("Checking availability for product: " + productId.toString() + " and related FixedAsset: " + fixedAssetProduct.getString("fixedAssetId"),module); @@ -894,7 +894,7 @@ } catch (GenericEntityException e) { Debug.logWarning(e, module); } - if (techDataCalendar == null) { + if (techDataCalendar == null) { // no calendar ok, when not more that total capacity if (fixedAsset.getBigDecimal("productionCapacity").compareTo(quantity) >= 0) { String msg = UtilProperties.getMessage(resource_error, "item.availableOk", cart.getLocale()); @@ -946,14 +946,14 @@ } } } - if (resultMessage.compareTo("") == 0) { + if (resultMessage.compareTo("") == 0) { String msg = UtilProperties.getMessage(resource_error, "item.availableOk", cart.getLocale()); return msg; } else { Map messageMap = UtilMisc.toMap("resultMessage", resultMessage); String msg = UtilProperties.getMessage(resource_error, "item.notAvailable", messageMap, cart.getLocale()); - return msg; + return msg; } } @@ -1191,7 +1191,7 @@ this.setDisplayPrice(configWrapper.getTotalPrice()); } } - + // no try to do a recurring price calculation; not all products have recurring prices so may be null Map recurringPriceContext = FastMap.newInstance(); recurringPriceContext.putAll(priceContext); @@ -1246,7 +1246,7 @@ public BigDecimal getReservPersons() { return this.reservPersons; } - + /** Returns accommodationMapId */ public String getAccommodationMapId() { return this.accommodationMapId; @@ -1255,7 +1255,7 @@ public String getAccommodationSpotId() { return this.accommodationSpotId; } - + public BigDecimal getPromoQuantityUsed() { if (this.getIsPromo()) { return this.quantity; @@ -1432,7 +1432,7 @@ /** Sets the date to ship before */ public void setShipBeforeDate(Timestamp date) { this.shipBeforeDate = date; - + } /** Returns the date to ship before */ @@ -1449,26 +1449,26 @@ public Timestamp getShipAfterDate() { return this.shipAfterDate; } - + /** Sets the cancel back order date */ public void setCancelBackOrderDate(Timestamp date) { this.cancelBackOrderDate = date; } - + /** Returns the cancel back order date */ public Timestamp getCancelBackOrderDate() { return this.cancelBackOrderDate; } - + /** Sets the date to EstimatedShipDate */ public void setEstimatedShipDate(Timestamp date) { this.EstimatedShipDate = date; - } + } /** Returns the date to EstimatedShipDate */ public Timestamp getEstimatedShipDate() { return this.EstimatedShipDate; - } + } /** Sets the item type. */ public void setItemType(String itemType) { @@ -1504,7 +1504,7 @@ public ShoppingCart.ShoppingCartItemGroup getItemGroup() { return this.itemGroup; } - + public boolean isInItemGroup(String groupNumber) { if (this.itemGroup == null) return false; if (this.itemGroup.getGroupNumber().equals(groupNumber)) return true; @@ -1882,7 +1882,7 @@ } return curBasePrice; } - + public BigDecimal getDisplayPrice() { BigDecimal curDisplayPrice; if (this.displayPrice == null) { @@ -1896,21 +1896,21 @@ } return curDisplayPrice; } - + public BigDecimal getSpecialPromoPrice() { return this.specialPromoPrice; } public BigDecimal getRecurringBasePrice() { if (this.recurringBasePrice == null) return null; - + if (selectedAmount.compareTo(BigDecimal.ZERO) > 0) { return this.recurringBasePrice.multiply(selectedAmount); } else { return this.recurringBasePrice; } } - + public BigDecimal getRecurringDisplayPrice() { if (this.recurringDisplayPrice == null) { return this.getRecurringBasePrice(); @@ -1922,7 +1922,7 @@ return this.recurringDisplayPrice; } } - + /** Returns the list price. */ public BigDecimal getListPrice() { return listPrice; @@ -2000,25 +2000,25 @@ public BigDecimal getDisplayItemSubTotal() { return this.getDisplayPrice().multiply(this.getQuantity()).multiply(this.getRentalAdjustment()).add(this.getOtherAdjustments()); } - + public BigDecimal getDisplayItemSubTotalNoAdj() { return this.getDisplayPrice().multiply(this.getQuantity()); } public BigDecimal getDisplayItemRecurringSubTotal() { BigDecimal curRecurringDisplayPrice = this.getRecurringDisplayPrice(); - + if (curRecurringDisplayPrice == null) { return this.getOtherAdjustmentsRecurring(); } - + return curRecurringDisplayPrice.multiply(this.getQuantity()).add(this.getOtherAdjustmentsRecurring()); } public BigDecimal getDisplayItemRecurringSubTotalNoAdj() { BigDecimal curRecurringDisplayPrice = this.getRecurringDisplayPrice(); if (curRecurringDisplayPrice == null) return BigDecimal.ZERO; - + return curRecurringDisplayPrice.multiply(this.getQuantity()); } @@ -2263,7 +2263,7 @@ public boolean equals(String productId, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, BigDecimal selectedAmount) { return equals(productId, reservStart, reservLength, reservPersons, null, null, 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, BigDecimal selectedAmount, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, boolean isPromo) { return equals(productId, null, BigDecimal.ZERO, BigDecimal.ZERO, null, null, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, null, itemType, itemGroup, isPromo); @@ -2271,7 +2271,7 @@ /** Compares the specified object with this cart item. */ public boolean equals(String productId, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, String accommodationMapId, String accommodationSpotId, - Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, BigDecimal selectedAmount, + Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, BigDecimal selectedAmount, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, boolean isPromo) { if (this.productId == null || productId == null) { // all non-product items are unique @@ -2333,7 +2333,7 @@ if (configWrapper != null && !configWrapper.equals(this.configWrapper)) { return false; } - + if (itemType != null && !itemType.equals(this.itemType)) { return false; } Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=757091&r1=757090&r2=757091&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java Sat Mar 21 23:44:41 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -209,7 +209,7 @@ if (orderName != null) { cart.setOrderName(orderName); } - + // set the role information GenericValue placingParty = orh.getPlacingParty(); if (placingParty != null) { @@ -219,7 +219,7 @@ GenericValue billFromParty = orh.getBillFromParty(); if (billFromParty != null) { cart.setBillFromVendorPartyId(billFromParty.getString("partyId")); - } + } GenericValue billToParty = orh.getBillToParty(); if (billToParty != null) { @@ -328,12 +328,12 @@ if (quantity == null) { quantity = BigDecimal.ZERO; } - + BigDecimal unitPrice = null; if ("Y".equals(item.getString("isModifiedPrice"))) { unitPrice = item.getBigDecimal("unitPrice"); } - + int itemIndex = -1; if (item.get("productId") == null) { // non-product item @@ -350,15 +350,15 @@ // product item String prodCatalogId = item.getString("prodCatalogId"); String productId = item.getString("productId"); - + //prepare the rental data Timestamp reservStart = null; BigDecimal reservLength = null; BigDecimal reservPersons = null; String accommodationMapId = null; String accommodationSpotId = null; - - GenericValue workEffort = null; + + GenericValue workEffort = null; String workEffortId = orh.getCurrentOrderItemWorkEffort(item); if (workEffortId != null) { try { @@ -366,16 +366,16 @@ } catch (GenericEntityException e) { Debug.logError(e, module); } - } + } if (workEffort != null && "ASSET_USAGE".equals(workEffort.getString("workEffortTypeId"))) { reservStart = workEffort.getTimestamp("estimatedStartDate"); reservLength = OrderReadHelper.getWorkEffortRentalLength(workEffort); reservPersons = workEffort.getBigDecimal("reservPersons"); accommodationMapId = workEffort.getString("accommodationMapId"); accommodationSpotId = workEffort.getString("accommodationSpotId"); - + } //end of rental data - + //check for AGGREGATED products ProductConfigWrapper configWrapper = null; String configId = null; @@ -395,7 +395,7 @@ if (UtilValidate.isNotEmpty(configId)) { configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, configId, productId, productStoreId, prodCatalogId, website, currency, locale, userLogin); - } + } try { itemIndex = cart.addItemToEnd(productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons,accommodationMapId,accommodationSpotId, null, null, prodCatalogId, configWrapper, item.getString("orderItemTypeId"), dispatcher, null, unitPrice == null ? null : false, skipInventoryChecks, skipProductChecks); } catch (ItemNotFoundException e) { @@ -424,7 +424,7 @@ cartItem.setShoppingList(item.getString("shoppingListId"), item.getString("shoppingListItemSeqId")); cartItem.setIsModifiedPrice("Y".equals(item.getString("isModifiedPrice"))); cartItem.setName(item.getString("itemDescription")); - + // load order item attributes List<GenericValue> orderItemAttributesList = null; try { @@ -459,11 +459,11 @@ // set the PO number on the cart cart.setPoNumber(item.getString("correspondingPoId")); - + List<GenericValue> itemAdjustments = orh.getOrderItemAdjustments(item); - if (itemAdjustments != null) { + if (itemAdjustments != null) { for(GenericValue itemAdjustment : itemAdjustments) { - cartItem.addAdjustment(itemAdjustment); + cartItem.addAdjustment(itemAdjustment); } } } @@ -520,7 +520,7 @@ itemIndex ++; } } - + // set the item seq in the cart if (nextItemSeq > 0) { try { @@ -532,18 +532,18 @@ } } - List adjustments = orh.getOrderHeaderAdjustments(); + List adjustments = orh.getOrderHeaderAdjustments(); // If applyQuoteAdjustments is set to false then standard cart adjustments are used. if (!adjustments.isEmpty()) { // The cart adjustments are added to the cart cart.getAdjustments().addAll(adjustments); } - + Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("shoppingCart", cart); return result; } - + public static Map<String, Object> loadCartFromQuote(DispatchContext dctx, Map<String, Object> context) { LocalDispatcher dispatcher = dctx.getDispatcher(); GenericDelegator delegator = dctx.getDelegator(); @@ -554,7 +554,7 @@ Locale locale = (Locale) context.get("locale"); boolean applyQuoteAdjustments = applyQuoteAdjustmentsString == null || "true".equals(applyQuoteAdjustmentsString); - + // get the quote header GenericValue quote = null; try { @@ -585,7 +585,7 @@ cart.setQuoteId(quoteId); cart.setOrderName(quote.getString("quoteName")); cart.setChannelType(quote.getString("salesChannelEnumId")); - + List<GenericValue>quoteItems = null; List<GenericValue>quoteAdjs = null; List<GenericValue>quoteRoles = null; @@ -705,14 +705,14 @@ // pass to the cart the quoteUnitPrice/amount value. quoteUnitPrice = quoteUnitPrice.divide(amount, generalRounding); } - + //rental product data Timestamp reservStart = quoteItem.getTimestamp("reservStart"); BigDecimal reservLength = quoteItem.getBigDecimal("reservLength"); BigDecimal reservPersons = quoteItem.getBigDecimal("reservPersons"); //String accommodationMapId = quoteItem.getString("accommodationMapId"); //String accommodationSpotId = quoteItem.getString("accommodationSpotId"); - + int itemIndex = -1; if (quoteItem.get("productId") == null) { // non-product item @@ -730,10 +730,10 @@ ProductConfigWrapper configWrapper = null; if (UtilValidate.isNotEmpty(quoteItem.getString("configId"))) { configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, quoteItem.getString("configId"), productId, productStoreId, null, null, currency, locale, userLogin); - } + } try { itemIndex = cart.addItemToEnd(productId, amount, quantity, quoteUnitPrice, reservStart, reservLength, reservPersons,null,null, null, null, null, configWrapper, null, dispatcher, new Boolean(!applyQuoteAdjustments), new Boolean(quoteUnitPrice.compareTo(BigDecimal.ZERO) == 0), Boolean.FALSE, Boolean.FALSE); - + } catch (ItemNotFoundException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -854,7 +854,7 @@ long nextItemSeq = 0; if (UtilValidate.isNotEmpty(shoppingListItems)) { - for(GenericValue shoppingListItem : shoppingListItems) { + for(GenericValue shoppingListItem : shoppingListItems) { // get the next item sequence id String orderItemSeqId = shoppingListItem.getString("shoppingListItemSeqId"); try { @@ -918,7 +918,7 @@ result.put("shoppingCart", cart); return result; } - + public static Map<String, Object>getShoppingCartData(DispatchContext dctx, Map<String, Object> context) { Map<String, Object> result = ServiceUtil.returnSuccess(); Locale locale = (Locale) context.get("locale"); @@ -950,13 +950,13 @@ } return result; } - + public static Map<String, Object>getShoppingCartItemIndex(DispatchContext dctx, Map<String, Object> context) { Map<String, Object> result = ServiceUtil.returnSuccess(); ShoppingCart shoppingCart = (ShoppingCart) context.get("shoppingCart"); String productId = (String) context.get("productId"); if (shoppingCart != null && UtilValidate.isNotEmpty(shoppingCart.items())) { - List allItems = shoppingCart.items(); + List allItems = shoppingCart.items(); List items = shoppingCart.findAllCartItems(productId); if (items.size() > 0) { ShoppingCartItem item = (ShoppingCartItem)items.get(0); @@ -966,7 +966,7 @@ } return result; } - + public static Map<String, Object>resetShipGroupItems(DispatchContext dctx, Map<String, Object> context) { Map<String, Object> result = ServiceUtil.returnSuccess(); ShoppingCart cart = (ShoppingCart) context.get("shoppingCart"); @@ -978,7 +978,7 @@ } return result; } - + public static Map<String, Object>prepareVendorShipGroups(DispatchContext dctx, Map<String, Object> context) { LocalDispatcher dispatcher = dctx.getDispatcher(); GenericDelegator delegator = dctx.getDelegator(); @@ -1008,7 +1008,7 @@ } catch (GenericEntityException e) { Debug.logError(e.toString(), module); } - + if (UtilValidate.isEmpty(vendorProduct)) { if (vendorMap.containsKey("_NA_")) { index = ((Integer) vendorMap.get("_NA_")).intValue(); @@ -1016,7 +1016,7 @@ } else { index = cart.addShipInfo(); vendorMap.put("_NA_", index); - + ShoppingCart.CartShipInfo info = cart.getShipInfo(index); info.setVendorPartyId("_NA_"); info.setShipGroupSeqId(UtilFormatOut.formatPaddedNumber(index, 5)); @@ -1031,14 +1031,14 @@ } else { index = cart.addShipInfo(); vendorMap.put(vendorPartyId, index); - + ShoppingCart.CartShipInfo info = cart.getShipInfo(index); info.setVendorPartyId(vendorPartyId); info.setShipGroupSeqId(UtilFormatOut.formatPaddedNumber(index, 5)); cart.positionItemToGroup(item, item.getQuantity(), 0, index, true); } } - } + } return result; } } Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/WebShoppingCart.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/WebShoppingCart.java?rev=757091&r1=757090&r2=757091&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/WebShoppingCart.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/WebShoppingCart.java Sat Mar 21 23:44:41 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -34,16 +34,16 @@ * * Extension of {@link org.ofbiz.order.shoppingcart.ShoppingCart ShoppingCart} * class which provides web presentation layer specific functionality - * related specifically to user session information. + * related specifically to user session information. */ public class WebShoppingCart extends ShoppingCart { public WebShoppingCart(HttpServletRequest request, Locale locale, String currencyUom) { - // for purchase orders, bill to customer partyId must be set - otherwise, no way to know who we're purchasing for. supplierPartyId is furnished + // for purchase orders, bill to customer partyId must be set - otherwise, no way to know who we're purchasing for. supplierPartyId is furnished // by order manager for PO entry. // TODO: refactor constructor and the getCartObject method which calls them to multiple constructors for different types of orders super((GenericDelegator)request.getAttribute("delegator"), ProductStoreWorker.getProductStoreId(request), - WebSiteWorker.getWebSiteId(request), (locale != null ? locale : ProductStoreWorker.getStoreLocale(request)), - (currencyUom != null ? currencyUom : ProductStoreWorker.getStoreCurrencyUomId(request)), + WebSiteWorker.getWebSiteId(request), (locale != null ? locale : ProductStoreWorker.getStoreLocale(request)), + (currencyUom != null ? currencyUom : ProductStoreWorker.getStoreCurrencyUomId(request)), request.getParameter("billToCustomerPartyId"), (request.getParameter("supplierPartyId") != null ? request.getParameter("supplierPartyId") : request.getParameter("billFromVendorPartyId"))); @@ -54,9 +54,9 @@ } public WebShoppingCart(HttpServletRequest request) { - this(request, UtilHttp.getLocale(request), UtilHttp.getCurrencyUom(request)); + this(request, UtilHttp.getLocale(request), UtilHttp.getCurrencyUom(request)); } - + /** Creates a new cloned ShoppingCart Object. */ public WebShoppingCart(ShoppingCart cart) { super(cart); Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java?rev=757091&r1=757090&r2=757091&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java Sat Mar 21 23:44:41 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -47,13 +47,13 @@ public class ProductDisplayWorker { - + public static final String module = ProductDisplayWorker.class.getName(); /* ========================================================================================*/ - + /* ============================= Special Data Retreival Methods ===========================*/ - + public static List getRandomCartProductAssoc(ServletRequest request, boolean checkViewAllow) { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); HttpServletRequest httpRequest = (HttpServletRequest) request; @@ -73,7 +73,7 @@ List complementProducts = delegator.findByAndCache("ProductAssoc", UtilMisc.toMap("productId", item.getProductId(), "productAssocTypeId", "PRODUCT_COMPLEMENT"), null); // since ProductAssoc records have a fromDate and thruDate, we can filter by now so that only assocs in the date range are included complementProducts = EntityUtil.filterByDate(complementProducts); - + List productsCategories = delegator.findByAndCache("ProductCategoryMember", UtilMisc.toMap("productId", item.getProductId()), null); productsCategories = EntityUtil.filterByDate(productsCategories, true); if (productsCategories != null) { @@ -126,7 +126,7 @@ cartAssocs = new ArrayList(tempList); } } - + if (cartAssocs == null) { cartAssocs = new ArrayList(products.values()); } @@ -139,14 +139,14 @@ } catch (GenericEntityException e) { Debug.logWarning(e, module); } - + if (UtilValidate.isNotEmpty(cartAssocs)) { return cartAssocs; } else { return null; } } - + public static Map getQuickReorderProducts(ServletRequest request) { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); HttpServletRequest httpRequest = (HttpServletRequest) request; @@ -262,7 +262,7 @@ } } //} - + List reorderProds = new ArrayList(products.values()); /* @@ -300,10 +300,10 @@ } catch (GenericEntityException e) { Debug.logWarning(e, module); } - + return results; } - + public static List productOrderByMap(Collection values, Map orderByMap, boolean descending) { if (values == null) return null; if (values.size() == 0) return UtilMisc.toList(values); @@ -350,5 +350,5 @@ return false; } } - } + } } |
Free forum by Nabble | Edit this page |