Author: bibryam
Date: Tue Mar 11 01:37:01 2008 New Revision: 635847 URL: http://svn.apache.org/viewvc?rev=635847&view=rev Log: Applied my patch from JIRA Issue # OFBIZ-1206 "Bugs in availability checking of rental products" Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=635847&r1=635846&r2=635847&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Tue Mar 11 01:37:01 2008 @@ -476,7 +476,17 @@ if (sci.equals(productId, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, features, attributes, prodCatalogId,selectedAmount, configWrapper, itemType, itemGroup, false)) { 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/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=635847&r1=635846&r2=635847&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 Tue Mar 11 01:37:01 2008 @@ -880,9 +880,13 @@ // 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()); @@ -906,13 +910,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 |