You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/03/27 18:25:00 UTC
svn commit: r522986 - in /ofbiz/trunk/applications/order:
src/org/ofbiz/order/order/OrderChangeHelper.java
src/org/ofbiz/order/order/OrderServices.java
webapp/ordermgr/order/orderitems.ftl
Author: jaz
Date: Tue Mar 27 09:24:50 2007
New Revision: 522986
URL: http://svn.apache.org/viewvc?view=rev&rev=522986
Log:
updated to support non-product items
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderChangeHelper.java
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl
Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderChangeHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderChangeHelper.java?view=diff&rev=522986&r1=522985&r2=522986
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderChangeHelper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderChangeHelper.java Tue Mar 27 09:24:50 2007
@@ -192,6 +192,7 @@
GenericValue orderItem = (GenericValue) oii.next();
String orderItemSeqId = orderItem.getString("orderItemSeqId");
GenericValue product = null;
+
try {
product = orderItem.getRelatedOne("Product");
} catch (GenericEntityException e) {
@@ -213,6 +214,16 @@
if (ModelService.RESPOND_ERROR.equals(digitalStatusChange.get(ModelService.RESPONSE_MESSAGE))) {
Debug.logError("Problems with digital product status change : " + product, module);
}
+ }
+ }
+ } else {
+ String orderItemType = orderItem.getString("orderItemTypeId");
+ if (!"PRODUCT_ORDER_ITEM".equals(orderItemType)) {
+ // non-product items don't ship; treat as a digital item
+ Map digitalStatusFields = UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "statusId", digitalItemStatus, "userLogin", userLogin);
+ Map digitalStatusChange = dispatcher.runSync("changeOrderItemStatus", digitalStatusFields);
+ if (ModelService.RESPOND_ERROR.equals(digitalStatusChange.get(ModelService.RESPONSE_MESSAGE))) {
+ Debug.logError("Problems with digital product status change : " + product, module);
}
}
}
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?view=diff&rev=522986&r1=522985&r2=522986
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Tue Mar 27 09:24:50 2007
@@ -2637,9 +2637,11 @@
}
}
- // find any digital goods
- Map digitalProducts = new HashMap();
+ // find any digital or non-product items
+ List nonProductItems = new ArrayList();
List digitalItems = new ArrayList();
+ Map digitalProducts = new HashMap();
+
if (orderItems != null && orderItems.size() > 0) {
Iterator i = orderItems.iterator();
while (i.hasNext()) {
@@ -2674,26 +2676,36 @@
}
}
}
+ } else {
+ String itemType = item.getString("orderItemTypeId");
+ if (!"PRODUCT_ORDER_ITEM".equals(itemType)) {
+ nonProductItems.add(item);
+ }
}
}
}
// now process the digital items
- if (digitalItems.size() > 0) {
+ if (digitalItems.size() > 0 || nonProductItems.size() > 0) {
GenericValue productStore = OrderReadHelper.getProductStoreFromOrder(dispatcher.getDelegator(), orderId);
boolean invoiceItems = true;
if (productStore != null && productStore.get("autoInvoiceDigitalItems") != null) {
invoiceItems = "Y".equalsIgnoreCase(productStore.getString("autoInvoiceDigitalItems"));
}
+ // single list with all invoice items
+ List itemsToInvoice = FastList.newInstance();
+ itemsToInvoice.addAll(nonProductItems);
+ itemsToInvoice.addAll(digitalItems);
+
if (invoiceItems) {
- // invoice all APPROVED digital goods
-
+ // invoice all APPROVED digital/non-product goods
+
// do something tricky here: run as a different user that can actually create an invoice, post transaction, etc
Map invoiceResult = null;
try {
GenericValue permUserLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system"));
- Map invoiceContext = UtilMisc.toMap("orderId", orderId, "billItems", digitalItems, "userLogin", permUserLogin);
+ Map invoiceContext = UtilMisc.toMap("orderId", orderId, "billItems", itemsToInvoice, "userLogin", permUserLogin);
invoiceResult = dispatcher.runSync("createInvoiceForOrder", invoiceContext);
} catch (GenericEntityException e) {
Debug.logError(e, "ERROR: Unable to invoice digital items", module);
@@ -2707,11 +2719,12 @@
}
// update the status of digital goods to COMPLETED; leave physical/digital as APPROVED for pick/ship
- Iterator dii = digitalItems.iterator();
+ Iterator dii = itemsToInvoice.iterator();
while (dii.hasNext()) {
GenericValue productType = null;
GenericValue item = (GenericValue) dii.next();
GenericValue product = (GenericValue) digitalProducts.get(item);
+ boolean markComplete = false;
if (product != null) {
try {
@@ -2719,6 +2732,11 @@
} catch (GenericEntityException e) {
Debug.logError(e, "ERROR: Unable to get ProductType from Product", module);
}
+ } else {
+ String itemType = item.getString("orderItemTypeId");
+ if (!"PRODUCT_ORDER_ITEM".equals(itemType)) {
+ markComplete = true;
+ }
}
if (product != null && productType != null) {
@@ -2726,18 +2744,22 @@
String isDigital = productType.getString("isDigital");
// we were set as a digital good; one more check and change status
- if ((isDigital != null && "Y".equalsIgnoreCase(isDigital)) && (
- isPhysical == null || !"Y".equalsIgnoreCase(isPhysical))) {
- Map statusCtx = new HashMap();
- statusCtx.put("orderId", item.getString("orderId"));
- statusCtx.put("orderItemSeqId", item.getString("orderItemSeqId"));
- statusCtx.put("statusId", "ITEM_COMPLETED");
- statusCtx.put("userLogin", userLogin);
- try {
- dispatcher.runSyncIgnore("changeOrderItemStatus", statusCtx);
- } catch (GenericServiceException e) {
- Debug.logError(e, "ERROR: Problem setting the status to COMPLETED : " + item, module);
- }
+ if ((isDigital != null && "Y".equalsIgnoreCase(isDigital)) &&
+ (isPhysical == null || !"Y".equalsIgnoreCase(isPhysical))) {
+ markComplete = true;
+ }
+ }
+
+ if (markComplete) {
+ Map statusCtx = new HashMap();
+ statusCtx.put("orderId", item.getString("orderId"));
+ statusCtx.put("orderItemSeqId", item.getString("orderItemSeqId"));
+ statusCtx.put("statusId", "ITEM_COMPLETED");
+ statusCtx.put("userLogin", userLogin);
+ try {
+ dispatcher.runSyncIgnore("changeOrderItemStatus", statusCtx);
+ } catch (GenericServiceException e) {
+ Debug.logError(e, "ERROR: Problem setting the status to COMPLETED : " + item, module);
}
}
}
@@ -4012,6 +4034,14 @@
// set the payment method
cart.addPayment(paymentMethodId);
+ // store the order
+ CheckOutHelper coh = new CheckOutHelper(dispatcher, delegator, cart);
+ Map createResp = coh.createOrder(userLogin);
+ if (ServiceUtil.isError(createResp)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(createResp));
+ }
+
+ // process the payment
Map procCtx = FastMap.newInstance();
procCtx.put("shoppingCart", cart);
procCtx.put("userLogin", userLogin);
Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl?view=diff&rev=522986&r1=522985&r2=522986
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/order/orderitems.ftl Tue Mar 27 09:24:50 2007
@@ -69,13 +69,13 @@
</td>
<#else>
<td valign="top">
- <#if productId?exists>
+ <#if productId?has_content>
<#assign product = orderItem.getRelatedOneCache("Product")>
</#if>
<div class="tabletext">
<#if productId?exists>
${orderItem.productId?default("N/A")} - ${orderItem.itemDescription?if_exists}
- <#if product.salesDiscontinuationDate?exists && Static["org.ofbiz.base.util.UtilDateTime"].nowTimestamp().after(product.salesDiscontinuationDate)>
+ <#if (product.salesDiscontinuationDate)?exists && Static["org.ofbiz.base.util.UtilDateTime"].nowTimestamp().after(product.salesDiscontinuationDate)>
<br/><span style="color: red;">${uiLabelMap.OrderItemDiscontinued}: ${product.salesDiscontinuationDate}</span>
</#if>
<#elseif orderItemType?exists>