You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2017/03/16 07:27:56 UTC

svn commit: r1787136 - in /ofbiz/branches: release14.12/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java release15.12/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java

Author: jleroux
Date: Thu Mar 16 07:27:56 2017
New Revision: 1787136

URL: http://svn.apache.org/viewvc?rev=1787136&view=rev
Log:
"Applied fix from trunk framework for revision: 1787133  " 
(Tree conflicts handled by hand)
------------------------------------------------------------------------
r1787133 | jleroux | 2017-03-16 08:16:40 +0100 (jeu. 16 mars 2017) | 10 lignes

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/branches/release14.12/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
    ofbiz/branches/release15.12/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java

Modified: ofbiz/branches/release14.12/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=1787136&r1=1787135&r2=1787136&view=diff
==============================================================================
--- ofbiz/branches/release14.12/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java (original)
+++ ofbiz/branches/release14.12/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java Thu Mar 16 07:27:56 2017
@@ -170,6 +170,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;
@@ -182,6 +183,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());
@@ -307,6 +309,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) {

Modified: ofbiz/branches/release15.12/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release15.12/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=1787136&r1=1787135&r2=1787136&view=diff
==============================================================================
--- ofbiz/branches/release15.12/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java (original)
+++ ofbiz/branches/release15.12/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java Thu Mar 16 07:27:56 2017
@@ -168,6 +168,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;
@@ -180,6 +181,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());
@@ -305,6 +307,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) {