Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=757091&r1=757090&r2=757091&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.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 @@ -107,7 +107,7 @@ public static final int taxRounding = UtilNumber.getBigDecimalRoundingMode("salestax.rounding"); public static final int orderDecimals = UtilNumber.getBigDecimalScale("order.decimals"); public static final int orderRounding = UtilNumber.getBigDecimalRoundingMode("order.rounding"); - public static final BigDecimal ZERO = BigDecimal.ZERO.setScale(taxDecimals, taxRounding); + public static final BigDecimal ZERO = BigDecimal.ZERO.setScale(taxDecimals, taxRounding); private static boolean hasPermission(String orderId, GenericValue userLogin, String action, Security security, GenericDelegator delegator) { @@ -386,15 +386,15 @@ errorMessages.add(excMsg); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderCouldNotFindRelatedFixedAssetForTheProduct",UtilMisc.toMap("productId",orderItem.getString("productId")), locale )); } - + if (UtilValidate.isNotEmpty(selFixedAssetProduct)) { Iterator firstOne = selFixedAssetProduct.iterator(); if (firstOne.hasNext()) { GenericValue fixedAssetProduct = delegator.makeValue("FixedAssetProduct"); - fixedAssetProduct = (GenericValue) firstOne.next(); - workEffort.set("fixedAssetId",fixedAssetProduct.get("fixedAssetId")); + fixedAssetProduct = (GenericValue) firstOne.next(); + workEffort.set("fixedAssetId",fixedAssetProduct.get("fixedAssetId")); workEffort.set("quantityToProduce",orderItem.get("quantity")); // have quantity easy available later... - workEffort.set("createdByUserLogin", userLogin.get("userLoginId")); + workEffort.set("createdByUserLogin", userLogin.get("userLoginId")); } } break; // item found, so go to next orderitem. @@ -419,7 +419,7 @@ } else if (billFromVendorPartyId != null) { orgPartyId = billFromVendorPartyId; } - + if (UtilValidate.isNotEmpty(orgPartyId)) { Map getNextOrderIdContext = UtilMisc.toMap("partyId", orgPartyId, "userLogin", userLogin); @@ -446,7 +446,7 @@ // for purchase orders or when other orderId generation fails, a product store id should not be required to make an order orderId = delegator.getNextSeqId("OrderHeader"); } - + String billingAccountId = (String) context.get("billingAccountId"); Timestamp orderDate = (Timestamp) context.get("orderDate"); if (orderDate == null) { @@ -556,7 +556,7 @@ toBeStored.add(orderItemGroup); } } - + // set the order items Iterator oi = orderItems.iterator(); while (oi.hasNext()) { @@ -604,7 +604,7 @@ while (orderInternalNotesIt.hasNext()) { String orderInternalNote = (String) orderInternalNotesIt.next(); try { - Map noteOutputMap = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, + Map noteOutputMap = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "internalNote", "Y", "note", orderInternalNote, "userLogin", userLogin)); @@ -688,7 +688,7 @@ break; } } - } + } if (techDataCalendar == null ) { techDataCalendar = delegator.makeValue("TechDataCalendar"); Debug.logInfo("create techdata calendar because it does not exist",module); @@ -738,7 +738,7 @@ break; } } - } + } if (techDataCalendarExcDay == null) { techDataCalendarExcDay = delegator.makeValue("TechDataCalendarExcDay"); techDataCalendarExcDay.set("calendarId", fixedAsset.get("calendarId")); @@ -1155,7 +1155,7 @@ resErrorMessages.add(componentsRes.get(ModelService.ERROR_MESSAGE)); continue; } else { - List assocProducts = (List) componentsRes.get("assocProducts"); + List assocProducts = (List) componentsRes.get("assocProducts"); Iterator assocProductsIter = assocProducts.iterator(); while (assocProductsIter.hasNext()) { GenericValue productAssoc = (GenericValue) assocProductsIter.next(); @@ -1210,7 +1210,7 @@ // Reserving inventory or not we still need to create a marketing package // If the product is a marketing package auto, attempt to create enough packages to bring ATP back to 0, won't necessarily create enough to cover this order. if ("MARKETING_PKG_AUTO".equals(product.get("productTypeId"))) { - // do something tricky here: run as the "system" user + // do something tricky here: run as the "system" user // that can actually create and run a production run GenericValue permUserLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "system")); Map inputMap = new HashMap(); @@ -1297,13 +1297,13 @@ String errorMessage = UtilProperties.getMessage(resource_error, "OrderErrorCouldNotFindProductStoreWithID", UtilMisc.toMap("productStoreId", productStoreId), (Locale) context.get("locale")) + e.toString(); Debug.logError(e, errorMessage, module); return ServiceUtil.returnError(errorMessage + e.getMessage() + ")."); - } + } showPricesWithVatTax = productStore.getString("showPricesWithVatTax"); } BigDecimal remainingSubTotal = ZERO; if (UtilValidate.isNotEmpty(productStoreId) && "Y".equalsIgnoreCase(showPricesWithVatTax)) { // calculate subTotal as grandTotal + taxes - (returnsTotal + shipping of all items) - remainingSubTotal = updatedTotal.subtract(orh.getOrderReturnedTotal()).subtract(orh.getShippingTotal()); + remainingSubTotal = updatedTotal.subtract(orh.getOrderReturnedTotal()).subtract(orh.getShippingTotal()); } else { // calculate subTotal as grandTotal - returnsTotal - (tax + shipping of items not returned) remainingSubTotal = updatedTotal.subtract(orh.getOrderReturnedTotal()).subtract(orh.getOrderNonReturnedTaxAndShipping()); @@ -1428,7 +1428,7 @@ BigDecimal totalExistingOrderTax = ZERO; Iterator otait = UtilMisc.toIterator(orderTaxAdjustments); while (otait != null && otait.hasNext()) { - GenericValue orderTaxAdjustment = (GenericValue) otait.next(); + GenericValue orderTaxAdjustment = (GenericValue) otait.next(); if ( orderTaxAdjustment.get("amount") != null) { totalExistingOrderTax = totalExistingOrderTax.add(orderTaxAdjustment.getBigDecimal("amount").setScale(taxDecimals, taxRounding)); } @@ -1459,7 +1459,7 @@ // shipping amount BigDecimal orderShipping = OrderReadHelper.calcOrderAdjustments(orderHeaderAdjustments, orderSubTotal, false, false, true); - + //promotions amount BigDecimal orderPromotions = OrderReadHelper.calcOrderPromoAdjustmentsBd(allAdjustments); @@ -1486,7 +1486,7 @@ shippingAddress = (GenericValue) billingAddressList.get(0); } } - + // TODO and NOTE DEJ20070816: this is NOT a good way to determine if this is a face-to-face or immediatelyFulfilled order //this should be made consistent with the CheckOutHelper.makeTaxContext(int shipGroup, GenericValue shipAddress) method if (shippingAddress == null) { @@ -1509,7 +1509,7 @@ if (shippingAddress == null) { continue; } - + // prepare the service context Map serviceContext = UtilMisc.toMap("productStoreId", orh.getProductStoreId(), "itemProductList", products, "itemAmountList", amounts, "itemShippingList", shipAmts, "itemPriceList", itPrices, "orderShippingAmount", orderShipping); @@ -1728,7 +1728,7 @@ } String orderHeaderStatusId = orderHeader.getString("statusId"); - + boolean allCanceled = true; boolean allComplete = true; boolean allApproved = true; @@ -1761,7 +1761,7 @@ newStatus = "ORDER_COMPLETED"; } else if (allApproved) { boolean changeToApprove = true; - + // NOTE DEJ20070805 I'm not sure why we would want to auto-approve the header... adding at least this one exeption so that we don't have to add processing, held, etc statuses to the item status list // NOTE2 related to the above: appears this was a weird way to set the order header status by setting all order item statuses... changing that to be less weird and more direct // this is a bit of a pain: if the current statusId = ProductStore.headerApprovedStatus and we don't have that status in the history then we don't want to change it on approving the items @@ -1787,11 +1787,11 @@ return ServiceUtil.returnError(errMsg); } } - + if ("ORDER_SENT".equals(orderHeaderStatusId)) changeToApprove = false; if ("ORDER_COMPLETED".equals(orderHeaderStatusId)) changeToApprove = false; if ("ORDER_CANCELLED".equals(orderHeaderStatusId)) changeToApprove = false; - + if (changeToApprove) { newStatus = "ORDER_APPROVED"; } @@ -1829,14 +1829,14 @@ String orderItemSeqId = (String) context.get("orderItemSeqId"); String shipGroupSeqId = (String) context.get("shipGroupSeqId"); Map itemReasonMap = (Map) context.get("itemReasonMap"); - Map itemCommentMap = (Map) context.get("itemCommentMap"); + Map itemCommentMap = (Map) context.get("itemCommentMap"); // debugging message info String itemMsgInfo = orderId + " / " + orderItemSeqId + " / " + shipGroupSeqId; // check and make sure we have permission to change the order Security security = ctx.getSecurity(); - + boolean hasPermission = OrderServices.hasPermission(orderId, userLogin, "UPDATE", security, delegator); if (!hasPermission) { return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderYouDoNotHavePermissionToChangeThisOrdersStatus",locale)); @@ -1878,7 +1878,7 @@ aisgaCancelQuantity = BigDecimal.ZERO; } BigDecimal availableQuantity = orderItemShipGroupAssoc.getBigDecimal("quantity").subtract(aisgaCancelQuantity); - + BigDecimal itemCancelQuantity = orderItem.getBigDecimal("cancelQuantity"); if (itemCancelQuantity == null) { itemCancelQuantity = BigDecimal.ZERO; @@ -1908,7 +1908,7 @@ Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderUnableToSetCancelQuantity", UtilMisc.toMap("itemMsgInfo",itemMsgInfo), locale)); } - + // create order item change record if (!"Y".equals(orderItem.getString("isPromo"))) { String reasonEnumId = null; @@ -1919,14 +1919,14 @@ if (UtilValidate.isNotEmpty(itemCommentMap)) { changeComments = (String) itemCommentMap.get(orderItem.getString("orderItemSeqId")); } - + Map serviceCtx = FastMap.newInstance(); serviceCtx.put("orderId", orderItem.getString("orderId")); serviceCtx.put("orderItemSeqId", orderItem.getString("orderItemSeqId")); serviceCtx.put("cancelQuantity", thisCancelQty); serviceCtx.put("changeTypeEnumId", "ODR_ITM_CANCEL"); serviceCtx.put("reasonEnumId", reasonEnumId); - serviceCtx.put("changeComments", changeComments); + serviceCtx.put("changeComments", changeComments); serviceCtx.put("userLogin", userLogin); Map resp = null; try { @@ -1938,7 +1938,7 @@ if (ServiceUtil.isError(resp)) { return ServiceUtil.returnError((String)resp.get(ModelService.ERROR_MESSAGE)); } - } + } if (thisCancelQty.compareTo(itemQuantity) >= 0) { // all items are cancelled -- mark the item as cancelled @@ -2078,7 +2078,7 @@ if (!hasPermission) { return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderYouDoNotHavePermissionToChangeThisOrdersStatus",locale)); } - + if ("Y".equals(context.get("setItemStatus"))) { String newItemStatusId = null; if ("ORDER_APPROVED".equals(statusId)) { @@ -2088,7 +2088,7 @@ } else if ("ORDER_CANCELLED".equals(statusId)) { newItemStatusId = "ITEM_CANCELLED"; } - + if (newItemStatusId != null) { try { Map resp = dispatcher.runSync("changeOrderItemStatus", UtilMisc.<String, Object>toMap("orderId", orderId, "statusId", newItemStatusId, "userLogin", userLogin)); @@ -2296,23 +2296,23 @@ public static Map sendOrderPayRetryNotification(DispatchContext ctx, Map context) { return sendOrderNotificationScreen(ctx, context, "PRDS_ODR_PAYRETRY"); } - + protected static Map sendOrderNotificationScreen(DispatchContext dctx, Map context, String emailType) { LocalDispatcher dispatcher = dctx.getDispatcher(); GenericDelegator delegator = dctx.getDelegator(); GenericValue userLogin = (GenericValue) context.get("userLogin"); - String orderId = (String) context.get("orderId"); + String orderId = (String) context.get("orderId"); String orderItemSeqId = (String) context.get("orderItemSeqId"); String sendTo = (String) context.get("sendTo"); String sendCc = (String) context.get("sendCc"); String note = (String) context.get("note"); - String screenUri = (String) context.get("screenUri"); + String screenUri = (String) context.get("screenUri"); GenericValue temporaryAnonymousUserLogin = (GenericValue) context.get("temporaryAnonymousUserLogin"); if (userLogin == null) { // this may happen during anonymous checkout, try to the special case user userLogin = temporaryAnonymousUserLogin; } - + // prepare the order information Map sendMap = FastMap.newInstance(); @@ -2379,7 +2379,7 @@ if (placingUserLogin == null) { placingUserLogin = temporaryAnonymousUserLogin; } - + GenericValue productStore = OrderReadHelper.getProductStoreFromOrder(orderHeader); if (locale == null && productStore != null) { String localeString = productStore.getString("defaultLocaleString"); @@ -2477,7 +2477,7 @@ Map templateData = new HashMap(context); templateData.putAll(orderHeader); templateData.putAll(workEffort); - + /* NOTE DEJ20080609 commenting out this code because the old OFBiz Workflow Engine is being deprecated and this was only for that String omgStatusId = WfUtil.getOMGStatus(workEffort.getString("currentStatusId")); templateData.put("omgStatusId", omgStatusId); @@ -2707,7 +2707,7 @@ Debug.logError(se, module); return ServiceUtil.returnError("Problem associating note with order (" + se.getMessage() + ")"); } - + return ServiceUtil.returnSuccess(); } @@ -2844,7 +2844,7 @@ itemsExprs.add(EntityCondition.makeCondition("dontCancelSetUserLogin", EntityOperator.EQUALS, GenericEntity.NULL_FIELD)); itemsExprs.add(EntityCondition.makeCondition("dontCancelSetDate", EntityOperator.EQUALS, GenericEntity.NULL_FIELD)); itemsExprs.add(EntityCondition.makeCondition("autoCancelDate", EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD)); - + ecl = EntityCondition.makeCondition(itemsExprs); List orderItems = null; @@ -3083,7 +3083,7 @@ } List allProductContent = product.getRelated("ProductContent"); - + // try looking up the parent product if the product has no content and is a variant if (((allProductContent == null) || allProductContent.size() == 0) && ("Y".equals(product.getString("isVariant")))) { GenericValue parentProduct = ProductWorker.getParentProduct(product.getString("productId"), delegator); @@ -3094,7 +3094,7 @@ allProductContent.addAll(parentProduct.getRelated("ProductContent")); } } - + if (UtilValidate.isNotEmpty(allProductContent)) { // only keep ones with valid dates productContent = EntityUtil.filterByDate(allProductContent, UtilDateTime.nowTimestamp(), "fromDate", "thruDate", true); @@ -3158,7 +3158,7 @@ } return ServiceUtil.returnSuccess(); } - + /** Service to invoice service items from order*/ public static Map invoiceServiceItems(DispatchContext dctx, Map context) { GenericDelegator delegator = dctx.getDelegator(); @@ -3255,7 +3255,7 @@ productType = product.getRelatedOne("ProductType"); } catch (GenericEntityException e) { Debug.logError(e, "ERROR: Unable to get ProductType from Product", module); - } + } if (item != null && productType != null) { String productTypeId = productType.getString("productTypeId"); if (productTypeId != null && "SERVICE".equalsIgnoreCase(productTypeId)) { @@ -3298,7 +3298,7 @@ String overridePrice = (String) context.get("overridePrice"); Map itemAttributesMap = (Map) context.get("itemAttributesMap"); String reasonEnumId = (String) context.get("reasonEnumId"); - String changeComments = (String) context.get("changeComments"); + String changeComments = (String) context.get("changeComments"); if (amount == null) { amount = BigDecimal.ZERO; @@ -3351,7 +3351,7 @@ return ServiceUtil.returnError(e.getMessage()); } - Map changeMap = UtilMisc.toMap("itemReasonMap", UtilMisc.toMap("reasonEnumId", reasonEnumId), + Map changeMap = UtilMisc.toMap("itemReasonMap", UtilMisc.toMap("reasonEnumId", reasonEnumId), "itemCommentMap", UtilMisc.toMap("changeComments", changeComments)); // save all the updated information try { @@ -3390,7 +3390,7 @@ Map itemAttributesMap = (Map) context.get("itemAttributesMap"); Map<String,String> itemEstimatedShipDateMap = (Map) context.get("itemShipDateMap"); Map<String, String> itemEstimatedDeliveryDateMap = (Map) context.get("itemDeliveryDateMap"); - + // obtain a shopping cart object for updating ShoppingCart cart = null; try { @@ -3499,7 +3499,7 @@ Debug.logInfo("Unable to locate shopping cart item for seqId #" + itemSeqId, module); } } - // Create Estimated Delivery dates + // Create Estimated Delivery dates for (Map.Entry<String, String> entry : itemEstimatedDeliveryDateMap.entrySet()) { String itemSeqId = entry.getKey(); String estimatedDeliveryDate = entry.getValue(); @@ -3509,7 +3509,7 @@ cartItem.setDesiredDeliveryDate(deliveryDate); } } - + // Create Estimated ship dates for (Map.Entry<String, String> entry : itemEstimatedShipDateMap.entrySet()) { String itemSeqId = entry.getKey(); @@ -3519,9 +3519,9 @@ ShoppingCartItem cartItem = cart.findCartItem(itemSeqId); cartItem.setEstimatedShipDate(shipDate); } - + } - + // update the group amounts Iterator gai = itemQtyMap.keySet().iterator(); while (gai.hasNext()) { @@ -3556,7 +3556,7 @@ // run promotions to handle all changes in the cart ProductPromoWorker.doPromotions(cart, dispatcher); - + // save all the updated information try { saveUpdatedCartToOrder(dispatcher, delegator, cart, locale, userLogin, orderId, UtilMisc.toMap("itemReasonMap", itemReasonMap, "itemCommentMap", itemCommentMap)); @@ -3576,25 +3576,25 @@ result.put("orderId", orderId); return result; } - + public static Map loadCartForUpdate(DispatchContext dctx, Map context) { LocalDispatcher dispatcher = dctx.getDispatcher(); GenericDelegator delegator = dctx.getDelegator(); String orderId = (String) context.get("orderId"); GenericValue userLogin = (GenericValue) context.get("userLogin"); - + ShoppingCart cart = null; Map result = null; try { - cart = loadCartForUpdate(dispatcher, delegator, userLogin, orderId); + cart = loadCartForUpdate(dispatcher, delegator, userLogin, orderId); result = ServiceUtil.returnSuccess(); result.put("shoppingCart", cart); } catch (GeneralException e) { Debug.logError(e, module); result = ServiceUtil.returnError(e.getMessage()); - } - + } + result.put("orderId", orderId); return result; } @@ -3630,7 +3630,7 @@ cart.setOrderId(orderId); } - // Now that the cart is loaded, all the data that will be re-created + // Now that the cart is loaded, all the data that will be re-created // when the method saveUpdatedCartToOrder(...) will be called, are // removed and cancelled: // - inventory reservations are cancelled @@ -3638,7 +3638,7 @@ // - order payments are released (cancelled) // - offline non received payments are cancelled // - promotional, shipping and tax adjustments are removed - + // Inventory reservations // find ship group associations List shipGroupAssocs = null; @@ -3766,7 +3766,7 @@ } public static Map saveUpdatedCartToOrder(DispatchContext dctx, Map context) throws GeneralException { - + LocalDispatcher dispatcher = dctx.getDispatcher(); GenericDelegator delegator = dctx.getDelegator(); @@ -3775,7 +3775,7 @@ ShoppingCart cart = (ShoppingCart) context.get("shoppingCart"); Map changeMap = (Map) context.get("changeMap"); Locale locale = (Locale) context.get("locale"); - + Map result = null; try { saveUpdatedCartToOrder(dispatcher, delegator, cart, locale, userLogin, orderId, changeMap); @@ -3784,8 +3784,8 @@ } catch (GeneralException e) { Debug.logError(e, module); result = ServiceUtil.returnError(e.getMessage()); - } - + } + result.put("orderId", orderId); return result; } @@ -3809,7 +3809,7 @@ } cart.setItemShipGroupEstimate(shippingTotal, gi); } - + // calc the sales tax CheckOutHelper coh = new CheckOutHelper(dispatcher, delegator, cart); try { @@ -3826,7 +3826,7 @@ } // get the new orderItems, adjustments, shipping info, payments and order item atrributes from the cart - List<Map> modifiedItems = FastList.newInstance(); + List<Map> modifiedItems = FastList.newInstance(); List toStore = new LinkedList(); toStore.addAll(cart.makeOrderItems()); toStore.addAll(cart.makeAllAdjustments()); @@ -3870,7 +3870,7 @@ valueObj.set("statusId", "PAYMENT_NOT_RECEIVED"); } } else if ("OrderItem".equals(valueObj.getEntityName())) { - + // ignore promotion items. They are added/canceled automatically if ("Y".equals(valueObj.getString("isPromo"))) { continue; @@ -3883,19 +3883,19 @@ throw new GeneralException(e.getMessage()); } if (UtilValidate.isNotEmpty(oldOrderItem)) { - + // Existing order item found. Check for modifications and store if any String oldItemDescription = oldOrderItem.getString("itemDescription") != null ? oldOrderItem.getString("itemDescription") : ""; BigDecimal oldQuantity = oldOrderItem.getBigDecimal("quantity") != null ? oldOrderItem.getBigDecimal("quantity") : BigDecimal.ZERO; BigDecimal oldUnitPrice = oldOrderItem.getBigDecimal("unitPrice") != null ? oldOrderItem.getBigDecimal("unitPrice") : BigDecimal.ZERO; - + boolean changeFound = false; Map modifiedItem = FastMap.newInstance(); if (!oldItemDescription.equals(valueObj.getString("itemDescription"))) { modifiedItem.put("itemDescription", oldItemDescription); changeFound = true; } - + BigDecimal quantityDif = valueObj.getBigDecimal("quantity").subtract(oldQuantity); BigDecimal unitPriceDif = valueObj.getBigDecimal("unitPrice").subtract(oldUnitPrice); if (quantityDif.compareTo(BigDecimal.ZERO) != 0) { @@ -3907,7 +3907,7 @@ changeFound = true; } if (changeFound) { - + // found changes to store Map itemReasonMap = (Map) changeMap.get("itemReasonMap"); Map itemCommentMap = (Map) changeMap.get("itemCommentMap"); @@ -3919,14 +3919,14 @@ String changeComments = (String) itemCommentMap.get(valueObj.getString("orderItemSeqId")); modifiedItem.put("changeComments", changeComments); } - + modifiedItem.put("orderId", valueObj.getString("orderId")); - modifiedItem.put("orderItemSeqId", valueObj.getString("orderItemSeqId")); - modifiedItem.put("changeTypeEnumId", "ODR_ITM_UPDATE"); + modifiedItem.put("orderItemSeqId", valueObj.getString("orderItemSeqId")); + modifiedItem.put("changeTypeEnumId", "ODR_ITM_UPDATE"); modifiedItems.add(modifiedItem); - } + } } else { - + // this is a new item appended to the order Map itemReasonMap = (Map) changeMap.get("itemReasonMap"); Map itemCommentMap = (Map) changeMap.get("itemCommentMap"); @@ -3942,11 +3942,11 @@ appendedItem.put("orderId", valueObj.getString("orderId")); appendedItem.put("orderItemSeqId", valueObj.getString("orderItemSeqId")); - appendedItem.put("quantity", valueObj.getBigDecimal("quantity")); - appendedItem.put("changeTypeEnumId", "ODR_ITM_APPEND"); + appendedItem.put("quantity", valueObj.getBigDecimal("quantity")); + appendedItem.put("changeTypeEnumId", "ODR_ITM_APPEND"); modifiedItems.add(appendedItem); } - } + } } Debug.log("To Store Contains: " + toStore, module); @@ -3967,7 +3967,7 @@ } // store the OrderItemChange - if (UtilValidate.isNotEmpty(modifiedItems)) { + if (UtilValidate.isNotEmpty(modifiedItems)) { for (Map modifiendItem: modifiedItems) { Map serviceCtx = FastMap.newInstance(); serviceCtx.put("orderId", modifiendItem.get("orderId")); @@ -3977,7 +3977,7 @@ serviceCtx.put("unitPrice", modifiendItem.get("unitPrice")); serviceCtx.put("changeTypeEnumId", modifiendItem.get("changeTypeEnumId")); serviceCtx.put("reasonEnumId", modifiendItem.get("reasonEnumId")); - serviceCtx.put("changeComments", modifiendItem.get("changeComments")); + serviceCtx.put("changeComments", modifiendItem.get("changeComments")); serviceCtx.put("userLogin", userLogin); Map resp = null; try { @@ -3991,7 +3991,7 @@ } } } - + // make the order item object map & the ship group assoc list List orderItemShipGroupAssoc = new LinkedList(); Map itemValuesBySeqId = new HashMap(); @@ -4122,13 +4122,13 @@ return ServiceUtil.returnError("Failed to create Payment: Cannot get the ProductStore for the order header"); } - // get the partyId billed to + // get the partyId billed to OrderReadHelper orh = new OrderReadHelper(orderHeader); GenericValue billToParty = orh.getBillToParty(); if (billToParty == null) { return ServiceUtil.returnError("Failed to create Payment: cannot find the bill to customer party"); } - + // set the payToPartyId String payToPartyId = productStore.getString("payToPartyId"); if (payToPartyId == null) { @@ -4138,7 +4138,7 @@ // create the payment Map paymentParams = new HashMap(); BigDecimal maxAmount = orderPaymentPreference.getBigDecimal("maxAmount"); - //if (maxAmount > 0.0) { + //if (maxAmount > 0.0) { paymentParams.put("paymentTypeId", "CUSTOMER_PAYMENT"); paymentParams.put("paymentMethodTypeId", orderPaymentPreference.getString("paymentMethodTypeId")); paymentParams.put("paymentPreferenceId", orderPaymentPreference.getString("orderPaymentPreferenceId")); @@ -4185,7 +4185,7 @@ } public static Map massChangeApproved(DispatchContext dctx, Map context) { - return massChangeItemStatus(dctx, context, "ITEM_APPROVED"); + return massChangeItemStatus(dctx, context, "ITEM_APPROVED"); } public static Map massCancelOrders(DispatchContext dctx, Map context) { @@ -4473,14 +4473,14 @@ CheckOutHelper coh = new CheckOutHelper(dispatcher, delegator, cart); Map resultOrderMap = coh.createOrder(userLogin); String purchaseOrderId = (String)resultOrderMap.get("orderId"); - + // TODO: associate the new purchase order with the sales order (ship group) } else { // if there are no items to drop ship, then clear out the supplier partyId Debug.logWarning("No drop ship items found for order [" + shipGroup.getString("orderId") + "] and ship group [" + shipGroup.getString("shipGroupSeqId") + "] and supplier party [" + shipGroup.getString("supplierPartyId") + "]. Supplier party information will be cleared for this ship group", module); shipGroup.set("supplierPartyId", null); shipGroup.store(); - + } } } @@ -4489,7 +4489,7 @@ // TODO: imporve error handling ServiceUtil.returnError("The following error occurred creating drop shipments for order [" + orderId + "]: " + exc.getMessage()); } - + return ServiceUtil.returnSuccess(); } @@ -4530,7 +4530,7 @@ opp.store(); results.put("orderPaymentPreferenceId", opp.get("orderPaymentPreferenceId")); } else { - GenericValue newOpp = (GenericValue) opp.clone(); + GenericValue newOpp = (GenericValue) opp.clone(); opp.set("statusId", "PAYMENT_CANCELLED"); opp.store(); @@ -4560,26 +4560,26 @@ LocalDispatcher dispatcher = dctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Locale locale = (Locale) context.get("locale"); - + String orderId = (String) context.get("orderId"); String facilityId = (String) context.get("facilityId"); try { GenericValue orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId)); - + if (UtilValidate.isEmpty(orderHeader)) { String errorMessage = UtilProperties.getMessage(resource_error, "OrderErrorOrderIdNotFound", UtilMisc.toMap("orderId", orderId), locale); Debug.logError(errorMessage, module); return ServiceUtil.returnError(errorMessage); } - + if (! "PURCHASE_ORDER".equals(orderHeader.getString("orderTypeId"))) { String errorMessage = UtilProperties.getMessage(resource_error, "ProductErrorOrderNotPurchaseOrder", UtilMisc.toMap("orderId", orderId), locale); Debug.logError(errorMessage, module); return ServiceUtil.returnError(errorMessage); } - + // Build a map of productId -> quantity cancelled over all order items Map productRequirementQuantities = new HashMap(); List orderItems = orderHeader.getRelated("OrderItem"); @@ -4587,7 +4587,7 @@ while (oiit.hasNext()) { GenericValue orderItem = (GenericValue) oiit.next(); if (! "PRODUCT_ORDER_ITEM".equals(orderItem.getString("orderItemTypeId"))) continue; - + // Get the cancelled quantity for the item BigDecimal orderItemCancelQuantity = BigDecimal.ZERO; if (! UtilValidate.isEmpty(orderItem.get("cancelQuantity")) ) { @@ -4595,13 +4595,13 @@ } if (orderItemCancelQuantity.compareTo(BigDecimal.ZERO) <= 0) continue; - + String productId = orderItem.getString("productId"); if (productRequirementQuantities.containsKey(productId)) { - orderItemCancelQuantity = orderItemCancelQuantity.add((BigDecimal) productRequirementQuantities.get(productId)); + orderItemCancelQuantity = orderItemCancelQuantity.add((BigDecimal) productRequirementQuantities.get(productId)); } productRequirementQuantities.put(productId, orderItemCancelQuantity); - + } // Generate requirements for each of the product quantities @@ -4610,9 +4610,9 @@ String productId = (String) cqit.next(); BigDecimal requiredQuantity = (BigDecimal) productRequirementQuantities.get(productId); Map createRequirementResult = dispatcher.runSync("createRequirement", UtilMisc.<String, Object>toMap("requirementTypeId", "PRODUCT_REQUIREMENT", "facilityId", facilityId, "productId", productId, "quantity", requiredQuantity, "userLogin", userLogin)); - if (ServiceUtil.isError(createRequirementResult)) return createRequirementResult; + if (ServiceUtil.isError(createRequirementResult)) return createRequirementResult; } - + } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -4635,31 +4635,31 @@ LocalDispatcher dispatcher = dctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Locale locale = (Locale) context.get("locale"); - + String orderId = (String) context.get("orderId"); try { GenericValue orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId)); - + if (UtilValidate.isEmpty(orderHeader)) { String errorMessage = UtilProperties.getMessage(resource_error, "OrderErrorOrderIdNotFound", UtilMisc.toMap("orderId", orderId), locale); Debug.logError(errorMessage, module); return ServiceUtil.returnError(errorMessage); } - + if (! "PURCHASE_ORDER".equals(orderHeader.getString("orderTypeId"))) { String errorMessage = UtilProperties.getMessage(resource_error, "OrderErrorOrderNotPurchaseOrder", UtilMisc.toMap("orderId", orderId), locale); Debug.logError(errorMessage, module); return ServiceUtil.returnError(errorMessage); } - + List orderItems = orderHeader.getRelated("OrderItem"); Iterator oiit = orderItems.iterator(); while (oiit.hasNext()) { GenericValue orderItem = (GenericValue) oiit.next(); if (! "PRODUCT_ORDER_ITEM".equals(orderItem.getString("orderItemTypeId"))) continue; - + // Get the ordered quantity for the item BigDecimal orderItemQuantity = BigDecimal.ZERO; if (! UtilValidate.isEmpty(orderItem.get("quantity"))) { @@ -4680,18 +4680,18 @@ receivedQuantity = receivedQuantity.add(shipmentReceipt.getBigDecimal("quantityAccepted")); } } - + BigDecimal quantityToCancel = orderItemQuantity.subtract(orderItemCancelQuantity).subtract(receivedQuantity); if (quantityToCancel.compareTo(BigDecimal.ZERO) > 0) { Map cancelOrderItemResult = dispatcher.runSync("cancelOrderItem", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "cancelQuantity", quantityToCancel, "userLogin", userLogin)); - if (ServiceUtil.isError(cancelOrderItemResult)) return cancelOrderItemResult; + if (ServiceUtil.isError(cancelOrderItemResult)) return cancelOrderItemResult; } // If there's nothing to cancel, the item should be set to completed, if it isn't already orderItem.refresh(); if ("ITEM_APPROVED".equals(orderItem.getString("statusId"))) { Map changeOrderItemStatusResult = dispatcher.runSync("changeOrderItemStatus", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "statusId", "ITEM_COMPLETED", "userLogin", userLogin)); - if (ServiceUtil.isError(changeOrderItemStatusResult)) return changeOrderItemStatusResult; + if (ServiceUtil.isError(changeOrderItemStatusResult)) return changeOrderItemStatusResult; } } @@ -4715,7 +4715,7 @@ Locale locale = (Locale) context.get("locale"); String paymentMethodId = (String) context.get("paymentMethodId"); - String productStoreId = (String) context.get("productStoreId"); + String productStoreId = (String) context.get("productStoreId"); String currency = (String) context.get("currency"); String partyId = (String) context.get("partyId"); Map itemMap = (Map) context.get("itemMap"); @@ -4850,7 +4850,7 @@ /** * Determines the total amount invoiced for a given order item over all invoices by totalling the item subtotal (via OrderItemBilling), - * any adjustments for that item (via OrderAdjustmentBilling), and the item's share of any order-level adjustments (that calculated + * any adjustments for that item (via OrderAdjustmentBilling), and the item's share of any order-level adjustments (that calculated * by applying the percentage of the items total that the item represents to the order-level adjustments total (also via * OrderAdjustmentBilling). Also returns the quantity invoiced for the item over all invoices, to aid in prorating. * @param dctx DispatchContext @@ -4860,7 +4860,7 @@ public static Map getOrderItemInvoicedAmountAndQuantity(DispatchContext dctx, Map context) { GenericDelegator delegator = dctx.getDelegator(); Locale locale = (Locale) context.get("locale"); - + String orderId = (String) context.get("orderId"); String orderItemSeqId = (String) context.get("orderItemSeqId"); @@ -4882,7 +4882,7 @@ Debug.logError(errorMessage, module); return ServiceUtil.returnError(errorMessage); } - + BigDecimal orderItemsSubtotal = ZERO; // Aggregated value of order items, non-tax and non-shipping item-level adjustments BigDecimal invoicedTotal = ZERO; // Amount invoiced for the target order item BigDecimal itemAdjustments = ZERO; // Item-level tax- and shipping-adjustments @@ -4892,7 +4892,7 @@ Iterator oit = orderItems.iterator(); while (oit.hasNext()) { GenericValue orderItem = (GenericValue) oit.next(); - + // Look at the orderItemBillings to discover the amount and quantity ever invoiced for this order item List orderItemBillings = delegator.findByAnd("OrderItemBilling", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"))); Iterator oibit = orderItemBillings.iterator(); @@ -4904,7 +4904,7 @@ // Add the item base amount to the subtotal orderItemsSubtotal = orderItemsSubtotal.add(quantity.multiply(amount)); - + // If the item is the target order item, add the invoiced quantity and amount to their respective totals if (orderItemSeqId.equals(orderItem.get("orderItemSeqId"))) { invoicedQuantity = invoicedQuantity.add(quantity); @@ -4918,7 +4918,7 @@ while (oait.hasNext()) { GenericValue orderAdjustment = (GenericValue) oait.next(); String orderAdjustmentTypeId = orderAdjustment.getString("orderAdjustmentTypeId"); - + // Look at the orderAdjustmentBillings to discove the amount ever invoiced for this order adjustment List orderAdjustmentBillings = delegator.findByAnd("OrderAdjustmentBilling", UtilMisc.toMap("orderAdjustmentId", orderAdjustment.get("orderAdjustmentId"))); Iterator oabit = orderAdjustmentBillings.iterator(); @@ -4926,19 +4926,19 @@ GenericValue orderAjustmentBilling = (GenericValue) oabit.next(); BigDecimal amount = orderAjustmentBilling.getBigDecimal("amount").setScale(orderDecimals, orderRounding); if (UtilValidate.isEmpty(amount)) continue; - + if ("SALES_TAX".equals(orderAdjustmentTypeId) || "SHIPPING_CHARGES".equals(orderAdjustmentTypeId)) { if (orderItemSeqId.equals(orderItem.get("orderItemSeqId"))) { - + // Add tax- and shipping-adjustment amounts to the total adjustments for the target order item itemAdjustments = itemAdjustments.add(amount); } } else { - // Add non-tax and non-shipping adjustment amounts to the order items subtotal + // Add non-tax and non-shipping adjustment amounts to the order items subtotal orderItemsSubtotal = orderItemsSubtotal.add(amount); if (orderItemSeqId.equals(orderItem.get("orderItemSeqId"))) { - + // If the item is the target order item, add non-tax and non-shipping adjustment amounts to the invoiced total invoicedTotal = invoicedTotal.add(amount); } @@ -4986,7 +4986,7 @@ result.put("invoicedQuantity", invoicedQuantity.setScale(orderDecimals, orderRounding)); return result; } - + public static Map setOrderPaymentStatus(DispatchContext ctx, Map context) { LocalDispatcher dispatcher = ctx.getDispatcher(); GenericDelegator delegator = ctx.getDelegator(); @@ -4998,7 +4998,7 @@ try { GenericValue orderPaymentPreference = delegator.findByPrimaryKey("OrderPaymentPreference", UtilMisc.toMap("orderPaymentPreferenceId", orderPaymentPreferenceId)); String orderId = orderPaymentPreference.getString("orderId"); - String statusUserLogin = orderPaymentPreference.getString("createdByUserLogin"); + String statusUserLogin = orderPaymentPreference.getString("createdByUserLogin"); GenericValue orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId)); if (orderHeader == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderErrorCouldNotChangeOrderStatusOrderCannotBeFound", locale)); @@ -5031,18 +5031,18 @@ Locale locale = (Locale) context.get("locale"); int count = 0; Map result = null; - + boolean beganTransaction = false; try { beganTransaction = TransactionUtil.begin(); - + List exprs = UtilMisc.toList(EntityCondition.makeCondition("automaticExtend", EntityOperator.EQUALS, "Y"), EntityCondition.makeCondition("orderId", EntityOperator.NOT_EQUAL, null), EntityCondition.makeCondition("productId", EntityOperator.NOT_EQUAL, null)); EntityCondition cond = EntityCondition.makeCondition(exprs, EntityOperator.AND); EntityListIterator eli = null; eli = delegator.find("Subscription", cond, null, null, null, null); - + if (eli != null) { GenericValue subscription; while (((subscription = (GenericValue) eli.next()) != null)) { @@ -5053,31 +5053,31 @@ int field = Calendar.MONTH; if (subscription.get("canclAutmExtTime") != null && subscription.get("canclAutmExtTimeUomId") != null) { if ("TF_day".equals(subscription.getString("canclAutmExtTimeUomId"))) { - field = Calendar.DAY_OF_YEAR; + field = Calendar.DAY_OF_YEAR; } else if ("TF_wk".equals(subscription.getString("canclAutmExtTimeUomId"))) { - field = Calendar.WEEK_OF_YEAR; + field = Calendar.WEEK_OF_YEAR; } else if ("TF_mon".equals(subscription.getString("canclAutmExtTimeUomId"))) { - field = Calendar.MONTH; + field = Calendar.MONTH; } else if ("TF_yr".equals(subscription.getString("canclAutmExtTimeUomId"))) { - field = Calendar.YEAR; + field = Calendar.YEAR; } else { Debug.logWarning("Don't know anything about useTimeUomId [" + subscription.getString("canclAutmExtTimeUomId") + "], defaulting to month", module); } endDate.add(field, new Integer(subscription.getString("canclAutmExtTime")).intValue()); } - + Calendar endDateSubscription = Calendar.getInstance(); endDateSubscription.setTime(subscription.getTimestamp("thruDate")); - + if (endDate.before(endDateSubscription)) { // nor expired yet..... continue; } - + result = dispatcher.runSync("loadCartFromOrder", UtilMisc.toMap("orderId", subscription.get("orderId"), "userLogin", userLogin)); ShoppingCart cart = (ShoppingCart) result.get("shoppingCart"); - + // only keep the orderitem with the related product. List cartItems = cart.items(); Iterator ci = cartItems.iterator(); @@ -5087,16 +5087,16 @@ cart.removeCartItem(shoppingCartItem, dispatcher); } } - + CheckOutHelper helper = new CheckOutHelper(dispatcher, delegator, cart); - + // store the order Map createResp = helper.createOrder(userLogin); if (createResp != null && ServiceUtil.isError(createResp)) { Debug.logError("Cannot create order for shopping list - " + subscription, module); } else { String orderId = (String) createResp.get("orderId"); - + // authorize the payments Map payRes = null; try { @@ -5104,15 +5104,15 @@ } catch (GeneralException e) { Debug.logError(e, module); } - + if (payRes != null && ServiceUtil.isError(payRes)) { Debug.logError("Payment processing problems with shopping list - " + subscription, module); } - + // remove the automatic extension flag subscription.put("automaticExtend", "N"); subscription.store(); - + // send notification dispatcher.runAsync("sendOrderPayRetryNotification", UtilMisc.toMap("orderId", orderId)); count++; @@ -5120,7 +5120,7 @@ } eli.close(); } - + } catch (GenericServiceException e) { Debug.logError("Could call service to create cart", module); return ServiceUtil.returnError(e.toString()); Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/quote/QuoteServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/quote/QuoteServices.java?rev=757091&r1=757090&r2=757091&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/quote/QuoteServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/quote/QuoteServices.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 @@ -132,7 +132,7 @@ public static Map storeQuote(DispatchContext dctx, Map context) { LocalDispatcher dispatcher = dctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); - + String quoteTypeId = (String) context.get("quoteTypeId"); String partyId = (String) context.get("partyId"); Timestamp issueDate = (Timestamp) context.get("issueDate"); @@ -151,7 +151,7 @@ List quoteTerms = (List) context.get("quoteTerms"); List quoteTermAttributes = (List) context.get("quoteTermAttributes"); List quoteWorkEfforts = (List) context.get("quoteWorkEfforts"); - List quoteAdjustments = (List) context.get("quoteAdjustments"); + List quoteAdjustments = (List) context.get("quoteAdjustments"); Map result = FastMap.newInstance(); @@ -167,15 +167,15 @@ if (userLogin != null) { quoteIn.put("userLogin", userLogin); } - - + + // create Quote Map quoteOut = dispatcher.runSync("createQuote", quoteIn); - + if (UtilValidate.isNotEmpty(quoteOut) && UtilValidate.isNotEmpty(quoteOut.get("quoteId"))) { String quoteId = (String)quoteOut.get("quoteId"); result.put("quoteId", quoteId); - + // create Quote Items if (UtilValidate.isNotEmpty(quoteItems)) { Iterator quoteIt = quoteItems.iterator(); @@ -184,11 +184,11 @@ quoteItem.set("quoteId", quoteId); Map quoteItemIn = quoteItem.getAllFields(); quoteItemIn.put("userLogin", userLogin); - + dispatcher.runSync("createQuoteItem", quoteItemIn); } } - + // create Quote Attributes if (UtilValidate.isNotEmpty(quoteAttributes)) { Iterator quoteAttrIt = quoteAttributes.iterator(); @@ -197,11 +197,11 @@ quoteAttr.set("quoteId", quoteId); Map quoteAttrIn = quoteAttr.getAllFields(); quoteAttrIn.put("userLogin", userLogin); - + dispatcher.runSync("createQuoteAttribute", quoteAttrIn); } } - + // create Quote Coefficients if (UtilValidate.isNotEmpty(quoteCoefficients)) { Iterator quoteCoefficientIt = quoteCoefficients.iterator(); @@ -210,11 +210,11 @@ quoteCoefficient.set("quoteId", quoteId); Map quoteCoefficientIn = quoteCoefficient.getAllFields(); quoteCoefficientIn.put("userLogin", userLogin); - + dispatcher.runSync("createQuoteCoefficient", quoteCoefficientIn); } } - + // create Quote Roles if (UtilValidate.isNotEmpty(quoteRoles)) { Iterator quoteRoleIt = quoteRoles.iterator(); @@ -223,7 +223,7 @@ quoteRole.set("quoteId", quoteId); Map quoteRoleIn = quoteRole.getAllFields(); quoteRoleIn.put("userLogin", userLogin); - + dispatcher.runSync("createQuoteRole", quoteRoleIn); } } @@ -236,11 +236,11 @@ quoteWorkEffort.set("quoteId", quoteId); Map quoteWorkEffortIn = quoteWorkEffort.getAllFields(); quoteWorkEffortIn.put("userLogin", userLogin); - + dispatcher.runSync("createQuoteWorkEffort", quoteWorkEffortIn); } } - + // create Quote Adjustments if (UtilValidate.isNotEmpty(quoteAdjustments)) { Iterator quoteAdjustmentIt = quoteAdjustments.iterator(); @@ -249,11 +249,11 @@ quoteAdjustment.set("quoteId", quoteId); Map quoteAdjustmentIn = quoteAdjustment.getAllFields(); quoteAdjustmentIn.put("userLogin", userLogin); - + dispatcher.runSync("createQuoteAdjustment", quoteAdjustmentIn); } } - + //TODO create Quote Terms still to be implemented the base service createQuoteTerm //TODO create Quote Term Attributes still to be implemented the base service createQuoteTermAttribute } else { Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java?rev=757091&r1=757090&r2=757091&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.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 @@ -77,7 +77,7 @@ } else { conditions.add( EntityCondition.makeCondition("roleTypeId", EntityOperator.EQUALS, "SUPPLIER") ); } - + EntityConditionList<EntityCondition> ecl = EntityCondition.makeCondition(conditions, EntityOperator.AND); List requirementAndRoles = delegator.findList("RequirementAndRole", ecl, null, orderBy, null, false); Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java?rev=757091&r1=757090&r2=757091&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.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 @@ -48,13 +48,13 @@ } public void sessionDestroyed(HttpSessionEvent event) { - HttpSession session = event.getSession(); - ShoppingCart cart = (ShoppingCart) session.getAttribute("shoppingCart"); + HttpSession session = event.getSession(); + ShoppingCart cart = (ShoppingCart) session.getAttribute("shoppingCart"); if (cart == null) { Debug.logInfo("No cart to save, doing nothing.", module); return; } - + String delegatorName = (String) session.getAttribute("delegatorName"); GenericDelegator delegator = null; if (UtilValidate.isNotEmpty(delegatorName)) { @@ -64,17 +64,17 @@ Debug.logError("Could not find delegator with delegatorName in session, not saving abandoned cart info.", module); return; } - + boolean beganTransaction = false; try { beganTransaction = TransactionUtil.begin(); - + GenericValue visit = VisitHandler.getVisit(session); if (visit == null) { Debug.logError("Could not get the current visit, not saving abandoned cart info.", module); return; } - + Debug.logInfo("Saving abandoned cart", module); Iterator cartItems = cart.iterator(); int seqId = 1; Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartItemModifyException.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartItemModifyException.java?rev=757091&r1=757090&r2=757091&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartItemModifyException.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartItemModifyException.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 @@ -36,7 +36,7 @@ public CartItemModifyException(Throwable nested) { super(nested); } - + public CartItemModifyException(String str, Throwable nested) { super(str, nested); } Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java?rev=757091&r1=757090&r2=757091&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.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 @@ -74,7 +74,7 @@ if ("error".equals(CheckOutEvents.cartNotEmpty(request, response)) == true) { return "error"; } - + HttpSession session = request.getSession(); //Locale locale = UtilHttp.getLocale(request); @@ -98,7 +98,7 @@ cart.cleanUpShipGroups(); } CheckOutHelper checkOutHelper = new CheckOutHelper(dispatcher, delegator, cart); - + if ("shippingaddress".equals(curPage) == true) { // Set the shipping address options String shippingContactMechId = request.getParameter("shipping_contact_mech_id"); @@ -106,7 +106,7 @@ String taxAuthPartyGeoIds = request.getParameter("taxAuthPartyGeoIds"); String partyTaxId = request.getParameter("partyTaxId"); String isExempt = request.getParameter("isExempt"); - + List errorMessages = new ArrayList(); Map errorMaps = new HashMap(); for (int shipGroupIndex = 0; shipGroupIndex < cart.getShipGroupSize(); shipGroupIndex++) { @@ -122,7 +122,7 @@ // if taxAuthPartyGeoIds is not empty drop that into the database if (UtilValidate.isNotEmpty(taxAuthPartyGeoIds)) { try { - Map createCustomerTaxAuthInfoResult = dispatcher.runSync("createCustomerTaxAuthInfo", + Map createCustomerTaxAuthInfoResult = dispatcher.runSync("createCustomerTaxAuthInfo", UtilMisc.<String, Object>toMap("partyId", cart.getPartyId(), "taxAuthPartyGeoIds", taxAuthPartyGeoIds, "partyTaxId", partyTaxId, "isExempt", isExempt, "userLogin", userLogin)); ServiceUtil.getMessages(request, createCustomerTaxAuthInfoResult, null); if (ServiceUtil.isError(createCustomerTaxAuthInfoResult)) { @@ -134,7 +134,7 @@ return "error"; } } - + Map callResult = checkOutHelper.setCheckOutShippingAddress(shippingContactMechId); ServiceUtil.getMessages(request, callResult, null); @@ -154,7 +154,7 @@ String shipBeforeDate = request.getParameter("shipBeforeDate"); String shipAfterDate = request.getParameter("shipAfterDate"); Map callResult = ServiceUtil.returnSuccess(); - + for (int shipGroupIndex = 0; shipGroupIndex < cart.getShipGroupSize(); shipGroupIndex++) { callResult = checkOutHelper.finalizeOrderEntryOptions(shipGroupIndex, shippingMethod, shippingInstructions, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate, orderAdditionalEmails); ServiceUtil.getMessages(request, callResult, null); @@ -171,7 +171,7 @@ if (UtilValidate.isNotEmpty(billingAccountId)) { BigDecimal billingAccountAmt = null; billingAccountAmt = determineBillingAccountAmount(billingAccountId, request.getParameter("billingAccountAmount"), dispatcher); - if ((billingAccountId != null) && !"_NA_".equals(billingAccountId) && (billingAccountAmt == null)) { + if ((billingAccountId != null) && !"_NA_".equals(billingAccountId) && (billingAccountAmt == null)) { request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderInvalidAmountSetForBillingAccount", UtilMisc.toMap("billingAccountId",billingAccountId), (cart != null ? cart.getLocale() : Locale.getDefault()))); return "error"; } @@ -246,7 +246,7 @@ } /** - * Use for quickcheckout submit. It calculates the tax before setting the payment options. + * Use for quickcheckout submit. It calculates the tax before setting the payment options. * Shipment option should already be set by the quickcheckout form. */ public static String setQuickCheckOutOptions(HttpServletRequest request, HttpServletResponse response) { @@ -294,7 +294,7 @@ if (paymentMethods != null) { for (int i = 0; i < paymentMethods.length; i++) { Map paymentMethodInfo = FastMap.newInstance(); - + String securityCode = request.getParameter("securityCode_" + paymentMethods[i]); if (UtilValidate.isNotEmpty(securityCode)) { paymentMethodInfo.put("securityCode", securityCode); @@ -335,7 +335,7 @@ if (UtilValidate.isNotEmpty(billingAccountId)) { BigDecimal billingAccountAmt = null; billingAccountAmt = determineBillingAccountAmount(billingAccountId, request.getParameter("billingAccountAmount"), dispatcher); - if (billingAccountAmt == null) { + if (billingAccountAmt == null) { request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderInvalidAmountSetForBillingAccount", UtilMisc.toMap("billingAccountId",billingAccountId), (cart != null ? cart.getLocale() : Locale.getDefault()))); return "error"; } @@ -348,11 +348,11 @@ String shippingMethod = request.getParameter("shipping_method"); String shippingContactMechId = request.getParameter("shipping_contact_mech_id"); - + String taxAuthPartyGeoIds = request.getParameter("taxAuthPartyGeoIds"); String partyTaxId = request.getParameter("partyTaxId"); String isExempt = request.getParameter("isExempt"); - + String shippingInstructions = request.getParameter("shipping_instructions"); String orderAdditionalEmails = request.getParameter("order_additional_emails"); String maySplit = request.getParameter("may_split"); @@ -362,7 +362,7 @@ String shipBeforeDate = request.getParameter("shipBeforeDate"); String shipAfterDate = request.getParameter("shipAfterDate"); String cancelBackOrderDate = request.getParameter("cancelBackOrderDate"); - + List singleUsePayments = new ArrayList(); // get a request map of parameters @@ -371,7 +371,7 @@ // if taxAuthPartyGeoIds is not empty drop that into the database if (UtilValidate.isNotEmpty(taxAuthPartyGeoIds)) { try { - Map createCustomerTaxAuthInfoResult = dispatcher.runSync("createCustomerTaxAuthInfo", + Map createCustomerTaxAuthInfoResult = dispatcher.runSync("createCustomerTaxAuthInfo", UtilMisc.toMap("partyId", cart.getPartyId(), "taxAuthPartyGeoIds", taxAuthPartyGeoIds, "partyTaxId", partyTaxId, "isExempt", isExempt)); ServiceUtil.getMessages(request, createCustomerTaxAuthInfoResult, null); if (ServiceUtil.isError(createCustomerTaxAuthInfoResult)) { @@ -383,7 +383,7 @@ return "error"; } } - + // check for gift card not on file Map gcResult = checkOutHelper.checkGiftCard(params, selectedPaymentMethods); ServiceUtil.getMessages(request, gcResult, null); @@ -482,7 +482,7 @@ } return productStore.getBoolean("explodeOrderItems").booleanValue(); } - + public static String checkShipmentNeeded(HttpServletRequest request, HttpServletResponse response) { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); ShoppingCart cart = ShoppingCartEvents.getCartObject(request); @@ -492,7 +492,7 @@ } catch (GenericEntityException e) { Debug.logError(e, "Error getting ProductStore: " + e.toString(), module); } - + Debug.logInfo("checkShipmentNeeded: reqShipAddrForDigItems=" + productStore.getString("reqShipAddrForDigItems"), module); if (productStore != null && "N".equals(productStore.getString("reqShipAddrForDigItems"))) { Debug.logInfo("checkShipmentNeeded: cart.containOnlyDigitalGoods()=" + cart.containOnlyDigitalGoods(), module); @@ -501,7 +501,7 @@ return "shipmentNotNeeded"; } } - + return "shipmentNeeded"; } @@ -695,7 +695,7 @@ Debug.logError(e, module); } } - + // set the customer info if (mode != null && mode.equals("default")) { cart.setDefaultCheckoutOptions(dispatcher); @@ -780,7 +780,7 @@ shipBeforeDate = request.getParameter(shipGroupIndex + "_shipBeforeDate"); shipAfterDate = request.getParameter(shipGroupIndex + "_shipAfterDate"); cancelBackOrderDate = request.getParameter("cancelBackOrderDate"); - + callResult = checkOutHelper.finalizeOrderEntryOptions(shipGroupIndex, shippingMethod, shippingInstructions, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate, cancelBackOrderDate); ServiceUtil.addErrors(errorMessages, errorMaps, callResult); } @@ -831,7 +831,7 @@ if (UtilValidate.isNotEmpty(billingAccountId)) { BigDecimal billingAccountAmt = null; billingAccountAmt = determineBillingAccountAmount(billingAccountId, request.getParameter("billingAccountAmount"), dispatcher); - if (billingAccountAmt == null) { + if (billingAccountAmt == null) { request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderInvalidAmountSetForBillingAccount", UtilMisc.toMap("billingAccountId",billingAccountId), (cart != null ? cart.getLocale() : Locale.getDefault()))); return "error"; } @@ -851,7 +851,7 @@ selectedPaymentMethods.put(newPaymentMethodId, UtilMisc.toMap("amount", null, "securityCode", null)); } } - + // The selected payment methods are set errorMessages.addAll(checkOutHelper.setCheckOutPaymentInternal(selectedPaymentMethods, null, billingAccountId)); // Verify if a gift card has been selected during order entry @@ -943,7 +943,7 @@ shippingOptionsSet = false; } } - + String customerPartyId = cart.getPartyId(); String[] processOrder = {"customer", "shipping", "shipGroups", "options", "term", "payment", Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=757091&r1=757090&r2=757091&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.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 @@ -129,7 +129,7 @@ String errMsg = null; if (UtilValidate.isNotEmpty(this.cart)) { - errorMessages.addAll(setCheckOutShippingOptionsInternal(shippingMethod, shippingInstructions, + errorMessages.addAll(setCheckOutShippingOptionsInternal(shippingMethod, shippingInstructions, orderAdditionalEmails, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate)); } else { errMsg = UtilProperties.getMessage(resource_error,"checkhelper.no_items_in_cart", (cart != null ? cart.getLocale() : Locale.getDefault())); @@ -147,7 +147,7 @@ return result; } - private List setCheckOutShippingOptionsInternal(String shippingMethod, String shippingInstructions, String orderAdditionalEmails, + private List setCheckOutShippingOptionsInternal(String shippingMethod, String shippingInstructions, String orderAdditionalEmails, String maySplit, String giftMessage, String isGift, String internalCode, String shipBeforeDate, String shipAfterDate ) { List errorMessages = new ArrayList(); String errMsg = null; @@ -385,7 +385,7 @@ public Map setCheckOutOptions(String shippingMethod, String shippingContactMechId, Map selectedPaymentMethods, - List singleUsePayments, String billingAccountId, String shippingInstructions, + List singleUsePayments, String billingAccountId, String shippingInstructions, String orderAdditionalEmails, String maySplit, String giftMessage, String isGift, String internalCode, String shipBeforeDate, String shipAfterDate) { List errorMessages = new ArrayList(); Map result = null; @@ -394,12 +394,12 @@ if (UtilValidate.isNotEmpty(this.cart)) { // set the general shipping options and method - errorMessages.addAll(setCheckOutShippingOptionsInternal(shippingMethod, shippingInstructions, + errorMessages.addAll(setCheckOutShippingOptionsInternal(shippingMethod, shippingInstructions, orderAdditionalEmails, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate)); // set the shipping address errorMessages.addAll(setCheckOutShippingAddressInternal(shippingContactMechId)); - + // Recalc shipping costs before setting payment Map shipEstimateMap = ShippingEvents.getShipGroupEstimate(dispatcher, delegator, cart, 0); BigDecimal shippingTotal = (BigDecimal) shipEstimateMap.get("shippingTotal"); @@ -458,7 +458,7 @@ errorMessages.add(errMsg); gcFieldsOkay = false; } - } + } // See if we should validate gift card code against FinAccount's accountCode if (cart.isValidateGCFinAccount(delegator)) { try { @@ -481,9 +481,9 @@ } catch (GenericEntityException ex) { errorMessages.add(ex.getMessage()); gcFieldsOkay = false; - } - } - + } + } + if (UtilValidate.isNotEmpty(selectedPaymentMethods)) { if (gcAmt == null || gcAmt.length() == 0) { errMsg = UtilProperties.getMessage(resource_error,"checkhelper.enter_amount_to_place_on_gift_card", (cart != null ? cart.getLocale() : Locale.getDefault())); @@ -630,7 +630,7 @@ String productId = orderItem.getString("productId"); if (productId != null) { try { - // do something tricky here: run as the "system" user + // do something tricky here: run as the "system" user // that can actually create and run a production run GenericValue permUserLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "system")); GenericValue productStore = ProductStoreWorker.getProductStore(productStoreId, delegator); @@ -644,12 +644,12 @@ inputMap.put("orderItemSeqId", orderItem.getString("orderItemSeqId")); inputMap.put("quantity", orderItem.getBigDecimal("quantity")); inputMap.put("userLogin", permUserLogin); - + Map prunResult = dispatcher.runSync("createProductionRunFromConfiguration", inputMap); if (ServiceUtil.isError(prunResult)) { Debug.logError(ServiceUtil.getErrorMessage(prunResult) + " for input:" + inputMap, module); } - } + } } catch (Exception e) { String service = e.getMessage(); Map messageMap = UtilMisc.toMap("service", service); @@ -794,22 +794,22 @@ List shipAmt = new ArrayList(totalItems); // Debug.logInfo("====== makeTaxContext passed in shipAddress=" + shipAddress, module); - + Iterator it = csi.shipItemInfo.keySet().iterator(); for (int i = 0; i < totalItems; i++) { ShoppingCartItem cartItem = (ShoppingCartItem) it.next(); ShoppingCart.CartShipInfo.CartShipItemInfo itemInfo = csi.getShipItemInfo(cartItem); - + //Debug.logInfo("In makeTaxContext for item [" + i + "] in ship group [" + shipGroup + "] got cartItem: " + cartItem, module); //Debug.logInfo("In makeTaxContext for item [" + i + "] in ship group [" + shipGroup + "] got itemInfo: " + itemInfo, module); - + product.add(i, cartItem.getProduct()); amount.add(i, cartItem.getItemSubTotal(itemInfo.quantity)); price.add(i, cartItem.getBasePrice()); shipAmt.add(i, BigDecimal.ZERO); // no per item shipping yet shoppingCartItemIndexMap.put(Integer.valueOf(i), cartItem); } - + //add promotion adjustments List allAdjustments = cart.getAdjustments(); BigDecimal orderPromoAmt = OrderReadHelper.calcOrderPromoAdjustmentsBd(allAdjustments); @@ -1052,10 +1052,10 @@ EntityCondition.makeCondition("paymentMethodTypeId", EntityOperator.EQUALS, "EXT_BILLACT")); List cashCodPcBaPaymentPreferences = EntityUtil.filterByOr(allPaymentPreferences, cashCodPcBaExpr); - if (UtilValidate.isNotEmpty(cashCodPcBaPaymentPreferences) && + if (UtilValidate.isNotEmpty(cashCodPcBaPaymentPreferences) && UtilValidate.isNotEmpty(allPaymentPreferences) && cashCodPcBaPaymentPreferences.size() == allPaymentPreferences.size()) { - + //if there are Check type, approve the order only if it is face to face List checkPareferences = EntityUtil.filterByAnd(cashCodPcBaPaymentPreferences, UtilMisc.toMap("paymentMethodTypeId", "PERSONAL_CHECK")); if (UtilValidate.isNotEmpty(checkPareferences)) { @@ -1064,8 +1064,8 @@ if (!ok) { throw new GeneralException("Problem with order change; see above error"); } - } - // approve this as long as there are only CASH, COD and Billing Account types + } + // approve this as long as there are only CASH, COD and Billing Account types } else { boolean ok = OrderChangeHelper.approveOrder(dispatcher, userLogin, orderId, manualHold); if (!ok) { @@ -1191,7 +1191,7 @@ String errMsg=null; String REJECT_MESSAGE = productStore.getString("authFraudMessage"); String orderId = this.cart.getOrderId(); - + try { if (userLogin != null) { // nuke the userlogin @@ -1379,7 +1379,7 @@ * * @param checkOutPaymentId The payment ID to be associated with the cart * @return A Map conforming to the OFBiz Service conventions containing - * any error messages. + * any error messages. */ public Map finalizeOrderEntryPayment(String checkOutPaymentId, BigDecimal amount, boolean singleUse, boolean append) { Map result = ServiceUtil.returnSuccess(); @@ -1512,7 +1512,7 @@ errMsg = UtilProperties.getMessage(resource_error, "checkhelper.change_returned_cannot_be_greater_than_cash", (cart != null ? cart.getLocale() : Locale.getDefault())); return ServiceUtil.returnError(errMsg); } - } + } } return ServiceUtil.returnSuccess(); } Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ItemNotFoundException.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ItemNotFoundException.java?rev=757091&r1=757090&r2=757091&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ItemNotFoundException.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ItemNotFoundException.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 |
Free forum by Nabble | Edit this page |