svn commit: r1787133 - /ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1787133 - /ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java

jleroux@apache.org
Author: jleroux
Date: Thu Mar 16 07:16:40 2017
New Revision: 1787133

URL: http://svn.apache.org/viewvc?rev=1787133&view=rev
Log:
Fixed: While re-ordering an order, order terms doesn't set
(OFBIZ-9252)

Place an order and click on create as new order button on order detail page.
All the information is properly copied over to that order but order terms are
not copied to newly created order.
Order Terms should be copied while creating cart object.


Thanks: Suraj Khurana

Modified:
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java

Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=1787133&r1=1787132&r2=1787133&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java Thu Mar 16 07:16:40 2017
@@ -167,6 +167,7 @@ public class ShoppingCartServices {
         Locale locale = (Locale) context.get("locale");
         //FIXME: deepak:Personally I don't like the idea of passing flag but for orderItem quantity calculation we need this flag.
         String createAsNewOrder = (String) context.get("createAsNewOrder");
+        List<GenericValue>orderTerms = null;
 
         if (UtilValidate.isEmpty(skipInventoryChecks)) {
             skipInventoryChecks = Boolean.FALSE;
@@ -179,6 +180,7 @@ public class ShoppingCartServices {
         GenericValue orderHeader = null;
         try {
             orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne();
+            orderTerms = orderHeader.getRelated("OrderTerm", null, null, false);
         } catch (GenericEntityException e) {
             Debug.logError(e, module);
             return ServiceUtil.returnError(e.getMessage());
@@ -304,6 +306,21 @@ public class ShoppingCartServices {
         } else {
             Debug.logInfo("No payment preferences found for order #" + orderId, module);
         }
+        // set the order term
+        if (UtilValidate.isNotEmpty(orderTerms)) {
+            for (GenericValue orderTerm : orderTerms) {
+                BigDecimal termValue = BigDecimal.ZERO;
+                if (UtilValidate.isNotEmpty(orderTerm.getString("termValue"))){
+                    termValue = new BigDecimal(orderTerm.getString("termValue"));
+                }
+                long termDays = 0;
+                if (UtilValidate.isNotEmpty(orderTerm.getString("termDays"))) {
+                    termDays = Long.parseLong(orderTerm.getString("termDays").trim());
+                }
+                String orderItemSeqId = orderTerm.getString("orderItemSeqId");
+                cart.addOrderTerm(orderTerm.getString("termTypeId"), orderItemSeqId, termValue, termDays, orderTerm.getString("textValue"), orderTerm.getString("description"));
+            }
+        }
 
         List<GenericValue> orderItemShipGroupList = orh.getOrderItemShipGroups();
         for (GenericValue orderItemShipGroup: orderItemShipGroupList) {