Author: bibryam
Date: Tue Mar 11 01:42:20 2008 New Revision: 635850 URL: http://svn.apache.org/viewvc?rev=635850&view=rev Log: Merged by hand from rev. 635847 Modified: ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java Modified: ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=635850&r1=635849&r2=635850&view=diff ============================================================================== --- ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Tue Mar 11 01:42:20 2008 @@ -461,6 +461,18 @@ if (sci.equals(productId, reservStart, reservLength, reservPersons, features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, selectedAmount)) { double newQuantity = sci.getQuantity() + quantity; + if (sci.getItemType().equals("RENTAL_ORDER_ITEM")) { + // check to see if the related fixed asset is available for the new quantity + String isAvailable = ShoppingCartItem.checkAvailability(productId, newQuantity, reservStart, reservLength, this); + if(isAvailable.compareTo("OK") != 0) { + Map messageMap = UtilMisc.toMap("productId", productId, + "availableMessage", isAvailable); + String excMsg = UtilProperties.getMessage(ShoppingCartItem.resource, "item.product_not_available", + messageMap, this.getLocale() ); + Debug.logInfo(excMsg, module); + throw new CartItemModifyException(isAvailable); + } + } if (Debug.verboseOn()) Debug.logVerbose("Found a match for id " + productId + " on line " + i + ", updating quantity to " + newQuantity, module); sci.setQuantity(newQuantity, dispatcher, this); Modified: ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=635850&r1=635849&r2=635850&view=diff ============================================================================== --- ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java (original) +++ ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java Tue Mar 11 01:42:20 2008 @@ -819,12 +819,15 @@ return msg; } //Debug.logInfo("Checking availability for product: " + productId.toString() + " and related FixedAsset: " + fixedAssetProduct.getString("fixedAssetId"),module); - // see if this fixed asset has a calendar, when no create one and attach to fixed asset // DEJ20050725 this isn't being used anywhere, commenting out for now and not assigning from the getRelatedOne: GenericValue techDataCalendar = null; + GenericValue techDataCalendar = null; try { - fixedAsset.getRelatedOne("TechDataCalendar"); + techDataCalendar = fixedAsset.getRelatedOne("TechDataCalendar"); } catch (GenericEntityException e) { + Debug.logWarning(e, module); + } + if(techDataCalendar == null) { // no calendar ok, when not more that total capacity if (fixedAsset.getDouble("productionCapacity").doubleValue() >= quantity) { String msg = UtilProperties.getMessage(resource, "item.availableOk", cart.getLocale()); @@ -848,13 +851,13 @@ techDataCalendarExcDay = delegator.findByPrimaryKey("TechDataCalendarExcDay", UtilMisc.toMap("calendarId", fixedAsset.get("calendarId"), "exceptionDateStartTime", exceptionDateStartTime)); } catch (GenericEntityException e) { - if (fixedAsset.get("productionCapacity") != null) { - //Debug.logInfo(" No exception day record found, available: " + fixedAsset.getString("productionCapacity") + " Requested now: " + quantity, module); - if (fixedAsset.getDouble("productionCapacity").doubleValue() < quantity) - resultMessage = resultMessage.concat(exceptionDateStartTime.toString().substring(0, 10) + ", "); - } + Debug.logWarning(e, module); } - if (techDataCalendarExcDay != null) { + if (techDataCalendarExcDay == null ) { + //Debug.logInfo(" No exception day record found, available: " + fixedAsset.getString("productionCapacity") + " Requested now: " + quantity, module); + if (fixedAsset.get("productionCapacity") != null && fixedAsset.getDouble("productionCapacity").doubleValue() < quantity) + resultMessage = resultMessage.concat(exceptionDateStartTime.toString().substring(0, 10) + ", "); + } else { // see if we can get the number of assets available // first try techDataCalendarExcDay(exceptionCapacity) and then FixedAsset(productionCapacity) // if still zero, do not check availability |
Free forum by Nabble | Edit this page |