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. 



git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@755596 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vikas Mayur
2009-03-18 13:54:53 +00:00
parent e20914f899
commit 7bc9f320d3
13 changed files with 126 additions and 11 deletions
@@ -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>
@@ -27,4 +27,6 @@ under the License.
<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>
+2 -1
View File
@@ -475,7 +475,8 @@ under the License.
<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"/>
@@ -1255,4 +1255,35 @@ under the License.
</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>
+6 -1
View File
@@ -945,4 +945,9 @@ under the License.
<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>
@@ -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);
}
}
@@ -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) {
@@ -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";
@@ -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;
@@ -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;
}
@@ -194,6 +194,24 @@ under the License.
</a>
</td>
</tr>
<#if cart.getOrderType() == "PURCHASE_ORDER">
<tr>
<td>&nbsp;</td>
<td align='right' valign='top'>
<div class='tableheadtext'>
${uiLabelMap.FormFieldTitle_cancelBackOrderDate}
</div>
</td>
<td>&nbsp;</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>
@@ -18,8 +18,8 @@ under the License.
-->
<#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 @@ under the License.
<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>
@@ -138,6 +138,14 @@ under the License.
</#if>
</td>
</tr>
<#if orderItem.cancelBackOrderDate?exists>
<tr><td colspan="3"><hr/></td></tr>
<tr>
<td align="right" valign="top" width="15%" class="label">&nbsp;${uiLabelMap.FormFieldTitle_cancelBackOrderDate}</td>
<td width="5%">&nbsp;</td>
<td valign="top" width="80%">${orderItem.cancelBackOrderDate?if_exists}</td>
</tr>
</#if>
<#if distributorId?exists>
<tr><td colspan="3"><hr/></td></tr>
<tr>