From 7bc9f320d376178fa80533fa1c85e958ea334889 Mon Sep 17 00:00:00 2001 From: Vikas Mayur Date: Wed, 18 Mar 2009 13:54:53 +0000 Subject: [PATCH] Cancel back orders from supplier if the cancelBackOrderDate (new field on OrderItem) has passed. This is achieved using a schedule job. Patch applied from OFBIZ-2220 (https://issues.apache.org/jira/browse/OFBIZ-2220). Thanks Deepesh Kapoor and Pranay Pandey for testing. On a side note, I have changed the field description on the entity to use element instead of . Also changed this for adjacent field. Changed the description of the service a bit. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@755596 13f79535-47bb-0310-9956-ffa450edef68 --- applications/order/config/OrderUiLabels.xml | 3 ++ .../order/data/OrderScheduledServices.xml | 2 ++ applications/order/entitydef/entitymodel.xml | 3 +- .../org/ofbiz/order/order/OrderServices.xml | 33 ++++++++++++++++++- applications/order/servicedef/services.xml | 7 +++- .../order/shoppingcart/CheckOutEvents.java | 7 +++- .../order/shoppingcart/ShoppingCart.java | 13 +++++++- .../shoppingcart/ShoppingCartEvents.java | 5 +++ .../order/shoppingcart/ShoppingCartItem.java | 17 ++++++++-- .../WEB-INF/actions/order/OrderView.groovy | 5 +++ .../webapp/ordermgr/entry/orderagreements.ftl | 18 ++++++++++ .../order/orderReportHeaderInfo.fo.ftl | 16 ++++++--- .../order/webapp/ordermgr/order/orderinfo.ftl | 8 +++++ 13 files changed, 126 insertions(+), 11 deletions(-) diff --git a/applications/order/config/OrderUiLabels.xml b/applications/order/config/OrderUiLabels.xml index 82c9b61d87..615da1f379 100644 --- a/applications/order/config/OrderUiLabels.xml +++ b/applications/order/config/OrderUiLabels.xml @@ -51,6 +51,9 @@ ใบเสร็จถึงรหัสกลุ่มลูกค้า 账单记入客户会员标识 + + Cancel Back Order Date + Spediteur Rollentyp ID Carrier Role Type Id diff --git a/applications/order/data/OrderScheduledServices.xml b/applications/order/data/OrderScheduledServices.xml index cecb43dfc4..ba36eff3c3 100644 --- a/applications/order/data/OrderScheduledServices.xml +++ b/applications/order/data/OrderScheduledServices.xml @@ -27,4 +27,6 @@ under the License. + + diff --git a/applications/order/entitydef/entitymodel.xml b/applications/order/entitydef/entitymodel.xml index 8385307ba0..4bc1ba3abf 100644 --- a/applications/order/entitydef/entitymodel.xml +++ b/applications/order/entitydef/entitymodel.xml @@ -475,7 +475,8 @@ under the License. - + Used to cancel all orders from suppliers when its in past + Used to specify the override or actual glAccountId used for the adjustment, avoids problems if configuration changes after initial posting, etc. diff --git a/applications/order/script/org/ofbiz/order/order/OrderServices.xml b/applications/order/script/org/ofbiz/order/order/OrderServices.xml index 6f3948e7f3..7f6d1fab76 100644 --- a/applications/order/script/org/ofbiz/order/order/OrderServices.xml +++ b/applications/order/script/org/ofbiz/order/order/OrderServices.xml @@ -1255,4 +1255,35 @@ under the License. - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/applications/order/servicedef/services.xml b/applications/order/servicedef/services.xml index 10d431239e..f39f9f2c2a 100644 --- a/applications/order/servicedef/services.xml +++ b/applications/order/servicedef/services.xml @@ -945,4 +945,9 @@ under the License. - + + + Cancels those back orders from suppliers whose cancel back order date (cancelBackOrderDate) has passed the current date + + \ No newline at end of file diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java index e307e4e755..bfed575972 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java @@ -361,6 +361,8 @@ public class CheckOutEvents { String internalCode = request.getParameter("internalCode"); 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 @@ -660,6 +662,7 @@ public class CheckOutEvents { String appendPayment = null; String shipBeforeDate = null; String shipAfterDate = null; + String cancelBackOrderDate = null; String mode = request.getParameter("finalizeMode"); Debug.logInfo("FinalizeMode: " + mode, module); @@ -776,7 +779,9 @@ public class CheckOutEvents { internalCode = request.getParameter("internalCode"); // FIXME shipBeforeDate = request.getParameter(shipGroupIndex + "_shipBeforeDate"); shipAfterDate = request.getParameter(shipGroupIndex + "_shipAfterDate"); - callResult = checkOutHelper.finalizeOrderEntryOptions(shipGroupIndex, shippingMethod, shippingInstructions, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate); + cancelBackOrderDate = request.getParameter("cancelBackOrderDate"); + + callResult = checkOutHelper.finalizeOrderEntryOptions(shipGroupIndex, shippingMethod, shippingInstructions, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate, cancelBackOrderDate); ServiceUtil.addErrors(errorMessages, errorMaps, callResult); } } diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java index f2ce62b845..f0de6e89d5 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java @@ -164,6 +164,7 @@ public class ShoppingCart implements Serializable { protected String currencyUom = null; protected boolean holdOrder = false; protected Timestamp orderDate = null; + protected Timestamp cancelBackOrderDate = null; /** don't allow empty constructor */ protected ShoppingCart() {} @@ -195,6 +196,7 @@ public class ShoppingCart implements Serializable { this.viewCartOnAdd = cart.viewCartOnAdd(); this.defaultShipAfterDate = cart.getDefaultShipAfterDate(); this.defaultShipBeforeDate = cart.getDefaultShipBeforeDate(); + this.cancelBackOrderDate = cart.getCancelBackOrderDate(); this.terminalId = cart.getTerminalId(); this.transactionId = cart.getTransactionId(); @@ -517,7 +519,7 @@ public class ShoppingCart implements Serializable { //GenericValue productSupplier = null; supplierProduct = getSupplierProduct(productId, quantity, dispatcher); if (supplierProduct != null || "_NA_".equals(this.getPartyId())) { - return this.addItem(0, ShoppingCartItem.makePurchaseOrderItem(new Integer(0), productId, selectedAmount, quantity, features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, dispatcher, this, supplierProduct, shipBeforeDate, shipAfterDate)); + return this.addItem(0, ShoppingCartItem.makePurchaseOrderItem(new Integer(0), productId, selectedAmount, quantity, features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, dispatcher, this, supplierProduct, shipBeforeDate, shipAfterDate, cancelBackOrderDate)); } else { throw new CartItemModifyException("SupplierProduct not found"); } @@ -1120,6 +1122,14 @@ public class ShoppingCart implements Serializable { this.defaultShipAfterDate = defaultShipAfterDate; } + public void setCancelBackOrderDate(Timestamp cancelBackOrderDate) { + this.cancelBackOrderDate = cancelBackOrderDate; + } + + public Timestamp getCancelBackOrderDate() { + return this.cancelBackOrderDate; + } + public Timestamp getDefaultShipAfterDate() { return this.defaultShipAfterDate; } @@ -3447,6 +3457,7 @@ public class ShoppingCart implements Serializable { orderItem.set("shipBeforeDate", item.getShipBeforeDate()); orderItem.set("shipAfterDate", item.getShipAfterDate()); orderItem.set("estimatedShipDate", item.getEstimatedShipDate()); + orderItem.set("cancelBackOrderDate", item.getCancelBackOrderDate()); String fromInventoryItemId = (String) item.getAttribute("fromInventoryItemId"); if (fromInventoryItemId != null) { diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java index 3acd86ca3e..294f01cf6f 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java @@ -1661,6 +1661,7 @@ public class ShoppingCartEvents { String workEffortId = request.getParameter("workEffortId"); String shipBeforeDateStr = request.getParameter("shipBeforeDate"); String shipAfterDateStr = request.getParameter("shipAfterDate"); + String cancelBackOrderDateStr = request.getParameter("cancelBackOrderDate"); String orderId = request.getParameter("orderId"); String orderName = request.getParameter("orderName"); String correspondingPoId = request.getParameter("correspondingPoId"); @@ -1713,6 +1714,10 @@ public class ShoppingCartEvents { if (shipAfterDateStr.length() == 10) shipAfterDateStr += " 00:00:00.000"; cart.setDefaultShipAfterDate(java.sql.Timestamp.valueOf(shipAfterDateStr)); } + if (UtilValidate.isNotEmpty(cancelBackOrderDateStr)) { + if (cancelBackOrderDateStr.length() == 10) cancelBackOrderDateStr += " 00:00:00.000"; + cart.setCancelBackOrderDate(java.sql.Timestamp.valueOf(cancelBackOrderDateStr)); + } } catch (IllegalArgumentException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java index b4510f19b0..88c30c1ba6 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java @@ -132,6 +132,7 @@ public class ShoppingCartItem implements java.io.Serializable { private Timestamp shipBeforeDate = null; private Timestamp shipAfterDate = null; private Timestamp EstimatedShipDate = null; + private Timestamp cancelBackOrderDate = null; private Map contactMechIdsMap = FastMap.newInstance(); private List orderItemPriceInfos = null; @@ -162,12 +163,13 @@ public class ShoppingCartItem implements java.io.Serializable { * @param supplierProduct GenericValue of SupplierProduct entity, containing product description and prices * @param shipBeforeDate Request that the shipment be made before this date * @param shipAfterDate Request that the shipment be made after this date + * @param cancelBackOrderDate The date which if crossed causes order cancellation * @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) + LocalDispatcher dispatcher, ShoppingCart cart, GenericValue supplierProduct, Timestamp shipBeforeDate, Timestamp shipAfterDate, Timestamp cancelBackOrderDate) throws CartItemModifyException, ItemNotFoundException { GenericDelegator delegator = cart.getDelegator(); GenericValue product = null; @@ -229,10 +231,11 @@ public class ShoppingCartItem implements java.io.Serializable { newItem.setSelectedAmount(selectedAmount); } - // set the ship before/after dates. this needs to happen before setQuantity because setQuantity causes the ship group's dates to be + // 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()); newItem.setShipAfterDate(shipAfterDate != null ? shipAfterDate : cart.getDefaultShipAfterDate()); + newItem.setCancelBackOrderDate(cancelBackOrderDate != null ? cancelBackOrderDate : cart.getCancelBackOrderDate()); try { newItem.setQuantity(quantity, dispatcher, cart, true); @@ -1447,6 +1450,16 @@ public class ShoppingCartItem implements java.io.Serializable { 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; diff --git a/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy b/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy index 3dbebfabe9..3298f4f70d 100644 --- a/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy +++ b/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy @@ -412,3 +412,8 @@ if (orderHeader) { postalContactMechList = ContactHelper.getContactMechByType(orderParty,"POSTAL_ADDRESS", false); context.postalContactMechList = postalContactMechList; } + +if (orderItems) { + orderItem = EntityUtil.getFirst(orderItems); + context.orderItem = orderItem; +} diff --git a/applications/order/webapp/ordermgr/entry/orderagreements.ftl b/applications/order/webapp/ordermgr/entry/orderagreements.ftl index 9c899f4879..9983c37e8f 100644 --- a/applications/order/webapp/ordermgr/entry/orderagreements.ftl +++ b/applications/order/webapp/ordermgr/entry/orderagreements.ftl @@ -194,6 +194,24 @@ under the License. + + <#if cart.getOrderType() == "PURCHASE_ORDER"> + +   + +
+ ${uiLabelMap.FormFieldTitle_cancelBackOrderDate} +
+ +   + + + Calendar + + + + + diff --git a/applications/order/webapp/ordermgr/order/orderReportHeaderInfo.fo.ftl b/applications/order/webapp/ordermgr/order/orderReportHeaderInfo.fo.ftl index 3d56c92008..767ccdb541 100644 --- a/applications/order/webapp/ordermgr/order/orderReportHeaderInfo.fo.ftl +++ b/applications/order/webapp/ordermgr/order/orderReportHeaderInfo.fo.ftl @@ -18,8 +18,8 @@ under the License. --> <#escape x as x?xml> - - + + @@ -43,6 +43,14 @@ under the License. ${uiLabelMap.OrderCurrentStatus} ${currentStatus.get("description",locale)} - - + <#if orderItem.cancelBackOrderDate?exists> + + ${uiLabelMap.FormFieldTitle_cancelBackOrderDate} + <#assign dateFormat = Static["java.text.DateFormat"].LONG> + <#assign cancelBackOrderDate = Static["java.text.DateFormat"].getDateInstance(dateFormat,locale).format(orderItem.get("cancelBackOrderDate"))> + <#if cancelBackOrderDate?has_content>${cancelBackOrderDate} + + + + diff --git a/applications/order/webapp/ordermgr/order/orderinfo.ftl b/applications/order/webapp/ordermgr/order/orderinfo.ftl index a3b8e71854..f964c2d7e2 100644 --- a/applications/order/webapp/ordermgr/order/orderinfo.ftl +++ b/applications/order/webapp/ordermgr/order/orderinfo.ftl @@ -138,6 +138,14 @@ under the License. + <#if orderItem.cancelBackOrderDate?exists> +
+ +  ${uiLabelMap.FormFieldTitle_cancelBackOrderDate} +   + ${orderItem.cancelBackOrderDate?if_exists} + + <#if distributorId?exists>