Author: ashish
Date: Fri Nov 19 09:33:08 2010 New Revision: 1036773 URL: http://svn.apache.org/viewvc?rev=1036773&view=rev Log: Code Enhancement. Sometime it happens that you are reading order information from some legacy database and importing them in OFBiz. So if orderDate is passed in context then lets check it with sales discontinuation date. And if sales discontinuation date is greater then passed order date then you should safely import the order. Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java 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=1036773&r1=1036772&r2=1036773&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 Fri Nov 19 09:33:08 2010 @@ -295,6 +295,8 @@ public class OrderServices { return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderErrorTheProductStoreIdCanOnlyBeNullForPurchaseOrders",locale)); } + Timestamp orderDate = (Timestamp) context.get("orderDate"); + Iterator normalizedIter = normalizedItemQuantities.keySet().iterator(); while (normalizedIter.hasNext()) { // lookup the product entity for each normalized item; error on products not found @@ -331,8 +333,16 @@ public class OrderServices { } if ("SALES_ORDER".equals(orderTypeId)) { + boolean salesDiscontinuationFlag = false; + // Sometime it happens that you are reading orders info from legacy database. So if orderdate is passed in context then lets handle that case as well and compare the passed date with sales discontinuation date. + //The else condition should handle the previous case when order date is not passed and you wanted to check on sales discontinuation date. + if (orderDate != null && product.get("salesDiscontinuationDate") != null) { + salesDiscontinuationFlag = orderDate.after(product.getTimestamp("salesDiscontinuationDate")) && nowTimestamp.after(product.getTimestamp("salesDiscontinuationDate")); + } else if (product.get("salesDiscontinuationDate") != null) { + salesDiscontinuationFlag = nowTimestamp.after(product.getTimestamp("salesDiscontinuationDate")); + } // check to see if salesDiscontinuationDate has passed - if (product.get("salesDiscontinuationDate") != null && nowTimestamp.after(product.getTimestamp("salesDiscontinuationDate"))) { + if (salesDiscontinuationFlag) { String excMsg = UtilProperties.getMessage(resource_error, "product.no_longer_for_sale", new Object[] { getProductName(product, itemName), product.getString("productId") }, locale); Debug.logWarning(excMsg, module); @@ -457,7 +467,6 @@ public class OrderServices { } String billingAccountId = (String) context.get("billingAccountId"); - Timestamp orderDate = (Timestamp) context.get("orderDate"); if (orderDate == null) { orderDate = nowTimestamp; } |
Free forum by Nabble | Edit this page |