Author: jaz
Date: Fri Oct 22 22:43:27 2010
New Revision: 1026520
URL: http://svn.apache.org/viewvc?rev=1026520&view=rev
Log:
added condition to disable tax calculation when using the
saveUpdatedCartToOrder services; setting facility ID when calling
loadCartFromOrder
Modified:
ofbiz/trunk/applications/order/servicedef/services.xml
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
Modified: ofbiz/trunk/applications/order/servicedef/services.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?rev=1026520&r1=1026519&r2=1026520&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/order/servicedef/services.xml Fri Oct 22 22:43:27
2010
@@ -305,6 +305,7 @@ under the License.
<attribute name="orderId" type="String" mode="INOUT" optional="false"/>
<attribute name="supplierPartyId" type="String" mode="IN"
optional="true"/>
<attribute name="orderTypeId" type="String" mode="IN" optional="true"/>
+ <attribute name="calcTax" type="Boolean" mode="IN" optional="true"
default-value="true"/>
<attribute name="itemDescriptionMap" type="Map" mode="IN"
string-map-prefix="idm_" optional="true"/>
<attribute name="itemQtyMap" type="Map" mode="IN"
string-map-prefix="iqm_" optional="false"/>
<attribute name="itemPriceMap" type="Map" mode="IN"
string-map-prefix="ipm_" optional="false"/>
@@ -328,6 +329,7 @@ under the License.
<description>Update the quantities/prices for an existing
order</description>
<attribute name="orderId" type="String" mode="INOUT" optional="false"/>
<attribute name="shoppingCart"
type="org.ofbiz.order.shoppingcart.ShoppingCart" mode="IN" optional="false"/>
+ <attribute name="calcTax" type="Boolean" mode="IN" optional="true"
default-value="true"/>
<!-- <attribute name="locale" type="" mode="IN" optional="false"/> -->
<attribute name="changeMap" type="Map" mode="IN" optional="false"/>
</service>
@@ -346,6 +348,7 @@ under the License.
<attribute name="changeComments" type="String" mode="IN"
optional="true"/>
<attribute name="itemDesiredDeliveryDate" type="Timestamp" mode="IN"
optional="true"/>
<attribute name="itemAttributesMap" type="Map" mode="IN"
optional="true"/>
+ <attribute name="calcTax" type="Boolean" mode="IN" optional="true"
default-value="true"/>
<attribute name="shoppingCart"
type="org.ofbiz.order.shoppingcart.ShoppingCart" mode="OUT" optional="false"/>
</service>
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=1026520&r1=1026519&r2=1026520&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 Oct 22 22:43:27 2010
@@ -1781,7 +1781,9 @@ public class OrderServices {
// find the next status to set to (if any)
String newStatus = null;
if (allCanceled) {
- newStatus = "ORDER_CANCELLED";
+ if (!"PURCHASE_ORDER".equals(orderTypeId)) {
+ newStatus = "ORDER_CANCELLED";
+ }
} else if (allComplete) {
newStatus = "ORDER_COMPLETED";
} else if (allApproved) {
@@ -3303,6 +3305,10 @@ public class OrderServices {
Map itemAttributesMap = (Map) context.get("itemAttributesMap");
String reasonEnumId = (String) context.get("reasonEnumId");
String changeComments = (String) context.get("changeComments");
+ Boolean calcTax = (Boolean) context.get("calcTax");
+ if (calcTax == null) {
+ calcTax = Boolean.TRUE;
+ }
if (amount == null) {
amount = BigDecimal.ZERO;
@@ -3377,7 +3383,7 @@ public class OrderServices {
"itemCommentMap",
UtilMisc.toMap("changeComments", changeComments));
// save all the updated information
try {
- saveUpdatedCartToOrder(dispatcher, delegator, cart, locale,
userLogin, orderId, changeMap);
+ saveUpdatedCartToOrder(dispatcher, delegator, cart, locale,
userLogin, orderId, changeMap, calcTax);
} catch (GeneralException e) {
return ServiceUtil.returnError(e.getMessage());
}
@@ -3412,6 +3418,10 @@ public class OrderServices {
Map itemAttributesMap = (Map) context.get("itemAttributesMap");
Map<String,String> itemEstimatedShipDateMap = (Map)
context.get("itemShipDateMap");
Map<String, String> itemEstimatedDeliveryDateMap = (Map)
context.get("itemDeliveryDateMap");
+ Boolean calcTax = (Boolean) context.get("calcTax");
+ if (calcTax == null) {
+ calcTax = Boolean.TRUE;
+ }
// obtain a shopping cart object for updating
ShoppingCart cart = null;
@@ -3578,7 +3588,7 @@ public class OrderServices {
// save all the updated information
try {
- saveUpdatedCartToOrder(dispatcher, delegator, cart, locale,
userLogin, orderId, UtilMisc.toMap("itemReasonMap", itemReasonMap,
"itemCommentMap", itemCommentMap));
+ saveUpdatedCartToOrder(dispatcher, delegator, cart, locale,
userLogin, orderId, UtilMisc.toMap("itemReasonMap", itemReasonMap,
"itemCommentMap", itemCommentMap), calcTax);
} catch (GeneralException e) {
return ServiceUtil.returnError(e.getMessage());
}
@@ -3797,10 +3807,14 @@ public class OrderServices {
ShoppingCart cart = (ShoppingCart) context.get("shoppingCart");
Map changeMap = (Map) context.get("changeMap");
Locale locale = (Locale) context.get("locale");
+ Boolean calcTax = (Boolean) context.get("calcTax");
+ if (calcTax == null) {
+ calcTax = Boolean.TRUE;
+ }
Map result = null;
try {
- saveUpdatedCartToOrder(dispatcher, delegator, cart, locale,
userLogin, orderId, changeMap);
+ saveUpdatedCartToOrder(dispatcher, delegator, cart, locale,
userLogin, orderId, changeMap, calcTax);
result = ServiceUtil.returnSuccess();
//result.put("shoppingCart", cart);
} catch (GeneralException e) {
@@ -3812,7 +3826,7 @@ public class OrderServices {
return result;
}
- private static void saveUpdatedCartToOrder(LocalDispatcher dispatcher,
Delegator delegator, ShoppingCart cart, Locale locale, GenericValue userLogin,
String orderId, Map changeMap) throws GeneralException {
+ private static void saveUpdatedCartToOrder(LocalDispatcher dispatcher,
Delegator delegator, ShoppingCart cart, Locale locale, GenericValue userLogin,
String orderId, Map changeMap, boolean calcTax) throws GeneralException {
// get/set the shipping estimates. if it's a SALES ORDER, then return
an error if there are no ship estimates
int shipGroups = cart.getShipGroupSize();
for (int gi = 0; gi < shipGroups; gi++) {
@@ -3832,13 +3846,15 @@ public class OrderServices {
cart.setItemShipGroupEstimate(shippingTotal, gi);
}
- // calc the sales tax
+ // calc the sales tax
CheckOutHelper coh = new CheckOutHelper(dispatcher, delegator, cart);
- try {
- coh.calcAndAddTax();
- } catch (GeneralException e) {
- Debug.logError(e, module);
- throw new GeneralException(e.getMessage());
+ if (calcTax) {
+ try {
+ coh.calcAndAddTax();
+ } catch (GeneralException e) {
+ Debug.logError(e, module);
+ throw new GeneralException(e.getMessage());
+ }
}
// get the new orderItems, adjustments, shipping info, payments and
order item atrributes from the cart
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=1026520&r1=1026519&r2=1026520&view=diff
==============================================================================
---
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
(original)
+++
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
Fri Oct 22 22:43:27 2010
@@ -201,6 +201,7 @@ public class ShoppingCartServices {
cart.setOrderName(orderHeader.getString("orderName"));
cart.setOrderStatusId(orderHeader.getString("statusId"));
cart.setOrderStatusString(currentStatusString);
+ cart.setFacilityId(orderHeader.getString("originFacilityId"));
try {
cart.setUserLogin(userLogin, dispatcher);