Author: mor
Date: Wed Mar 18 13:54:53 2009 New Revision: 755596 URL: http://svn.apache.org/viewvc?rev=755596&view=rev Log: 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 <description> element instead of <!-- -->. Also changed this for adjacent field. Changed the description of the service a bit. Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.xml ofbiz/trunk/applications/order/data/OrderScheduledServices.xml ofbiz/trunk/applications/order/entitydef/entitymodel.xml ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml ofbiz/trunk/applications/order/servicedef/services.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy ofbiz/trunk/applications/order/webapp/ordermgr/entry/orderagreements.ftl ofbiz/trunk/applications/order/webapp/ordermgr/order/orderReportHeaderInfo.fo.ftl ofbiz/trunk/applications/order/webapp/ordermgr/order/orderinfo.ftl Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderUiLabels.xml?rev=755596&r1=755595&r2=755596&view=diff ============================================================================== --- ofbiz/trunk/applications/order/config/OrderUiLabels.xml (original) +++ ofbiz/trunk/applications/order/config/OrderUiLabels.xml Wed Mar 18 13:54:53 2009 @@ -51,6 +51,9 @@ <value xml:lang="th">à¹à¸à¹à¸ªà¸£à¹à¸à¸à¸¶à¸à¸£à¸«à¸±à¸ªà¸à¸¥à¸¸à¹à¸¡à¸¥à¸¹à¸à¸à¹à¸²</value> <value xml:lang="zh">è´¦åè®°å ¥å®¢æ·ä¼åæ è¯</value> </property> + <property key="FormFieldTitle_cancelBackOrderDate"> + <value xml:lang="en">Cancel Back Order Date</value> + </property> <property key="FormFieldTitle_carrierRoleTypeId"> <value xml:lang="de">Spediteur Rollentyp ID</value> <value xml:lang="en">Carrier Role Type Id</value> Modified: ofbiz/trunk/applications/order/data/OrderScheduledServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/data/OrderScheduledServices.xml?rev=755596&r1=755595&r2=755596&view=diff ============================================================================== --- ofbiz/trunk/applications/order/data/OrderScheduledServices.xml (original) +++ ofbiz/trunk/applications/order/data/OrderScheduledServices.xml Wed Mar 18 13:54:53 2009 @@ -27,4 +27,6 @@ <JobSandbox jobId="8003" jobName="Run Auto-Reorders" runTime="2000-01-01 03:00:00.000" serviceName="runShoppingListAutoReorder" poolId="pool" runAsUser="system" tempExprId="MIDNIGHT_DAILY" maxRecurrenceCount="-1"/> <JobSandbox jobId="8004" jobName="Re-Try Failed Auths NSF" runTime="2000-01-01 01:00:00.000" serviceName="retryFailedAuthNsfs" poolId="pool" runAsUser="system" tempExprId="MIDNIGHT_DAILY" maxRecurrenceCount="-1"/> <JobSandbox jobId="8005" jobName="Extend expired Subscriptions" runTime="2000-01-01 03:00:00.000" serviceName="runSubscriptionAutoReorders" poolId="pool" runAsUser="system" tempExprId="MIDNIGHT_DAILY" maxRecurrenceCount="-1"/> + <JobSandbox jobId="8006" jobName="Cancels all orders after date" runTime="2009-12-03 03:00:00.000" serviceName="cancelAllBackOrders" poolId="pool" runAsUser="system" tempExprId="MIDNIGHT_DAILY" maxRecurrenceCount="-1"/> + </entity-engine-xml> Modified: ofbiz/trunk/applications/order/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/entitydef/entitymodel.xml?rev=755596&r1=755595&r2=755596&view=diff ============================================================================== --- ofbiz/trunk/applications/order/entitydef/entitymodel.xml (original) +++ ofbiz/trunk/applications/order/entitydef/entitymodel.xml Wed Mar 18 13:54:53 2009 @@ -475,7 +475,8 @@ <field name="dontCancelSetUserLogin" type="id-vlong"></field> <field name="shipBeforeDate" type="date-time"></field> <field name="shipAfterDate" type="date-time"></field> - <field name="overrideGlAccountId" type="id"><!-- used to specify the override or actual glAccountId used for the adjustment, avoids problems if configuration changes after initial posting, etc --></field> + <field name="cancelBackOrderDate" type="date-time"><description>Used to cancel all orders from suppliers when its in past</description></field> + <field name="overrideGlAccountId" type="id"><description>Used to specify the override or actual glAccountId used for the adjustment, avoids problems if configuration changes after initial posting, etc.</description></field> <field name="salesOpportunityId" type="id-ne"></field> <prim-key field="orderId"/> <prim-key field="orderItemSeqId"/> Modified: ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml?rev=755596&r1=755595&r2=755596&view=diff ============================================================================== --- ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml (original) +++ ofbiz/trunk/applications/order/script/org/ofbiz/order/order/OrderServices.xml Wed Mar 18 13:54:53 2009 @@ -1255,4 +1255,35 @@ </if> </simple-method> -</simple-methods> + <simple-method method-name="cancelAllBackOrders" short-description="Cancels those back orders from suppliers whose cancel back order date (cancelBackOrderDate) has passed the current date"> + <now-timestamp field="nowTimestamp"/> + <entity-condition list="orders" entity-name="OrderHeader"> + <condition-list combine="and"> + <condition-expr field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/> + <condition-expr field-name="statusId" operator="not-equals" value="ORDER_CANCELLED"/> + </condition-list> + </entity-condition> + <iterate entry="currentOrder" list="orders"> + <entity-and list="orderItems" entity-name="OrderItem"> + <field-map field-name="orderId" from-field="currentOrder.orderId"/> + </entity-and> + <iterate entry="currentOrderItem" list="orderItems"> + <set field="backOrderDate" from-field="currentOrderItem.cancelBackOrderDate" type="Timestamp"/> + <if> + <condition> + <and> + <not><if-empty field="backOrderDate"/></not> + <if-compare-field field="nowTimestamp" to-field="backOrderDate" operator="greater" type="Timestamp"/> + </and> + </condition> + <then> + <set field="orderItemMap.orderId" from-field="currentOrder.orderId"/> + <set field="orderItemMap.orderItemSeqId" from-field="currentOrderItem.orderItemSeqId"/> + <call-service service-name="cancelOrderItem" in-map-name="orderItemMap"/> + </then> + </if> + </iterate> + </iterate> + </simple-method> + +</simple-methods> \ No newline at end of file Modified: ofbiz/trunk/applications/order/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?rev=755596&r1=755595&r2=755596&view=diff ============================================================================== --- ofbiz/trunk/applications/order/servicedef/services.xml (original) +++ ofbiz/trunk/applications/order/servicedef/services.xml Wed Mar 18 13:54:53 2009 @@ -945,4 +945,9 @@ <attribute name="itemPriceMap" type="Map" mode="IN" string-map-prefix="ipm_" optional="true"/> <attribute name="overridePriceMap" type="Map" mode="IN" string-map-prefix="opm_" optional="true"/> </service> -</services> + + <service name="cancelAllBackOrders" engine="simple" + location="org/ofbiz/order/order/OrderServices.xml" invoke="cancelAllBackOrders" auth="true"> + <description>Cancels those back orders from suppliers whose cancel back order date (cancelBackOrderDate) has passed the current date</description> + </service> +</services> \ No newline at end of file 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=755596&r1=755595&r2=755596&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 Wed Mar 18 13:54:53 2009 @@ -361,6 +361,8 @@ 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 @@ 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 @@ 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); } } 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=755596&r1=755595&r2=755596&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 Wed Mar 18 13:54:53 2009 @@ -164,6 +164,7 @@ 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 @@ 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 @@ //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 @@ 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 @@ 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) { Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=755596&r1=755595&r2=755596&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java Wed Mar 18 13:54:53 2009 @@ -1661,6 +1661,7 @@ 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 @@ 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"; 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=755596&r1=755595&r2=755596&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 Wed Mar 18 13:54:53 2009 @@ -132,6 +132,7 @@ 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 @@ * @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 @@ 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 @@ 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; Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy?rev=755596&r1=755595&r2=755596&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy Wed Mar 18 13:54:53 2009 @@ -412,3 +412,8 @@ postalContactMechList = ContactHelper.getContactMechByType(orderParty,"POSTAL_ADDRESS", false); context.postalContactMechList = postalContactMechList; } + +if (orderItems) { + orderItem = EntityUtil.getFirst(orderItems); + context.orderItem = orderItem; +} Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/orderagreements.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/orderagreements.ftl?rev=755596&r1=755595&r2=755596&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/entry/orderagreements.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/orderagreements.ftl Wed Mar 18 13:54:53 2009 @@ -194,6 +194,24 @@ </a> </td> </tr> + + <#if cart.getOrderType() == "PURCHASE_ORDER"> + <tr> + <td> </td> + <td align='right' valign='top'> + <div class='tableheadtext'> + ${uiLabelMap.FormFieldTitle_cancelBackOrderDate} + </div> + </td> + <td> </td> + <td><input type="text" name="cancelBackOrderDate" size="20" maxlength="30"/> + <a href="javascript:call_cal(document.agreementForm.cancelBackOrderDate,'');"> + <img src='/images/cal.gif' width='16' height='16' border='0' alt='Calendar'/> + </a> + </td> + </tr> + </#if> + </table> </div> </div> Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/orderReportHeaderInfo.fo.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/orderReportHeaderInfo.fo.ftl?rev=755596&r1=755595&r2=755596&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/order/orderReportHeaderInfo.fo.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/order/orderReportHeaderInfo.fo.ftl Wed Mar 18 13:54:53 2009 @@ -18,8 +18,8 @@ --> <#escape x as x?xml> <fo:table> - <fo:table-column column-width="1.5in"/> - <fo:table-column column-width="1.5in"/> + <fo:table-column column-width="2.0in"/> + <fo:table-column column-width="2.0in"/> <fo:table-body> <fo:table-row> <fo:table-cell> @@ -43,6 +43,14 @@ <fo:table-cell><fo:block>${uiLabelMap.OrderCurrentStatus}</fo:block></fo:table-cell> <fo:table-cell><fo:block font-weight="bold">${currentStatus.get("description",locale)}</fo:block></fo:table-cell> </fo:table-row> - </fo:table-body> - </fo:table> + <#if orderItem.cancelBackOrderDate?exists> + <fo:table-row> + <fo:table-cell><fo:block>${uiLabelMap.FormFieldTitle_cancelBackOrderDate}</fo:block></fo:table-cell> + <#assign dateFormat = Static["java.text.DateFormat"].LONG> + <#assign cancelBackOrderDate = Static["java.text.DateFormat"].getDateInstance(dateFormat,locale).format(orderItem.get("cancelBackOrderDate"))> + <fo:table-cell><#if cancelBackOrderDate?has_content><fo:block>${cancelBackOrderDate}</fo:block></#if></fo:table-cell> + </fo:table-row> + </#if> + </fo:table-body> + </fo:table> </#escape> Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/orderinfo.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/orderinfo.ftl?rev=755596&r1=755595&r2=755596&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/order/orderinfo.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/order/orderinfo.ftl Wed Mar 18 13:54:53 2009 @@ -138,6 +138,14 @@ </#if> </td> </tr> + <#if orderItem.cancelBackOrderDate?exists> + <tr><td colspan="3"><hr/></td></tr> + <tr> + <td align="right" valign="top" width="15%" class="label"> ${uiLabelMap.FormFieldTitle_cancelBackOrderDate}</td> + <td width="5%"> </td> + <td valign="top" width="80%">${orderItem.cancelBackOrderDate?if_exists}</td> + </tr> + </#if> <#if distributorId?exists> <tr><td colspan="3"><hr/></td></tr> <tr> |
Free forum by Nabble | Edit this page |