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:22:17 UTC

svn commit: r1787135 - /ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java

Author: jleroux
Date: Thu Mar 16 07:22:17 2017
New Revision: 1787135

URL: http://svn.apache.org/viewvc?rev=1787135&view=rev
Log: (empty)

Modified:
    ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java

Modified: ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=1787135&r1=1787134&r2=1787135&view=diff
==============================================================================
--- ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java (original)
+++ ofbiz/branches/release13.07/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java Thu Mar 16 07:22:17 2017
@@ -167,6 +167,7 @@ public class ShoppingCartServices {
         Boolean skipProductChecks = (Boolean) context.get("skipProductChecks");
         boolean includePromoItems = Boolean.TRUE.equals(context.get("includePromoItems"));
         Locale locale = (Locale) context.get("locale");
+        List<GenericValue>orderTerms = null;
 
         if (UtilValidate.isEmpty(skipInventoryChecks)) {
             skipInventoryChecks = Boolean.FALSE;
@@ -179,6 +180,7 @@ public class ShoppingCartServices {
         GenericValue orderHeader = null;
         try {
             orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false);
+            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) {