Replacement of iterators with for-each loops for order component
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1305309 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
package org.ofbiz.order;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -83,11 +82,9 @@ public class OrderManagerEvents {
|
||||
return "error";
|
||||
}
|
||||
if (paymentPrefs != null) {
|
||||
Iterator<GenericValue> i = paymentPrefs.iterator();
|
||||
while (i.hasNext()) {
|
||||
for(GenericValue ppref : paymentPrefs) {
|
||||
// update the preference to received
|
||||
// TODO: updating payment preferences should be done as a service
|
||||
GenericValue ppref = i.next();
|
||||
ppref.set("statusId", "PAYMENT_RECEIVED");
|
||||
ppref.set("authDate", UtilDateTime.nowTimestamp());
|
||||
toBeStored.add(ppref);
|
||||
@@ -179,9 +176,7 @@ public class OrderManagerEvents {
|
||||
return "error";
|
||||
}
|
||||
|
||||
Iterator<GenericValue> pmti = paymentMethodTypes.iterator();
|
||||
while (pmti.hasNext()) {
|
||||
GenericValue paymentMethodType = pmti.next();
|
||||
for(GenericValue paymentMethodType : paymentMethodTypes) {
|
||||
String paymentMethodTypeId = paymentMethodType.getString("paymentMethodTypeId");
|
||||
String amountStr = request.getParameter(paymentMethodTypeId + "_amount");
|
||||
String paymentReference = request.getParameter(paymentMethodTypeId + "_reference");
|
||||
@@ -251,9 +246,7 @@ public class OrderManagerEvents {
|
||||
Debug.logError(e, "ERROR: Unable to get existing payment preferences from order", module);
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(currentPrefs)) {
|
||||
Iterator<GenericValue> cpi = currentPrefs.iterator();
|
||||
while (cpi.hasNext()) {
|
||||
GenericValue cp = cpi.next();
|
||||
for(GenericValue cp : currentPrefs) {
|
||||
String paymentMethodType = cp.getString("paymentMethodTypeId");
|
||||
if ("EXT_OFFLINE".equals(paymentMethodType)) {
|
||||
offlineValue = cp;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*******************************************************************************/
|
||||
package org.ofbiz.order.order;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -185,9 +184,7 @@ public class OrderChangeHelper {
|
||||
Debug.logError(e, "ERROR: Unable to get OrderItem records for OrderHeader : " + orderId, module);
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(orderItems)) {
|
||||
Iterator<GenericValue> oii = orderItems.iterator();
|
||||
while (oii.hasNext()) {
|
||||
GenericValue orderItem = oii.next();
|
||||
for(GenericValue orderItem : orderItems) {
|
||||
String orderItemSeqId = orderItem.getString("orderItemSeqId");
|
||||
GenericValue product = null;
|
||||
|
||||
@@ -264,9 +261,7 @@ public class OrderChangeHelper {
|
||||
}
|
||||
|
||||
List<GenericValue> opps = orh.getPaymentPreferences();
|
||||
Iterator<GenericValue> oppi = opps.iterator();
|
||||
while (oppi.hasNext()) {
|
||||
GenericValue opp = oppi.next();
|
||||
for(GenericValue opp : opps) {
|
||||
if ("PAYMENT_RECEIVED".equals(opp.getString("statusId"))) {
|
||||
List<GenericValue> payments = orh.getOrderPayments(opp);
|
||||
if (UtilValidate.isEmpty(payments)) {
|
||||
|
||||
@@ -167,8 +167,7 @@ public class OrderListState implements Serializable {
|
||||
}
|
||||
|
||||
private void changeOrderListStates(HttpServletRequest request) {
|
||||
for (Iterator<String> iter = parameterToOrderStatusId.keySet().iterator(); iter.hasNext();) {
|
||||
String param = iter.next();
|
||||
for(String param : parameterToOrderStatusId.keySet()) {
|
||||
String value = request.getParameter(param);
|
||||
if ("Y".equals(value)) {
|
||||
orderStatusState.put(param, "Y");
|
||||
@@ -176,8 +175,7 @@ public class OrderListState implements Serializable {
|
||||
orderStatusState.put(param, "N");
|
||||
}
|
||||
}
|
||||
for (Iterator<String> iter = parameterToOrderTypeId.keySet().iterator(); iter.hasNext();) {
|
||||
String param = iter.next();
|
||||
for(String param : parameterToOrderTypeId.keySet()) {
|
||||
String value = request.getParameter(param);
|
||||
if ("Y".equals(value)) {
|
||||
orderTypeState.put(param, "Y");
|
||||
@@ -185,8 +183,7 @@ public class OrderListState implements Serializable {
|
||||
orderTypeState.put(param, "N");
|
||||
}
|
||||
}
|
||||
for (Iterator<String> iter = parameterToFilterId.keySet().iterator(); iter.hasNext();) {
|
||||
String param = iter.next();
|
||||
for(String param : parameterToFilterId.keySet()) {
|
||||
String value = request.getParameter(param);
|
||||
if ("Y".equals(value)) {
|
||||
orderFilterState.put(param, "Y");
|
||||
@@ -244,14 +241,12 @@ public class OrderListState implements Serializable {
|
||||
}
|
||||
|
||||
List<EntityCondition> statusConditions = FastList.newInstance();
|
||||
for (Iterator<String> iter = orderStatusState.keySet().iterator(); iter.hasNext();) {
|
||||
String status = iter.next();
|
||||
for(String status : orderFilterState.keySet()) {
|
||||
if (!hasStatus(status)) continue;
|
||||
statusConditions.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, parameterToOrderStatusId.get(status)));
|
||||
}
|
||||
List<EntityCondition> typeConditions = FastList.newInstance();
|
||||
for (Iterator<String> iter = orderTypeState.keySet().iterator(); iter.hasNext();) {
|
||||
String type = iter.next();
|
||||
for(String type : orderTypeState.keySet()) {
|
||||
if (!hasType(type)) continue;
|
||||
typeConditions.add(EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, parameterToOrderTypeId.get(type)));
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package org.ofbiz.order.order;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -115,10 +114,8 @@ public class OrderLookupServices {
|
||||
// the base order header fields
|
||||
List<String> orderTypeList = UtilGenerics.checkList(context.get("orderTypeId"));
|
||||
if (orderTypeList != null) {
|
||||
Iterator<String> i = orderTypeList.iterator();
|
||||
List<EntityExpr> orExprs = FastList.newInstance();
|
||||
while (i.hasNext()) {
|
||||
String orderTypeId = i.next();
|
||||
for(String orderTypeId : orderTypeList) {
|
||||
paramList.add("orderTypeId=" + orderTypeId);
|
||||
|
||||
if (!"PURCHASE_ORDER".equals(orderTypeId) || ("PURCHASE_ORDER".equals(orderTypeId) && canViewPo)) {
|
||||
@@ -136,10 +133,8 @@ public class OrderLookupServices {
|
||||
|
||||
List<String> orderStatusList = UtilGenerics.checkList(context.get("orderStatusId"));
|
||||
if (orderStatusList != null) {
|
||||
Iterator<String> i = orderStatusList.iterator();
|
||||
List<EntityCondition> orExprs = FastList.newInstance();
|
||||
while (i.hasNext()) {
|
||||
String orderStatusId = i.next();
|
||||
for(String orderStatusId : orderStatusList) {
|
||||
paramList.add("orderStatusId=" + orderStatusId);
|
||||
if ("PENDING".equals(orderStatusId)) {
|
||||
List<EntityExpr> pendExprs = FastList.newInstance();
|
||||
@@ -156,10 +151,8 @@ public class OrderLookupServices {
|
||||
|
||||
List<String> productStoreList = UtilGenerics.checkList(context.get("productStoreId"));
|
||||
if (productStoreList != null) {
|
||||
Iterator<String> i = productStoreList.iterator();
|
||||
List<EntityExpr> orExprs = FastList.newInstance();
|
||||
while (i.hasNext()) {
|
||||
String productStoreId = i.next();
|
||||
for(String productStoreId : productStoreList) {
|
||||
paramList.add("productStoreId=" + productStoreId);
|
||||
orExprs.add(EntityCondition.makeCondition("productStoreId", EntityOperator.EQUALS, productStoreId));
|
||||
}
|
||||
@@ -168,10 +161,8 @@ public class OrderLookupServices {
|
||||
|
||||
List<String> webSiteList = UtilGenerics.checkList(context.get("orderWebSiteId"));
|
||||
if (webSiteList != null) {
|
||||
Iterator<String> i = webSiteList.iterator();
|
||||
List<EntityExpr> orExprs = FastList.newInstance();
|
||||
while (i.hasNext()) {
|
||||
String webSiteId = i.next();
|
||||
for(String webSiteId : webSiteList) {
|
||||
paramList.add("webSiteId=" + webSiteId);
|
||||
orExprs.add(EntityCondition.makeCondition("webSiteId", EntityOperator.EQUALS, webSiteId));
|
||||
}
|
||||
@@ -180,10 +171,8 @@ public class OrderLookupServices {
|
||||
|
||||
List<String> saleChannelList = UtilGenerics.checkList(context.get("salesChannelEnumId"));
|
||||
if (saleChannelList != null) {
|
||||
Iterator<String> i = saleChannelList.iterator();
|
||||
List<EntityExpr> orExprs = FastList.newInstance();
|
||||
while (i.hasNext()) {
|
||||
String salesChannelEnumId = i.next();
|
||||
for(String salesChannelEnumId : saleChannelList) {
|
||||
paramList.add("salesChannelEnumId=" + salesChannelEnumId);
|
||||
orExprs.add(EntityCondition.makeCondition("salesChannelEnumId", EntityOperator.EQUALS, salesChannelEnumId));
|
||||
}
|
||||
@@ -335,10 +324,8 @@ public class OrderLookupServices {
|
||||
|
||||
if (roleTypeList != null) {
|
||||
fieldsToSelect.add("roleTypeId");
|
||||
Iterator<String> i = roleTypeList.iterator();
|
||||
List<EntityExpr> orExprs = FastList.newInstance();
|
||||
while (i.hasNext()) {
|
||||
String roleTypeId = i.next();
|
||||
for(String roleTypeId : roleTypeList) {
|
||||
paramList.add("roleTypeId=" + roleTypeId);
|
||||
orExprs.add(makeExpr("roleTypeId", roleTypeId));
|
||||
}
|
||||
@@ -397,9 +384,7 @@ public class OrderLookupServices {
|
||||
}
|
||||
List<GenericValue> variants = UtilGenerics.checkList(varLookup.get("assocProducts"));
|
||||
if (variants != null) {
|
||||
Iterator<GenericValue> i = variants.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue v = i.next();
|
||||
for(GenericValue v : variants) {
|
||||
orExprs.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, v.getString("productIdTo")));
|
||||
}
|
||||
}
|
||||
@@ -639,9 +624,7 @@ public class OrderLookupServices {
|
||||
|
||||
if ("Y".equals(doFilter) && orderList.size() > 0) {
|
||||
paramList.add("filterInventoryProblems=Y");
|
||||
Iterator<GenericValue> i = orderList.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue orderHeader = i.next();
|
||||
for(GenericValue orderHeader : orderList) {
|
||||
OrderReadHelper orh = new OrderReadHelper(orderHeader);
|
||||
BigDecimal backorderQty = orh.getOrderBackorderQuantity();
|
||||
if (backorderQty.compareTo(BigDecimal.ZERO) == 1) {
|
||||
@@ -682,9 +665,7 @@ public class OrderLookupServices {
|
||||
}
|
||||
|
||||
if (doPoFilter && orderList.size() > 0) {
|
||||
Iterator<GenericValue> i = orderList.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue orderHeader = i.next();
|
||||
for(GenericValue orderHeader : orderList) {
|
||||
OrderReadHelper orh = new OrderReadHelper(orderHeader);
|
||||
String orderType = orh.getOrderTypeId();
|
||||
String orderId = orh.getOrderId();
|
||||
|
||||
@@ -214,9 +214,7 @@ public class OrderReadHelper {
|
||||
public Map<String, BigDecimal> getReceivedPaymentTotalsByPaymentMethod() {
|
||||
Map<String, BigDecimal> paymentMethodAmounts = FastMap.newInstance();
|
||||
List<GenericValue> paymentPrefs = getPaymentPreferences();
|
||||
Iterator<GenericValue> ppit = paymentPrefs.iterator();
|
||||
while (ppit.hasNext()) {
|
||||
GenericValue paymentPref = ppit.next();
|
||||
for(GenericValue paymentPref : paymentPrefs) {
|
||||
List<GenericValue> payments = FastList.newInstance();
|
||||
try {
|
||||
List<EntityExpr> exprs = UtilMisc.toList(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "PMNT_RECEIVED"),
|
||||
@@ -234,9 +232,7 @@ public class OrderReadHelper {
|
||||
}
|
||||
|
||||
BigDecimal chargedToPaymentPref = ZERO;
|
||||
Iterator<GenericValue> payit = payments.iterator();
|
||||
while (payit.hasNext()) {
|
||||
GenericValue payment = payit.next();
|
||||
for(GenericValue payment : payments) {
|
||||
if (payment.get("amount") != null) {
|
||||
chargedToPaymentPref = chargedToPaymentPref.add(payment.getBigDecimal("amount")).setScale(scale+1, rounding);
|
||||
}
|
||||
@@ -263,9 +259,7 @@ public class OrderReadHelper {
|
||||
public Map<String, BigDecimal> getReturnedTotalsByPaymentMethod() {
|
||||
Map<String, BigDecimal> paymentMethodAmounts = FastMap.newInstance();
|
||||
List<GenericValue> paymentPrefs = getPaymentPreferences();
|
||||
Iterator<GenericValue> ppit = paymentPrefs.iterator();
|
||||
while (ppit.hasNext()) {
|
||||
GenericValue paymentPref = ppit.next();
|
||||
for(GenericValue paymentPref : paymentPrefs) {
|
||||
List<GenericValue> returnItemResponses = FastList.newInstance();
|
||||
try {
|
||||
returnItemResponses = orderHeader.getDelegator().findByAnd("ReturnItemResponse", UtilMisc.toMap("orderPaymentPreferenceId", paymentPref.getString("orderPaymentPreferenceId")));
|
||||
@@ -273,9 +267,7 @@ public class OrderReadHelper {
|
||||
Debug.logError(e, module);
|
||||
}
|
||||
BigDecimal refundedToPaymentPref = ZERO;
|
||||
Iterator<GenericValue> ririt = returnItemResponses.iterator();
|
||||
while (ririt.hasNext()) {
|
||||
GenericValue returnItemResponse = ririt.next();
|
||||
for(GenericValue returnItemResponse : returnItemResponses) {
|
||||
refundedToPaymentPref = refundedToPaymentPref.add(returnItemResponse.getBigDecimal("responseAmount")).setScale(scale+1, rounding);
|
||||
}
|
||||
|
||||
@@ -302,9 +294,7 @@ public class OrderReadHelper {
|
||||
prefs = UtilMisc.toList(orderPaymentPreference);
|
||||
}
|
||||
if (prefs != null) {
|
||||
Iterator<GenericValue> i = prefs.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue payPref = i.next();
|
||||
for(GenericValue payPref : prefs) {
|
||||
try {
|
||||
orderPayments.addAll(payPref.getRelated("Payment"));
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -405,9 +395,7 @@ public class OrderReadHelper {
|
||||
}
|
||||
|
||||
public boolean hasPhysicalProductItems() throws GenericEntityException {
|
||||
Iterator<GenericValue> orderItemIter = this.getOrderItems().iterator();
|
||||
while (orderItemIter.hasNext()) {
|
||||
GenericValue orderItem = orderItemIter.next();
|
||||
for(GenericValue orderItem : this.getOrderItems()) {
|
||||
GenericValue product = orderItem.getRelatedOneCache("Product");
|
||||
if (product != null) {
|
||||
GenericValue productType = product.getRelatedOneCache("ProductType");
|
||||
@@ -442,9 +430,7 @@ public class OrderReadHelper {
|
||||
List<GenericValue> shippingLocations = FastList.newInstance();
|
||||
List<GenericValue> shippingCms = this.getOrderContactMechs("SHIPPING_LOCATION");
|
||||
if (shippingCms != null) {
|
||||
Iterator<GenericValue> i = shippingCms.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue ocm = i.next();
|
||||
for(GenericValue ocm : shippingCms) {
|
||||
if (ocm != null) {
|
||||
try {
|
||||
GenericValue addr = ocm.getDelegator().findByPrimaryKey("PostalAddress",
|
||||
@@ -500,9 +486,7 @@ public class OrderReadHelper {
|
||||
List<GenericValue> billingLocations = FastList.newInstance();
|
||||
List<GenericValue> billingCms = this.getOrderContactMechs("BILLING_LOCATION");
|
||||
if (billingCms != null) {
|
||||
Iterator<GenericValue> i = billingCms.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue ocm = i.next();
|
||||
for(GenericValue ocm : billingCms) {
|
||||
if (ocm != null) {
|
||||
try {
|
||||
GenericValue addr = ocm.getDelegator().findByPrimaryKey("PostalAddress",
|
||||
@@ -807,9 +791,7 @@ public class OrderReadHelper {
|
||||
Debug.logError(e, "Unable to get ProductFeatureAppl for item : " + item, module);
|
||||
}
|
||||
if (featureAppls != null) {
|
||||
Iterator<GenericValue> fai = featureAppls.iterator();
|
||||
while (fai.hasNext()) {
|
||||
GenericValue appl = fai.next();
|
||||
for(GenericValue appl : featureAppls) {
|
||||
featureSet.add(appl.getString("productFeatureId"));
|
||||
}
|
||||
}
|
||||
@@ -823,9 +805,7 @@ public class OrderReadHelper {
|
||||
Debug.logError(e, "Unable to get OrderAdjustment from item : " + item, module);
|
||||
}
|
||||
if (additionalFeatures != null) {
|
||||
Iterator<GenericValue> afi = additionalFeatures.iterator();
|
||||
while (afi.hasNext()) {
|
||||
GenericValue adj = afi.next();
|
||||
for(GenericValue adj : additionalFeatures) {
|
||||
String featureId = adj.getString("productFeatureId");
|
||||
if (featureId != null) {
|
||||
featureSet.add(featureId);
|
||||
@@ -840,9 +820,7 @@ public class OrderReadHelper {
|
||||
Map<String, BigDecimal> featureMap = FastMap.newInstance();
|
||||
List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
|
||||
if (validItems != null) {
|
||||
Iterator<GenericValue> i = validItems.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue item = i.next();
|
||||
for(GenericValue item : validItems) {
|
||||
List<GenericValue> featureAppls = null;
|
||||
if (item.get("productId") != null) {
|
||||
try {
|
||||
@@ -854,9 +832,7 @@ public class OrderReadHelper {
|
||||
Debug.logError(e, "Unable to get ProductFeatureAppl for item : " + item, module);
|
||||
}
|
||||
if (featureAppls != null) {
|
||||
Iterator<GenericValue> fai = featureAppls.iterator();
|
||||
while (fai.hasNext()) {
|
||||
GenericValue appl = fai.next();
|
||||
for(GenericValue appl : featureAppls) {
|
||||
BigDecimal lastQuantity = featureMap.get(appl.getString("productFeatureId"));
|
||||
if (lastQuantity == null) {
|
||||
lastQuantity = BigDecimal.ZERO;
|
||||
@@ -875,9 +851,7 @@ public class OrderReadHelper {
|
||||
Debug.logError(e, "Unable to get OrderAdjustment from item : " + item, module);
|
||||
}
|
||||
if (additionalFeatures != null) {
|
||||
Iterator<GenericValue> afi = additionalFeatures.iterator();
|
||||
while (afi.hasNext()) {
|
||||
GenericValue adj = afi.next();
|
||||
for(GenericValue adj : additionalFeatures) {
|
||||
String featureId = adj.getString("productFeatureId");
|
||||
if (featureId != null) {
|
||||
BigDecimal lastQuantity = featureMap.get(featureId);
|
||||
@@ -899,9 +873,7 @@ public class OrderReadHelper {
|
||||
boolean shippingApplies = false;
|
||||
List<GenericValue> validItems = this.getValidOrderItems();
|
||||
if (validItems != null) {
|
||||
Iterator<GenericValue> i = validItems.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue item = i.next();
|
||||
for(GenericValue item : validItems) {
|
||||
GenericValue product = null;
|
||||
try {
|
||||
product = item.getRelatedOne("Product");
|
||||
@@ -923,9 +895,7 @@ public class OrderReadHelper {
|
||||
boolean taxApplies = false;
|
||||
List<GenericValue> validItems = this.getValidOrderItems();
|
||||
if (validItems != null) {
|
||||
Iterator<GenericValue> i = validItems.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue item = i.next();
|
||||
for(GenericValue item : validItems) {
|
||||
GenericValue product = null;
|
||||
try {
|
||||
product = item.getRelatedOne("Product");
|
||||
@@ -947,9 +917,7 @@ public class OrderReadHelper {
|
||||
BigDecimal shippableTotal = ZERO;
|
||||
List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
|
||||
if (validItems != null) {
|
||||
Iterator<GenericValue> i = validItems.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue item = i.next();
|
||||
for(GenericValue item : validItems) {
|
||||
GenericValue product = null;
|
||||
try {
|
||||
product = item.getRelatedOne("Product");
|
||||
@@ -971,9 +939,7 @@ public class OrderReadHelper {
|
||||
BigDecimal shippableQuantity = ZERO;
|
||||
List<GenericValue> shipGroups = getOrderItemShipGroups();
|
||||
if (UtilValidate.isNotEmpty(shipGroups)) {
|
||||
Iterator<GenericValue> shipGroupsIt = shipGroups.iterator();
|
||||
while (shipGroupsIt.hasNext()) {
|
||||
GenericValue shipGroup = shipGroupsIt.next();
|
||||
for(GenericValue shipGroup : shipGroups) {
|
||||
shippableQuantity = shippableQuantity.add(getShippableQuantity(shipGroup.getString("shipGroupSeqId")));
|
||||
}
|
||||
}
|
||||
@@ -984,9 +950,7 @@ public class OrderReadHelper {
|
||||
BigDecimal shippableQuantity = ZERO;
|
||||
List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
|
||||
if (validItems != null) {
|
||||
Iterator<GenericValue> i = validItems.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue item = i.next();
|
||||
for(GenericValue item : validItems) {
|
||||
GenericValue product = null;
|
||||
try {
|
||||
product = item.getRelatedOne("Product");
|
||||
@@ -1008,9 +972,7 @@ public class OrderReadHelper {
|
||||
BigDecimal shippableWeight = ZERO;
|
||||
List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
|
||||
if (validItems != null) {
|
||||
Iterator<GenericValue> i = validItems.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue item = i.next();
|
||||
for(GenericValue item : validItems) {
|
||||
shippableWeight = shippableWeight.add(this.getItemWeight(item).multiply(getOrderItemQuantity(item))).setScale(scale, rounding);
|
||||
}
|
||||
}
|
||||
@@ -1062,9 +1024,7 @@ public class OrderReadHelper {
|
||||
|
||||
List<GenericValue> validItems = getValidOrderItems();
|
||||
if (validItems != null) {
|
||||
Iterator<GenericValue> i = validItems.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue item = i.next();
|
||||
for(GenericValue item : validItems) {
|
||||
shippableSizes.add(this.getItemSize(item));
|
||||
}
|
||||
}
|
||||
@@ -1077,8 +1037,7 @@ public class OrderReadHelper {
|
||||
*/
|
||||
public BigDecimal getOrderPaymentPreferenceTotalByType(String paymentMethodTypeId) {
|
||||
BigDecimal total = ZERO;
|
||||
for (Iterator<GenericValue> iter = getPaymentPreferences().iterator(); iter.hasNext();) {
|
||||
GenericValue preference = iter.next();
|
||||
for(GenericValue preference : getPaymentPreferences()) {
|
||||
if (preference.get("maxAmount") == null) continue;
|
||||
if (paymentMethodTypeId == null || paymentMethodTypeId.equals(preference.get("paymentMethodTypeId"))) {
|
||||
total = total.add(preference.getBigDecimal("maxAmount")).setScale(scale, rounding);
|
||||
@@ -1111,8 +1070,7 @@ public class OrderReadHelper {
|
||||
// get a set of invoice IDs that belong to the order
|
||||
List<GenericValue> orderItemBillings = orderHeader.getRelatedCache("OrderItemBilling");
|
||||
Set<String> invoiceIds = new HashSet<String>();
|
||||
for (Iterator<GenericValue> iter = orderItemBillings.iterator(); iter.hasNext();) {
|
||||
GenericValue orderItemBilling = iter.next();
|
||||
for(GenericValue orderItemBilling : orderItemBillings) {
|
||||
invoiceIds.add(orderItemBilling.getString("invoiceId"));
|
||||
}
|
||||
|
||||
@@ -1126,8 +1084,7 @@ public class OrderReadHelper {
|
||||
EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(conditions, EntityOperator.AND);
|
||||
List<GenericValue> payments = orderHeader.getDelegator().findList("PaymentAndApplication", ecl, null, null, null, true);
|
||||
|
||||
for (Iterator<GenericValue> iter = payments.iterator(); iter.hasNext();) {
|
||||
GenericValue payment = iter.next();
|
||||
for (GenericValue payment : payments) {
|
||||
if (payment.get("amountApplied") == null) continue;
|
||||
total = total.add(payment.getBigDecimal("amountApplied")).setScale(scale, rounding);
|
||||
}
|
||||
@@ -1235,9 +1192,7 @@ public class OrderReadHelper {
|
||||
|
||||
List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
|
||||
if (validItems != null) {
|
||||
Iterator<GenericValue> i = validItems.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue item = i.next();
|
||||
for(GenericValue item : validItems) {
|
||||
shippableInfo.add(this.getItemInfoMap(item));
|
||||
}
|
||||
}
|
||||
@@ -1269,10 +1224,8 @@ public class OrderReadHelper {
|
||||
|
||||
StringBuilder emails = new StringBuilder();
|
||||
if (orderContactMechs != null) {
|
||||
Iterator<GenericValue> oci = orderContactMechs.iterator();
|
||||
while (oci.hasNext()) {
|
||||
for(GenericValue orderContactMech : orderContactMechs) {
|
||||
try {
|
||||
GenericValue orderContactMech = oci.next();
|
||||
GenericValue contactMech = orderContactMech.getRelatedOne("ContactMech");
|
||||
emails.append(emails.length() > 0 ? "," : "").append(contactMech.getString("infoString"));
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -1301,22 +1254,19 @@ public class OrderReadHelper {
|
||||
List<GenericValue> prefs = getPaymentPreferences();
|
||||
|
||||
// add up the covered amount, but skip preferences which are declined or cancelled
|
||||
for (Iterator<GenericValue> iter = prefs.iterator(); iter.hasNext();) {
|
||||
GenericValue pref = iter.next();
|
||||
for(GenericValue pref : prefs) {
|
||||
if ("PAYMENT_CANCELLED".equals(pref.get("statusId")) || "PAYMENT_DECLINED".equals(pref.get("statusId"))) {
|
||||
continue;
|
||||
} else if ("PAYMENT_SETTLED".equals(pref.get("statusId"))) {
|
||||
List<GenericValue> responses = pref.getRelatedByAnd("PaymentGatewayResponse", UtilMisc.toMap("transCodeEnumId", "PGT_CAPTURE"));
|
||||
for (Iterator<GenericValue> respIter = responses.iterator(); respIter.hasNext();) {
|
||||
GenericValue response = respIter.next();
|
||||
for(GenericValue response : responses) {
|
||||
BigDecimal amount = response.getBigDecimal("amount");
|
||||
if (amount != null) {
|
||||
openAmount = openAmount.add(amount);
|
||||
}
|
||||
}
|
||||
responses = pref.getRelatedByAnd("PaymentGatewayResponse", UtilMisc.toMap("transCodeEnumId", "PGT_REFUND"));
|
||||
for (Iterator<GenericValue> respIter = responses.iterator(); respIter.hasNext();) {
|
||||
GenericValue response = respIter.next();
|
||||
for(GenericValue response : responses) {
|
||||
BigDecimal amount = response.getBigDecimal("amount");
|
||||
if (amount != null) {
|
||||
openAmount = openAmount.subtract(amount);
|
||||
@@ -1449,9 +1399,7 @@ public class OrderReadHelper {
|
||||
|
||||
public boolean getRejectedOrderItems() {
|
||||
List<GenericValue> items = getOrderItems();
|
||||
Iterator<GenericValue> i = items.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue item = i.next();
|
||||
for(GenericValue item : items) {
|
||||
List<GenericValue> receipts = null;
|
||||
try {
|
||||
receipts = item.getRelated("ShipmentReceipt");
|
||||
@@ -1459,9 +1407,7 @@ public class OrderReadHelper {
|
||||
Debug.logWarning(e, module);
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(receipts)) {
|
||||
Iterator<GenericValue> recIter = receipts.iterator();
|
||||
while (recIter.hasNext()) {
|
||||
GenericValue rec = recIter.next();
|
||||
for(GenericValue rec : receipts) {
|
||||
BigDecimal rejected = rec.getBigDecimal("quantityRejected");
|
||||
if (rejected != null && rejected.compareTo(BigDecimal.ZERO) > 0) {
|
||||
return true;
|
||||
@@ -1487,9 +1433,7 @@ public class OrderReadHelper {
|
||||
return false;
|
||||
}*/
|
||||
List<GenericValue> items = getOrderItems();
|
||||
Iterator<GenericValue> i = items.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue item = i.next();
|
||||
for(GenericValue item : items) {
|
||||
List<GenericValue> receipts = null;
|
||||
try {
|
||||
receipts = item.getRelated("ShipmentReceipt");
|
||||
@@ -1497,9 +1441,7 @@ public class OrderReadHelper {
|
||||
Debug.logWarning(e, module);
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(receipts)) {
|
||||
Iterator<GenericValue> recIter = receipts.iterator();
|
||||
while (recIter.hasNext()) {
|
||||
GenericValue rec = recIter.next();
|
||||
for(GenericValue rec : receipts) {
|
||||
BigDecimal acceptedQuantity = rec.getBigDecimal("quantityAccepted");
|
||||
BigDecimal orderedQuantity = (BigDecimal) item.get("quantity");
|
||||
if (acceptedQuantity.intValue() != orderedQuantity.intValue() && acceptedQuantity.intValue() > 0) {
|
||||
@@ -1532,9 +1474,7 @@ public class OrderReadHelper {
|
||||
EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "ITEM_APPROVED"),
|
||||
EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "ITEM_COMPLETED"));
|
||||
List<GenericValue> items = EntityUtil.filterByOr(getOrderItems(), exprs);
|
||||
Iterator<GenericValue> i = items.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue item = i.next();
|
||||
for(GenericValue item : items) {
|
||||
if (item.get("productId") != null) {
|
||||
GenericValue product = null;
|
||||
try {
|
||||
@@ -1580,9 +1520,7 @@ public class OrderReadHelper {
|
||||
|
||||
if (UtilValidate.isNotEmpty(productContents)) {
|
||||
// make sure we are still within the allowed timeframe and use limits
|
||||
Iterator<GenericValue> pci = productContents.iterator();
|
||||
while (pci.hasNext()) {
|
||||
GenericValue productContent = pci.next();
|
||||
for(GenericValue productContent : productContents) {
|
||||
Timestamp fromDate = productContent.getTimestamp("purchaseFromDate");
|
||||
Timestamp thruDate = productContent.getTimestamp("purchaseThruDate");
|
||||
if (fromDate == null || item.getTimestamp("orderDate").after(fromDate)) {
|
||||
@@ -1742,8 +1680,7 @@ public class OrderReadHelper {
|
||||
|
||||
// since we don't have a handy grouped view entity, we'll have to group the return items by hand
|
||||
Map<String, BigDecimal> returnMap = FastMap.newInstance();
|
||||
for (Iterator<GenericValue> iter = this.getValidOrderItems().iterator(); iter.hasNext();) {
|
||||
GenericValue orderItem = iter.next();
|
||||
for(GenericValue orderItem : this.getValidOrderItems()) {
|
||||
List<GenericValue> group = EntityUtil.filterByAnd(returnItems, UtilMisc.toList(
|
||||
EntityCondition.makeCondition("orderId", orderItem.get("orderId")),
|
||||
EntityCondition.makeCondition("orderItemSeqId", orderItem.get("orderItemSeqId")),
|
||||
@@ -1751,8 +1688,7 @@ public class OrderReadHelper {
|
||||
|
||||
// add up the returned quantities for this group TODO: received quantity should be used eventually
|
||||
BigDecimal returned = BigDecimal.ZERO;
|
||||
for (Iterator<GenericValue> groupiter = group.iterator(); groupiter.hasNext();) {
|
||||
GenericValue returnItem = groupiter.next();
|
||||
for(GenericValue returnItem : group) {
|
||||
if (returnItem.getBigDecimal("returnQuantity") != null) {
|
||||
returned = returned.add(returnItem.getBigDecimal("returnQuantity"));
|
||||
}
|
||||
@@ -1788,9 +1724,7 @@ public class OrderReadHelper {
|
||||
returnedItems.addAll(EntityUtil.filterByAnd(returnedItemsBase, UtilMisc.toMap("statusId", "RETURN_COMPLETED")));
|
||||
|
||||
BigDecimal returnedQuantity = ZERO;
|
||||
Iterator<GenericValue> i = returnedItems.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue returnedItem = i.next();
|
||||
for(GenericValue returnedItem : returnedItems) {
|
||||
if (returnedItem.get("returnQuantity") != null) {
|
||||
returnedQuantity = returnedQuantity.add(returnedItem.getBigDecimal("returnQuantity")).setScale(scale, rounding);
|
||||
}
|
||||
@@ -1821,11 +1755,9 @@ public class OrderReadHelper {
|
||||
UtilMisc.toList(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "RETURN_CANCELLED"))));
|
||||
}
|
||||
BigDecimal returnedAmount = ZERO;
|
||||
Iterator<GenericValue> i = returnedItems.iterator();
|
||||
String orderId = orderHeader.getString("orderId");
|
||||
List<String> returnHeaderList = FastList.newInstance();
|
||||
while (i.hasNext()) {
|
||||
GenericValue returnedItem = i.next();
|
||||
for(GenericValue returnedItem : returnedItems) {
|
||||
if ((returnedItem.get("returnPrice") != null) && (returnedItem.get("returnQuantity") != null)) {
|
||||
returnedAmount = returnedAmount.add(returnedItem.getBigDecimal("returnPrice").multiply(returnedItem.getBigDecimal("returnQuantity")).setScale(scale, rounding));
|
||||
}
|
||||
@@ -1836,9 +1768,7 @@ public class OrderReadHelper {
|
||||
}
|
||||
}
|
||||
//get returnedAmount from returnHeader adjustments whose orderId must equals to current orderHeader.orderId
|
||||
Iterator<String> returnHeaderIterator = returnHeaderList.iterator();
|
||||
while (returnHeaderIterator.hasNext()) {
|
||||
String returnId = returnHeaderIterator.next();
|
||||
for(String returnId : returnHeaderList) {
|
||||
Map<String, Object> returnHeaderAdjFilter = UtilMisc.<String, Object>toMap("returnId", returnId, "returnItemSeqId", "_NA_", "returnTypeId", returnTypeId);
|
||||
returnedAmount =returnedAmount.add(getReturnAdjustmentTotal(orderHeader.getDelegator(), returnHeaderAdjFilter)).setScale(scale, rounding);
|
||||
}
|
||||
@@ -1878,9 +1808,7 @@ public class OrderReadHelper {
|
||||
returnedItems.addAll(EntityUtil.filterByAnd(returnedItemsBase, UtilMisc.toMap("statusId", "RETURN_COMPLETED")));
|
||||
|
||||
Map<String, BigDecimal> itemReturnedQuantities = FastMap.newInstance();
|
||||
Iterator<GenericValue> i = returnedItems.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue returnedItem = i.next();
|
||||
for(GenericValue returnedItem : returnedItems) {
|
||||
String orderItemSeqId = returnedItem.getString("orderItemSeqId");
|
||||
BigDecimal returnedQuantity = returnedItem.getBigDecimal("returnQuantity");
|
||||
if (orderItemSeqId != null && returnedQuantity != null) {
|
||||
@@ -1898,10 +1826,7 @@ public class OrderReadHelper {
|
||||
BigDecimal totalTaxNotReturned = ZERO;
|
||||
BigDecimal totalShippingNotReturned = ZERO;
|
||||
|
||||
Iterator<GenericValue> orderItems = this.getValidOrderItems().iterator();
|
||||
while (orderItems.hasNext()) {
|
||||
GenericValue orderItem = orderItems.next();
|
||||
|
||||
for(GenericValue orderItem : this.getValidOrderItems()) {
|
||||
BigDecimal itemQuantityDbl = orderItem.getBigDecimal("quantity");
|
||||
if (itemQuantityDbl == null || itemQuantityDbl.compareTo(ZERO) == 0) {
|
||||
continue;
|
||||
@@ -1960,8 +1885,7 @@ public class OrderReadHelper {
|
||||
|
||||
// sum up the return items that have a return item response with a billing account defined
|
||||
try {
|
||||
for (Iterator<GenericValue> iter = returnedItems.iterator(); iter.hasNext();) {
|
||||
GenericValue returnItem = iter.next();
|
||||
for(GenericValue returnItem : returnedItems) {
|
||||
GenericValue returnItemResponse = returnItem.getRelatedOne("ReturnItemResponse");
|
||||
if (returnItemResponse == null) continue;
|
||||
if (returnItemResponse.get("billingAccountId") == null) continue;
|
||||
@@ -1999,14 +1923,10 @@ public class OrderReadHelper {
|
||||
BigDecimal backorder = ZERO;
|
||||
List<GenericValue> items = this.getValidOrderItems();
|
||||
if (items != null) {
|
||||
Iterator<GenericValue> ii = items.iterator();
|
||||
while (ii.hasNext()) {
|
||||
GenericValue item = ii.next();
|
||||
for(GenericValue item : items) {
|
||||
List<GenericValue> reses = this.getOrderItemShipGrpInvResList(item);
|
||||
if (reses != null) {
|
||||
Iterator<GenericValue> ri = reses.iterator();
|
||||
while (ri.hasNext()) {
|
||||
GenericValue res = ri.next();
|
||||
for(GenericValue res : reses) {
|
||||
BigDecimal nav = res.getBigDecimal("quantityNotAvailable");
|
||||
if (nav != null) {
|
||||
backorder = backorder.add(nav).setScale(scale, rounding);
|
||||
@@ -2035,9 +1955,7 @@ public class OrderReadHelper {
|
||||
}
|
||||
|
||||
if (picked != null) {
|
||||
Iterator<GenericValue> i = picked.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue pickedItem = i.next();
|
||||
for(GenericValue pickedItem : picked) {
|
||||
BigDecimal issueQty = pickedItem.getBigDecimal("quantity");
|
||||
if (issueQty != null) {
|
||||
quantityPicked = quantityPicked.add(issueQty).setScale(scale, rounding);
|
||||
@@ -2051,9 +1969,7 @@ public class OrderReadHelper {
|
||||
BigDecimal quantityShipped = ZERO;
|
||||
List<GenericValue> issuance = getOrderItemIssuances(orderItem);
|
||||
if (issuance != null) {
|
||||
Iterator<GenericValue> i = issuance.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue issue = i.next();
|
||||
for(GenericValue issue : issuance) {
|
||||
BigDecimal issueQty = issue.getBigDecimal("quantity");
|
||||
BigDecimal cancelQty = issue.getBigDecimal("cancelQuantity");
|
||||
if (cancelQty == null) {
|
||||
@@ -2073,9 +1989,7 @@ public class OrderReadHelper {
|
||||
|
||||
List<GenericValue> reses = getOrderItemShipGrpInvResList(orderItem);
|
||||
if (reses != null) {
|
||||
Iterator<GenericValue> i = reses.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue res = i.next();
|
||||
for(GenericValue res : reses) {
|
||||
BigDecimal quantity = res.getBigDecimal("quantity");
|
||||
if (quantity != null) {
|
||||
reserved = reserved.add(quantity).setScale(scale, rounding);
|
||||
@@ -2093,9 +2007,7 @@ public class OrderReadHelper {
|
||||
|
||||
List<GenericValue> reses = getOrderItemShipGrpInvResList(orderItem);
|
||||
if (reses != null) {
|
||||
Iterator<GenericValue> i = reses.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue res = i.next();
|
||||
for(GenericValue res : reses) {
|
||||
Timestamp promised = res.getTimestamp("currentPromisedDate");
|
||||
if (promised == null) {
|
||||
promised = res.getTimestamp("promisedDatetime");
|
||||
@@ -2414,11 +2326,7 @@ public class OrderReadHelper {
|
||||
|
||||
if (UtilValidate.isNotEmpty(orderHeaderAdjustments)) {
|
||||
List<GenericValue> filteredAdjs = filterOrderAdjustments(orderHeaderAdjustments, includeOther, includeTax, includeShipping, false, false);
|
||||
Iterator<GenericValue> adjIt = filteredAdjs.iterator();
|
||||
|
||||
while (adjIt.hasNext()) {
|
||||
GenericValue orderAdjustment = adjIt.next();
|
||||
|
||||
for (GenericValue orderAdjustment : filteredAdjs) {
|
||||
adjTotal = adjTotal.add(OrderReadHelper.calcOrderAdjustment(orderAdjustment, subTotal)).setScale(scale, rounding);
|
||||
}
|
||||
}
|
||||
@@ -2449,17 +2357,12 @@ public class OrderReadHelper {
|
||||
|
||||
public static BigDecimal getOrderItemsSubTotal(List<GenericValue> orderItems, List<GenericValue> adjustments, List<GenericValue> workEfforts) {
|
||||
BigDecimal result = ZERO;
|
||||
Iterator<GenericValue> itemIter = UtilMisc.toIterator(orderItems);
|
||||
|
||||
while (itemIter != null && itemIter.hasNext()) {
|
||||
GenericValue orderItem = itemIter.next();
|
||||
for(GenericValue orderItem : orderItems) {
|
||||
BigDecimal itemTotal = getOrderItemSubTotal(orderItem, adjustments);
|
||||
// Debug.logInfo("Item : " + orderItem.getString("orderId") + " / " + orderItem.getString("orderItemSeqId") + " = " + itemTotal, module);
|
||||
|
||||
if (workEfforts != null && orderItem.getString("orderItemTypeId").compareTo("RENTAL_ORDER_ITEM") == 0) {
|
||||
Iterator<GenericValue> weIter = UtilMisc.toIterator(workEfforts);
|
||||
while (weIter != null && weIter.hasNext()) {
|
||||
GenericValue workEffort = weIter.next();
|
||||
for(GenericValue workEffort : workEfforts) {
|
||||
if (workEffort.getString("workEffortId").compareTo(orderItem.getString("orderItemSeqId")) == 0) {
|
||||
itemTotal = itemTotal.multiply(getWorkEffortRentalQuantity(workEffort)).setScale(scale, rounding);
|
||||
break;
|
||||
@@ -2519,10 +2422,8 @@ public class OrderReadHelper {
|
||||
|
||||
public static BigDecimal getOrderItemsTotal(List<GenericValue> orderItems, List<GenericValue> adjustments) {
|
||||
BigDecimal result = ZERO;
|
||||
Iterator<GenericValue> itemIter = UtilMisc.toIterator(orderItems);
|
||||
|
||||
while (itemIter != null && itemIter.hasNext()) {
|
||||
result = result.add(getOrderItemTotal(itemIter.next(), adjustments));
|
||||
for(GenericValue orderItem : orderItems) {
|
||||
result = result.add(getOrderItemTotal(orderItem, adjustments));
|
||||
}
|
||||
return result.setScale(scale, rounding);
|
||||
}
|
||||
@@ -2538,9 +2439,7 @@ public class OrderReadHelper {
|
||||
List<GenericValue> promoAdjustments = EntityUtil.filterByAnd(allOrderAdjustments, UtilMisc.toMap("orderAdjustmentTypeId", "PROMOTION_ADJUSTMENT"));
|
||||
|
||||
if (UtilValidate.isNotEmpty(promoAdjustments)) {
|
||||
Iterator<GenericValue> promoAdjIter = promoAdjustments.iterator();
|
||||
while (promoAdjIter.hasNext()) {
|
||||
GenericValue promoAdjustment = promoAdjIter.next();
|
||||
for(GenericValue promoAdjustment : promoAdjustments) {
|
||||
if (promoAdjustment != null) {
|
||||
BigDecimal amount = promoAdjustment.getBigDecimal("amount").setScale(taxCalcScale, taxRounding);
|
||||
promoAdjTotal = promoAdjTotal.add(amount);
|
||||
@@ -2593,10 +2492,8 @@ public class OrderReadHelper {
|
||||
|
||||
public static BigDecimal getAllOrderItemsAdjustmentsTotal(List<GenericValue> orderItems, List<GenericValue> adjustments, boolean includeOther, boolean includeTax, boolean includeShipping) {
|
||||
BigDecimal result = ZERO;
|
||||
Iterator<GenericValue> itemIter = UtilMisc.toIterator(orderItems);
|
||||
|
||||
while (itemIter != null && itemIter.hasNext()) {
|
||||
result = result.add(getOrderItemAdjustmentsTotal(itemIter.next(), adjustments, includeOther, includeTax, includeShipping));
|
||||
for(GenericValue orderItem : orderItems) {
|
||||
result = result.add(getOrderItemAdjustmentsTotal(orderItem, adjustments, includeOther, includeTax, includeShipping));
|
||||
}
|
||||
return result.setScale(scale, rounding);
|
||||
}
|
||||
@@ -2636,11 +2533,7 @@ public class OrderReadHelper {
|
||||
|
||||
if (UtilValidate.isNotEmpty(adjustments)) {
|
||||
List<GenericValue> filteredAdjs = filterOrderAdjustments(adjustments, includeOther, includeTax, includeShipping, forTax, forShipping);
|
||||
Iterator<GenericValue> adjIt = filteredAdjs.iterator();
|
||||
|
||||
while (adjIt.hasNext()) {
|
||||
GenericValue orderAdjustment = adjIt.next();
|
||||
|
||||
for(GenericValue orderAdjustment : filteredAdjs) {
|
||||
adjTotal = adjTotal.add(OrderReadHelper.calcItemAdjustment(orderAdjustment, quantity, unitPrice));
|
||||
}
|
||||
}
|
||||
@@ -2652,11 +2545,7 @@ public class OrderReadHelper {
|
||||
|
||||
if (UtilValidate.isNotEmpty(adjustments)) {
|
||||
List<GenericValue> filteredAdjs = filterOrderAdjustments(adjustments, includeOther, includeTax, includeShipping, forTax, forShipping);
|
||||
Iterator<GenericValue> adjIt = filteredAdjs.iterator();
|
||||
|
||||
while (adjIt.hasNext()) {
|
||||
GenericValue orderAdjustment = adjIt.next();
|
||||
|
||||
for(GenericValue orderAdjustment : filteredAdjs) {
|
||||
adjTotal = adjTotal.add(OrderReadHelper.calcItemAdjustmentRecurringBd(orderAdjustment, quantity, unitPrice)).setScale(scale, rounding);
|
||||
}
|
||||
}
|
||||
@@ -2693,11 +2582,7 @@ public class OrderReadHelper {
|
||||
List<GenericValue> newOrderAdjustmentsList = FastList.newInstance();
|
||||
|
||||
if (UtilValidate.isNotEmpty(adjustments)) {
|
||||
Iterator<GenericValue> adjIt = adjustments.iterator();
|
||||
|
||||
while (adjIt.hasNext()) {
|
||||
GenericValue orderAdjustment = adjIt.next();
|
||||
|
||||
for(GenericValue orderAdjustment : newOrderAdjustmentsList) {
|
||||
boolean includeAdjustment = false;
|
||||
|
||||
if ("SALES_TAX".equals(orderAdjustment.getString("orderAdjustmentTypeId")) ||
|
||||
@@ -2746,9 +2631,7 @@ public class OrderReadHelper {
|
||||
}
|
||||
|
||||
if (UtilValidate.isNotEmpty(openOrders)) {
|
||||
Iterator<GenericValue> i = openOrders.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue order = i.next();
|
||||
for(GenericValue order : openOrders) {
|
||||
BigDecimal thisQty = order.getBigDecimal("quantity");
|
||||
if (thisQty == null) {
|
||||
thisQty = BigDecimal.ZERO;
|
||||
@@ -2802,9 +2685,7 @@ public class OrderReadHelper {
|
||||
List<GenericValue> orderHeaderAdjustments = this.getOrderHeaderAdjustments();
|
||||
List<GenericValue> filteredAdjustments = FastList.newInstance();
|
||||
if (orderHeaderAdjustments != null) {
|
||||
Iterator<GenericValue> orderAdjIterator = orderHeaderAdjustments.iterator();
|
||||
while (orderAdjIterator.hasNext()) {
|
||||
GenericValue orderAdjustment = orderAdjIterator.next();
|
||||
for(GenericValue orderAdjustment : orderHeaderAdjustments) {
|
||||
long count = 0;
|
||||
try {
|
||||
count = orderHeader.getDelegator().findCountByCondition("ReturnAdjustment", EntityCondition.makeCondition("orderAdjustmentId", EntityOperator.EQUALS, orderAdjustment.get("orderAdjustmentId")), null, null);
|
||||
@@ -2832,9 +2713,7 @@ public class OrderReadHelper {
|
||||
// TODO: find on a view-entity with a sum is probably more efficient
|
||||
adjustments = delegator.findByAnd("ReturnAdjustment", condition);
|
||||
if (adjustments != null) {
|
||||
Iterator<GenericValue> adjustmentIterator = adjustments.iterator();
|
||||
while (adjustmentIterator.hasNext()) {
|
||||
GenericValue returnAdjustment = adjustmentIterator.next();
|
||||
for(GenericValue returnAdjustment : adjustments) {
|
||||
total = total.add(setScaleByType("RET_SALES_TAX_ADJ".equals(returnAdjustment.get("returnAdjustmentTypeId")),returnAdjustment.getBigDecimal("amount")));
|
||||
}
|
||||
}
|
||||
@@ -2855,8 +2734,7 @@ public class OrderReadHelper {
|
||||
try {
|
||||
// this is simply the sum of quantity billed in all related OrderItemBillings
|
||||
List<GenericValue> billings = orderItem.getRelated("OrderItemBilling");
|
||||
for (Iterator<GenericValue> iter = billings.iterator(); iter.hasNext();) {
|
||||
GenericValue billing = iter.next();
|
||||
for(GenericValue billing : billings) {
|
||||
BigDecimal quantity = billing.getBigDecimal("quantity");
|
||||
if (quantity != null) {
|
||||
invoiced = invoiced.add(quantity);
|
||||
|
||||
@@ -429,9 +429,7 @@ public class OrderReturnServices {
|
||||
returnableQuantity = orderQty;
|
||||
} else {
|
||||
BigDecimal returnedQty = BigDecimal.ZERO;
|
||||
Iterator<GenericValue> ri = returnedItems.iterator();
|
||||
while (ri.hasNext()) {
|
||||
GenericValue returnItem = ri.next();
|
||||
for(GenericValue returnItem : returnedItems) {
|
||||
GenericValue returnHeader = null;
|
||||
try {
|
||||
returnHeader = returnItem.getRelatedOne("ReturnHeader");
|
||||
@@ -498,9 +496,7 @@ public class OrderReturnServices {
|
||||
}
|
||||
|
||||
if (orderItemQuantitiesIssued != null) {
|
||||
Iterator<GenericValue> i = orderItemQuantitiesIssued.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue orderItemQuantityIssued = i.next();
|
||||
for(GenericValue orderItemQuantityIssued : orderItemQuantitiesIssued) {
|
||||
GenericValue item = null;
|
||||
try {
|
||||
item = orderItemQuantityIssued.getRelatedOne("OrderItem");
|
||||
@@ -578,9 +574,7 @@ public class OrderReturnServices {
|
||||
"OrderErrorUnableToGetOrderAdjustmentsFromItem", locale));
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(itemAdjustments)) {
|
||||
Iterator<GenericValue> itemAdjustmentsIt = itemAdjustments.iterator();
|
||||
while (itemAdjustmentsIt.hasNext()) {
|
||||
GenericValue itemAdjustment = itemAdjustmentsIt.next();
|
||||
for(GenericValue itemAdjustment : itemAdjustments) {
|
||||
returnInfo = FastMap.newInstance();
|
||||
returnInfo.put("returnableQuantity", BigDecimal.ONE);
|
||||
// TODO: the returnablePrice should be set to the amount minus the already returned amount
|
||||
@@ -637,9 +631,7 @@ public class OrderReturnServices {
|
||||
|
||||
List<GenericValue> completedItems = FastList.newInstance();
|
||||
if (returnHeader != null && UtilValidate.isNotEmpty(returnItems)) {
|
||||
Iterator<GenericValue> itemsIter = returnItems.iterator();
|
||||
while (itemsIter.hasNext()) {
|
||||
GenericValue item = itemsIter.next();
|
||||
for(GenericValue item : returnItems) {
|
||||
String itemStatus = item != null ? item.getString("statusId") : null;
|
||||
if (itemStatus != null) {
|
||||
// both completed and cancelled items qualify for completed status change
|
||||
@@ -782,9 +774,8 @@ public class OrderReturnServices {
|
||||
billingAccounts = EntityUtil.filterByDate(billingAccounts);
|
||||
billingAccounts = EntityUtil.orderBy(billingAccounts, UtilMisc.toList("-fromDate"));
|
||||
if (UtilValidate.isNotEmpty(billingAccounts)) {
|
||||
ListIterator<GenericValue> billingAccountItr = billingAccounts.listIterator();
|
||||
while (billingAccountItr.hasNext() && billingAccountId == null) {
|
||||
String thisBillingAccountId = billingAccountItr.next().getString("billingAccountId");
|
||||
for(GenericValue billingAccount : billingAccounts) {
|
||||
String thisBillingAccountId = billingAccount.getString("billingAccountId");
|
||||
BigDecimal billingAccountBalance = ZERO;
|
||||
try {
|
||||
billingAccountBalance = getBillingAccountBalance(thisBillingAccountId, dctx);
|
||||
@@ -881,8 +872,7 @@ public class OrderReturnServices {
|
||||
|
||||
// first, compute the total credit from the return items
|
||||
BigDecimal creditTotal = ZERO;
|
||||
for (Iterator<GenericValue> itemsIter = returnItems.iterator(); itemsIter.hasNext();) {
|
||||
GenericValue item = itemsIter.next();
|
||||
for(GenericValue item : returnItems) {
|
||||
BigDecimal quantity = item.getBigDecimal("returnQuantity");
|
||||
BigDecimal price = item.getBigDecimal("returnPrice");
|
||||
if (quantity == null) quantity = ZERO;
|
||||
@@ -962,8 +952,7 @@ public class OrderReturnServices {
|
||||
String itemResponseId = (String) serviceResults.get("returnItemResponseId");
|
||||
|
||||
// loop through the items again to update them and store a status change history
|
||||
for (Iterator<GenericValue> itemsIter = returnItems.iterator(); itemsIter.hasNext();) {
|
||||
GenericValue item = itemsIter.next();
|
||||
for(GenericValue item : returnItems) {
|
||||
Map<String, Object> returnItemMap = UtilMisc.<String, Object>toMap("returnItemResponseId", itemResponseId, "returnId", item.get("returnId"), "returnItemSeqId", item.get("returnItemSeqId"), "statusId", "RETURN_COMPLETED", "userLogin", userLogin);
|
||||
// store the item changes (attached responseId)
|
||||
try {
|
||||
@@ -1040,16 +1029,14 @@ public class OrderReturnServices {
|
||||
), EntityOperator.AND);
|
||||
|
||||
List<GenericValue> orderPaymentPreferenceSums = delegator.findList("OrderPurchasePaymentSummary", whereConditions, UtilMisc.toSet("maxAmount"), null, null, false);
|
||||
for (Iterator<GenericValue> oppsi = orderPaymentPreferenceSums.iterator(); oppsi.hasNext();) {
|
||||
GenericValue orderPaymentPreferenceSum = oppsi.next();
|
||||
for(GenericValue orderPaymentPreferenceSum : orderPaymentPreferenceSums) {
|
||||
BigDecimal maxAmount = orderPaymentPreferenceSum.getBigDecimal("maxAmount");
|
||||
balance = maxAmount != null ? balance.subtract(maxAmount) : balance;
|
||||
}
|
||||
|
||||
List<GenericValue> paymentAppls = delegator.findByAnd("PaymentApplication", UtilMisc.toMap("billingAccountId", billingAccountId));
|
||||
// TODO: cancelled payments?
|
||||
for (Iterator<GenericValue> pAi = paymentAppls.iterator(); pAi.hasNext();) {
|
||||
GenericValue paymentAppl = pAi.next();
|
||||
for(GenericValue paymentAppl : paymentAppls) {
|
||||
if (paymentAppl.getString("invoiceId") == null) {
|
||||
BigDecimal amountApplied = paymentAppl.getBigDecimal("amountApplied");
|
||||
balance = balance.add(amountApplied);
|
||||
@@ -1087,8 +1074,7 @@ public class OrderReturnServices {
|
||||
|
||||
// find the minimum storeCreditValidDays of all the ProductStores associated with all the Orders on the Return, skipping null ones
|
||||
Long storeCreditValidDays = null;
|
||||
for (Iterator<GenericValue> iter = productStores.iterator(); iter.hasNext();) {
|
||||
GenericValue productStore = iter.next();
|
||||
for(GenericValue productStore : productStores) {
|
||||
Long thisStoreValidDays = productStore.getLong("storeCreditValidDays");
|
||||
if (thisStoreValidDays == null) continue;
|
||||
|
||||
@@ -1314,9 +1300,7 @@ public class OrderReturnServices {
|
||||
* the intent is to get the refundable amounts per orderPaymentPreference, grouped by payment method type.
|
||||
*/
|
||||
Map<String, List<Map<String, Object>>> prefSplitMap = FastMap.newInstance();
|
||||
Iterator<GenericValue> oppit = orderPayPrefs.iterator();
|
||||
while (oppit.hasNext()) {
|
||||
GenericValue orderPayPref = oppit.next();
|
||||
for(GenericValue orderPayPref : orderPayPrefs) {
|
||||
String paymentMethodTypeId = orderPayPref.getString("paymentMethodTypeId");
|
||||
String orderPayPrefKey = orderPayPref.getString("paymentMethodId") != null ? orderPayPref.getString("paymentMethodId") : orderPayPref.getString("paymentMethodTypeId");
|
||||
|
||||
@@ -1484,10 +1468,7 @@ public class OrderReturnServices {
|
||||
String responseId = (String) serviceResults.get("returnItemResponseId");
|
||||
|
||||
// Set the response on each item
|
||||
Iterator<GenericValue> itemsIter = items.iterator();
|
||||
while (itemsIter.hasNext()) {
|
||||
GenericValue item = itemsIter.next();
|
||||
|
||||
for(GenericValue item : items) {
|
||||
Map<String, Object> returnItemMap = UtilMisc.<String, Object>toMap("returnItemResponseId", responseId, "returnId", item.get("returnId"), "returnItemSeqId", item.get("returnItemSeqId"), "statusId", returnItemStatusId, "userLogin", userLogin);
|
||||
//Debug.logInfo("Updating item status", module);
|
||||
try {
|
||||
@@ -1647,11 +1628,9 @@ public class OrderReturnServices {
|
||||
// for each return item in the response, get the list of return item billings and then a list of invoices
|
||||
Map<String, GenericValue> returnInvoices = FastMap.newInstance(); // key is invoiceId, value is Invoice GenericValue
|
||||
List<GenericValue> items = response.getRelated("ReturnItem");
|
||||
for (Iterator<GenericValue> itemIter = items.iterator(); itemIter.hasNext();) {
|
||||
GenericValue item = itemIter.next();
|
||||
for (GenericValue item : items) {
|
||||
List<GenericValue> billings = item.getRelated("ReturnItemBilling");
|
||||
for (Iterator<GenericValue> billIter = billings.iterator(); billIter.hasNext();) {
|
||||
GenericValue billing = billIter.next();
|
||||
for (GenericValue billing : billings) {
|
||||
GenericValue invoice = billing.getRelatedOne("Invoice");
|
||||
|
||||
// put the invoice in the map if it doesn't already exist (a very loopy way of doing group by invoiceId without creating a view)
|
||||
@@ -1664,13 +1643,10 @@ public class OrderReturnServices {
|
||||
// for each return invoice found, sum up the related billings
|
||||
Map<String, BigDecimal> invoiceTotals = FastMap.newInstance(); // key is invoiceId, value is the sum of all billings for that invoice
|
||||
BigDecimal grandTotal = ZERO; // The sum of all return invoice totals
|
||||
for (Iterator<GenericValue> iter = returnInvoices.values().iterator(); iter.hasNext();) {
|
||||
GenericValue invoice = iter.next();
|
||||
|
||||
for (GenericValue invoice : returnInvoices.values()) {
|
||||
List<GenericValue> billings = invoice.getRelated("ReturnItemBilling");
|
||||
BigDecimal runningTotal = ZERO;
|
||||
for (Iterator<GenericValue> billIter = billings.iterator(); billIter.hasNext();) {
|
||||
GenericValue billing = billIter.next();
|
||||
for (GenericValue billing : billings) {
|
||||
runningTotal = runningTotal.add(billing.getBigDecimal("amount").multiply(billing.getBigDecimal("quantity")).setScale(decimals, rounding));
|
||||
}
|
||||
|
||||
@@ -1679,8 +1655,7 @@ public class OrderReturnServices {
|
||||
}
|
||||
|
||||
// now allocate responseAmount * invoiceTotal / grandTotal to each invoice
|
||||
for (Iterator<GenericValue> iter = returnInvoices.values().iterator(); iter.hasNext();) {
|
||||
GenericValue invoice = iter.next();
|
||||
for (GenericValue invoice : returnInvoices.values()) {
|
||||
String invoiceId = invoice.getString("invoiceId");
|
||||
BigDecimal invoiceTotal = invoiceTotals.get(invoiceId);
|
||||
|
||||
@@ -1793,9 +1768,7 @@ public class OrderReturnServices {
|
||||
Debug.logError(e, module);
|
||||
}
|
||||
if (orderCm != null) {
|
||||
Iterator<GenericValue> orderCmi = orderCm.iterator();
|
||||
while (orderCmi.hasNext()) {
|
||||
GenericValue v = orderCmi.next();
|
||||
for(GenericValue v : orderCm) {
|
||||
contactMechs.add(GenericValue.create(v));
|
||||
}
|
||||
orderMap.put("orderContactMechs", contactMechs);
|
||||
@@ -1829,10 +1802,8 @@ public class OrderReturnServices {
|
||||
List<String> orderItemShipGroupIds = FastList.newInstance(); // this is used to store the ship group ids of the groups already added to the orderItemShipGroupInfo list
|
||||
List<GenericValue> orderItemAssocs = FastList.newInstance();
|
||||
if (returnItemList != null) {
|
||||
Iterator<GenericValue> returnItemIter = returnItemList.iterator();
|
||||
int itemCount = 1;
|
||||
while (returnItemIter.hasNext()) {
|
||||
GenericValue returnItem = returnItemIter.next();
|
||||
for(GenericValue returnItem : returnItemList) {
|
||||
GenericValue orderItem = null;
|
||||
GenericValue product = null;
|
||||
try {
|
||||
@@ -1946,9 +1917,7 @@ public class OrderReturnServices {
|
||||
continue;
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(repairItems)) {
|
||||
Iterator<GenericValue> repairItemIt = repairItems.iterator();
|
||||
while (repairItemIt.hasNext()) {
|
||||
GenericValue repairItem = repairItemIt.next();
|
||||
for(GenericValue repairItem : repairItems) {
|
||||
GenericValue repairItemProduct = null;
|
||||
try {
|
||||
repairItemProduct = repairItem.getRelatedOne("AssocProduct");
|
||||
@@ -2094,9 +2063,7 @@ public class OrderReturnServices {
|
||||
List<GenericValue> orderRoles = orderHeader.getRelated("OrderRole");
|
||||
Map<String, List<String>> orderRolesMap = FastMap.newInstance();
|
||||
if (orderRoles != null) {
|
||||
Iterator<GenericValue> orderRolesIt = orderRoles.iterator();
|
||||
while (orderRolesIt.hasNext()) {
|
||||
GenericValue orderRole = orderRolesIt.next();
|
||||
for(GenericValue orderRole : orderRoles) {
|
||||
List<String> parties = orderRolesMap.get(orderRole.getString("roleTypeId"));
|
||||
if (parties == null) {
|
||||
parties = FastList.newInstance();
|
||||
@@ -2173,9 +2140,7 @@ public class OrderReturnServices {
|
||||
"OrderProblemCreatingReturnItemResponseRecord", locale));
|
||||
}
|
||||
|
||||
Iterator<GenericValue> updateReturnItemIter = returnItemList.iterator();
|
||||
while (updateReturnItemIter.hasNext()) {
|
||||
GenericValue returnItem = updateReturnItemIter.next();
|
||||
for(GenericValue returnItem : returnItemList) {
|
||||
Map<String, Object> updateReturnItemCtx = FastMap.newInstance();
|
||||
updateReturnItemCtx.put("returnId", returnId);
|
||||
updateReturnItemCtx.put("returnItemSeqId", returnItem.get("returnItemSeqId"));
|
||||
@@ -2233,9 +2198,7 @@ public class OrderReturnServices {
|
||||
}
|
||||
|
||||
if (returnItems != null) {
|
||||
Iterator<GenericValue> ri = returnItems.iterator();
|
||||
while (ri.hasNext()) {
|
||||
GenericValue returnItem = ri.next();
|
||||
for(GenericValue returnItem : returnItems) {
|
||||
String orderItemSeqId = returnItem.getString("orderItemSeqId");
|
||||
String orderId = returnItem.getString("orderId");
|
||||
|
||||
@@ -2250,9 +2213,7 @@ public class OrderReturnServices {
|
||||
|
||||
// cancel all current subscriptions
|
||||
if (subscriptions != null) {
|
||||
Iterator<GenericValue> si = subscriptions.iterator();
|
||||
while (si.hasNext()) {
|
||||
GenericValue subscription = si.next();
|
||||
for(GenericValue subscription : subscriptions) {
|
||||
Timestamp thruDate = subscription.getTimestamp("thruDate");
|
||||
if (thruDate == null || thruDate.after(now)) {
|
||||
subscription.set("thruDate", now);
|
||||
@@ -2281,9 +2242,7 @@ public class OrderReturnServices {
|
||||
* @param returnTypeId the return type id
|
||||
*/
|
||||
public static void groupReturnItemsByOrder(List<GenericValue> returnItems, Map<String, List<GenericValue>> returnItemsByOrderId, Map<String, BigDecimal> totalByOrder, Delegator delegator, String returnId, String returnTypeId) {
|
||||
Iterator<GenericValue> itemIt = returnItems.iterator();
|
||||
while (itemIt.hasNext()) {
|
||||
GenericValue returnItem = itemIt.next();
|
||||
for(GenericValue returnItem : returnItems) {
|
||||
String orderId = returnItem.getString("orderId");
|
||||
if (orderId != null) {
|
||||
if (returnItemsByOrderId != null) {
|
||||
@@ -2326,9 +2285,7 @@ public class OrderReturnServices {
|
||||
|
||||
// We may also have some order-level adjustments, so we need to go through each order again and add those as well
|
||||
if ((totalByOrder != null) && (totalByOrder.keySet() != null)) {
|
||||
Iterator<String> orderIterator = totalByOrder.keySet().iterator();
|
||||
while (orderIterator.hasNext()) {
|
||||
String orderId = orderIterator.next();
|
||||
for(String orderId : totalByOrder.keySet()) {
|
||||
// find returnAdjustment for returnHeader
|
||||
Map<String, Object> condition = UtilMisc.<String, Object>toMap("returnId", returnId,
|
||||
"returnItemSeqId", org.ofbiz.common.DataModelConstants.SEQ_ID_NA,
|
||||
@@ -2355,20 +2312,14 @@ public class OrderReturnServices {
|
||||
"OrderErrorGettingReturnHeaderItemInformation", locale));
|
||||
}
|
||||
if ((returnItems != null) && (returnItems.size() > 0)) {
|
||||
Iterator<GenericValue> returnItemIterator = returnItems.iterator();
|
||||
GenericValue returnItem = null;
|
||||
GenericValue returnItemResponse = null;
|
||||
GenericValue payment = null;
|
||||
String orderId;
|
||||
List<String> paymentList = FastList.newInstance();
|
||||
while (returnItemIterator.hasNext()) {
|
||||
returnItem = returnItemIterator.next();
|
||||
orderId = returnItem.getString("orderId");
|
||||
for(GenericValue returnItem : returnItems) {
|
||||
String orderId = returnItem.getString("orderId");
|
||||
try {
|
||||
returnItemResponse = returnItem.getRelatedOne("ReturnItemResponse");
|
||||
GenericValue returnItemResponse = returnItem.getRelatedOne("ReturnItemResponse");
|
||||
if ((returnItemResponse != null) && (orderId != null)) {
|
||||
// TODO should we filter on payment's status (PMNT_SENT,PMNT_RECEIVED)
|
||||
payment = returnItemResponse.getRelatedOne("Payment");
|
||||
GenericValue payment = returnItemResponse.getRelatedOne("Payment");
|
||||
if ((payment != null) && (payment.getBigDecimal("amount") != null) &&
|
||||
!paymentList.contains(payment.get("paymentId"))) {
|
||||
UtilMisc.addToBigDecimalInMap(returnAmountByOrder, orderId, payment.getBigDecimal("amount"));
|
||||
@@ -2407,9 +2358,7 @@ public class OrderReturnServices {
|
||||
}
|
||||
|
||||
if ((returnAmountByOrder != null) && (returnAmountByOrder.keySet() != null)) {
|
||||
Iterator<String> orderIterator = returnAmountByOrder.keySet().iterator();
|
||||
while (orderIterator.hasNext()) {
|
||||
String orderId = orderIterator.next();
|
||||
for(String orderId : returnAmountByOrder.keySet()) {
|
||||
BigDecimal returnAmount = returnAmountByOrder.get(orderId);
|
||||
if (returnAmount.abs().compareTo(new BigDecimal("0.000001")) < 0) {
|
||||
Debug.logError("Order [" + orderId + "] refund amount[ " + returnAmount + "] less than zero", module);
|
||||
@@ -2662,9 +2611,7 @@ public class OrderReturnServices {
|
||||
// TODO: find on a view-entity with a sum is probably more efficient
|
||||
adjustments = delegator.findByAnd("ReturnAdjustment", condition);
|
||||
if (adjustments != null) {
|
||||
Iterator<GenericValue> adjustmentIterator = adjustments.iterator();
|
||||
while (adjustmentIterator.hasNext()) {
|
||||
GenericValue returnAdjustment = adjustmentIterator.next();
|
||||
for(GenericValue returnAdjustment : adjustments) {
|
||||
if ((returnAdjustment != null) && (returnAdjustment.get("amount") != null)) {
|
||||
total = total.add(returnAdjustment.getBigDecimal("amount"));
|
||||
}
|
||||
|
||||
@@ -925,11 +925,10 @@ public class OrderServices {
|
||||
Set<String> orderProductPromoCodes = UtilGenerics.checkSet(context.get("orderProductPromoCodes"));
|
||||
if (UtilValidate.isNotEmpty(orderProductPromoCodes)) {
|
||||
GenericValue orderProductPromoCode = delegator.makeValue("OrderProductPromoCode");
|
||||
Iterator<String> orderProductPromoCodeIter = orderProductPromoCodes.iterator();
|
||||
while (orderProductPromoCodeIter.hasNext()) {
|
||||
for(String productPromoCodeId : orderProductPromoCodes) {
|
||||
orderProductPromoCode.clear();
|
||||
orderProductPromoCode.set("orderId", orderId);
|
||||
orderProductPromoCode.set("productPromoCodeId", orderProductPromoCodeIter.next());
|
||||
orderProductPromoCode.set("productPromoCodeId", productPromoCodeId);
|
||||
toBeStored.add(orderProductPromoCode);
|
||||
}
|
||||
}
|
||||
@@ -4891,8 +4890,7 @@ public class OrderServices {
|
||||
// the original method did a "\d+" regexp to decide which is the case, this version is more explicit with its lookup of PaymentMethodType
|
||||
if (checkOutPaymentId != null) {
|
||||
List<GenericValue> paymentMethodTypes = delegator.findList("PaymentMethodType", null, null, null, null, true);
|
||||
for (Iterator<GenericValue> iter = paymentMethodTypes.iterator(); iter.hasNext();) {
|
||||
GenericValue type = iter.next();
|
||||
for (GenericValue type : paymentMethodTypes) {
|
||||
if (type.get("paymentMethodTypeId").equals(checkOutPaymentId)) {
|
||||
paymentMethodTypeId = (String) type.get("paymentMethodTypeId");
|
||||
break;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.ofbiz.order.quote;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -192,9 +191,7 @@ public class QuoteServices {
|
||||
|
||||
// create Quote Items
|
||||
if (UtilValidate.isNotEmpty(quoteItems)) {
|
||||
Iterator<GenericValue> quoteIt = quoteItems.iterator();
|
||||
while (quoteIt.hasNext()) {
|
||||
GenericValue quoteItem = quoteIt.next();
|
||||
for(GenericValue quoteItem : quoteItems) {
|
||||
quoteItem.set("quoteId", quoteId);
|
||||
Map<String, Object> quoteItemIn = quoteItem.getAllFields();
|
||||
quoteItemIn.put("userLogin", userLogin);
|
||||
@@ -205,9 +202,7 @@ public class QuoteServices {
|
||||
|
||||
// create Quote Attributes
|
||||
if (UtilValidate.isNotEmpty(quoteAttributes)) {
|
||||
Iterator<GenericValue> quoteAttrIt = quoteAttributes.iterator();
|
||||
while (quoteAttrIt.hasNext()) {
|
||||
GenericValue quoteAttr = quoteAttrIt.next();
|
||||
for(GenericValue quoteAttr : quoteAttributes) {
|
||||
quoteAttr.set("quoteId", quoteId);
|
||||
Map<String, Object> quoteAttrIn = quoteAttr.getAllFields();
|
||||
quoteAttrIn.put("userLogin", userLogin);
|
||||
@@ -218,9 +213,7 @@ public class QuoteServices {
|
||||
|
||||
// create Quote Coefficients
|
||||
if (UtilValidate.isNotEmpty(quoteCoefficients)) {
|
||||
Iterator<GenericValue> quoteCoefficientIt = quoteCoefficients.iterator();
|
||||
while (quoteCoefficientIt.hasNext()) {
|
||||
GenericValue quoteCoefficient = quoteCoefficientIt.next();
|
||||
for(GenericValue quoteCoefficient : quoteCoefficients) {
|
||||
quoteCoefficient.set("quoteId", quoteId);
|
||||
Map<String, Object> quoteCoefficientIn = quoteCoefficient.getAllFields();
|
||||
quoteCoefficientIn.put("userLogin", userLogin);
|
||||
@@ -231,9 +224,7 @@ public class QuoteServices {
|
||||
|
||||
// create Quote Roles
|
||||
if (UtilValidate.isNotEmpty(quoteRoles)) {
|
||||
Iterator<GenericValue> quoteRoleIt = quoteRoles.iterator();
|
||||
while (quoteRoleIt.hasNext()) {
|
||||
GenericValue quoteRole = quoteRoleIt.next();
|
||||
for(GenericValue quoteRole : quoteRoles) {
|
||||
quoteRole.set("quoteId", quoteId);
|
||||
Map<String, Object> quoteRoleIn = quoteRole.getAllFields();
|
||||
quoteRoleIn.put("userLogin", userLogin);
|
||||
@@ -244,9 +235,7 @@ public class QuoteServices {
|
||||
|
||||
// create Quote WorkEfforts
|
||||
if (UtilValidate.isNotEmpty(quoteWorkEfforts)) {
|
||||
Iterator<GenericValue> quoteWorkEffortIt = quoteWorkEfforts.iterator();
|
||||
while (quoteWorkEffortIt.hasNext()) {
|
||||
GenericValue quoteWorkEffort = quoteWorkEffortIt.next();
|
||||
for(GenericValue quoteWorkEffort : quoteWorkEfforts) {
|
||||
quoteWorkEffort.set("quoteId", quoteId);
|
||||
Map<String, Object> quoteWorkEffortIn = quoteWorkEffort.getAllFields();
|
||||
quoteWorkEffortIn.put("userLogin", userLogin);
|
||||
@@ -257,9 +246,7 @@ public class QuoteServices {
|
||||
|
||||
// create Quote Adjustments
|
||||
if (UtilValidate.isNotEmpty(quoteAdjustments)) {
|
||||
Iterator<GenericValue> quoteAdjustmentIt = quoteAdjustments.iterator();
|
||||
while (quoteAdjustmentIt.hasNext()) {
|
||||
GenericValue quoteAdjustment = quoteAdjustmentIt.next();
|
||||
for(GenericValue quoteAdjustment : quoteAdjustments) {
|
||||
quoteAdjustment.set("quoteId", quoteId);
|
||||
Map<String, Object> quoteAdjustmentIn = quoteAdjustment.getAllFields();
|
||||
quoteAdjustmentIn.put("userLogin", userLogin);
|
||||
|
||||
@@ -99,9 +99,8 @@ public class RequirementServices {
|
||||
|
||||
// join in fields with extra data about the suppliers and products
|
||||
List<Map<String, Object>> requirements = FastList.newInstance();
|
||||
for (Iterator<GenericValue> iter = requirementAndRoles.iterator(); iter.hasNext();) {
|
||||
for(GenericValue requirement : requirementAndRoles) {
|
||||
Map<String, Object> union = FastMap.newInstance();
|
||||
GenericValue requirement = iter.next();
|
||||
String productId = requirement.getString("productId");
|
||||
partyId = requirement.getString("partyId");
|
||||
String facilityId = requirement.getString("facilityId");
|
||||
@@ -217,8 +216,7 @@ public class RequirementServices {
|
||||
}
|
||||
String facilityId = productStore.getString("inventoryFacilityId");
|
||||
List<GenericValue> orderItems = order.getRelated("OrderItem");
|
||||
for (Iterator<GenericValue> iter = orderItems.iterator(); iter.hasNext();) {
|
||||
GenericValue item = iter.next();
|
||||
for(GenericValue item : orderItems) {
|
||||
GenericValue product = item.getRelatedOne("Product");
|
||||
if (product == null) continue;
|
||||
if ((!"PRODRQM_AUTO".equals(product.get("requirementMethodEnumId")) &&
|
||||
@@ -277,8 +275,7 @@ public class RequirementServices {
|
||||
}
|
||||
String facilityId = productStore.getString("inventoryFacilityId");
|
||||
List<GenericValue> orderItems = order.getRelated("OrderItem");
|
||||
for (Iterator<GenericValue> iter = orderItems.iterator(); iter.hasNext();) {
|
||||
GenericValue item = iter.next();
|
||||
for(GenericValue item : orderItems) {
|
||||
GenericValue product = item.getRelatedOne("Product");
|
||||
if (product == null) continue;
|
||||
|
||||
@@ -312,8 +309,7 @@ public class RequirementServices {
|
||||
EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "REQ_REJECTED")),
|
||||
EntityOperator.AND);
|
||||
List<GenericValue> requirements = delegator.findList("Requirement", ecl, null, null, null, false);
|
||||
for (Iterator<GenericValue> riter = requirements.iterator(); riter.hasNext();) {
|
||||
GenericValue requirement = riter.next();
|
||||
for(GenericValue requirement : requirements) {
|
||||
pendingRequirements = pendingRequirements.add(requirement.get("quantity") == null ? BigDecimal.ZERO : requirement.getBigDecimal("quantity"));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
*******************************************************************************/
|
||||
package org.ofbiz.order.shoppingcart;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpSessionEvent;
|
||||
import javax.servlet.http.HttpSessionListener;
|
||||
@@ -78,10 +76,8 @@ public class CartEventListener implements HttpSessionListener {
|
||||
}
|
||||
|
||||
Debug.logInfo("Saving abandoned cart", module);
|
||||
Iterator<ShoppingCartItem> cartItems = cart.iterator();
|
||||
int seqId = 1;
|
||||
while (cartItems.hasNext()) {
|
||||
ShoppingCartItem cartItem = cartItems.next();
|
||||
for(ShoppingCartItem cartItem : cart) {
|
||||
GenericValue cartAbandonedLine = delegator.makeValue("CartAbandonedLine");
|
||||
|
||||
cartAbandonedLine.set("visitId", visit.get("visitId"));
|
||||
|
||||
@@ -266,9 +266,7 @@ public class CheckOutHelper {
|
||||
try {
|
||||
List<GenericValue> billingAccountTerms = delegator.findByAnd("BillingAccountTerm", UtilMisc.toMap("billingAccountId", billingAccountId));
|
||||
if (UtilValidate.isNotEmpty(billingAccountTerms)) {
|
||||
Iterator<GenericValue> billingAccountTermsIt = billingAccountTerms.iterator();
|
||||
while (billingAccountTermsIt.hasNext()) {
|
||||
GenericValue billingAccountTerm = billingAccountTermsIt.next();
|
||||
for(GenericValue billingAccountTerm : billingAccountTerms) {
|
||||
// the term is not copied if in the cart a term of the same type is already set
|
||||
if (!cart.hasOrderTerm(billingAccountTerm.getString("termTypeId"))) {
|
||||
cart.addOrderTerm(billingAccountTerm.getString("termTypeId"), billingAccountTerm.getBigDecimal("termValue"), billingAccountTerm.getLong("termDays"));
|
||||
@@ -318,10 +316,7 @@ public class CheckOutHelper {
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> paymentMethods = selectedPaymentMethods.keySet();
|
||||
Iterator<String> i = paymentMethods.iterator();
|
||||
while (i.hasNext()) {
|
||||
String checkOutPaymentId = i.next();
|
||||
for(String checkOutPaymentId : selectedPaymentMethods.keySet()) {
|
||||
String finAccountId = null;
|
||||
|
||||
if (checkOutPaymentId.indexOf("|") > -1) {
|
||||
@@ -633,10 +628,8 @@ public class CheckOutHelper {
|
||||
// If needed, the production runs are created and linked to the order lines.
|
||||
//
|
||||
List<GenericValue> orderItems = UtilGenerics.checkList(context.get("orderItems"));
|
||||
Iterator<GenericValue> orderItemsIt = orderItems.iterator();
|
||||
int counter = 0;
|
||||
while (orderItemsIt.hasNext()) {
|
||||
GenericValue orderItem = orderItemsIt.next();
|
||||
for(GenericValue orderItem : orderItems) {
|
||||
String productId = orderItem.getString("productId");
|
||||
if (productId != null) {
|
||||
try {
|
||||
@@ -675,9 +668,7 @@ public class CheckOutHelper {
|
||||
// ----------
|
||||
// The status of the requirement associated to the shopping cart lines is set to "ordered".
|
||||
//
|
||||
Iterator<ShoppingCartItem> shoppingCartItems = this.cart.items().iterator();
|
||||
while (shoppingCartItems.hasNext()) {
|
||||
ShoppingCartItem shoppingCartItem = shoppingCartItems.next();
|
||||
for(ShoppingCartItem shoppingCartItem : this.cart.items()) {
|
||||
String requirementId = shoppingCartItem.getRequirementId();
|
||||
if (requirementId != null) {
|
||||
try {
|
||||
@@ -731,9 +722,7 @@ public class CheckOutHelper {
|
||||
String additionalEmails = this.cart.getOrderAdditionalEmails();
|
||||
List<String> emailList = StringUtil.split(additionalEmails, ",");
|
||||
if (emailList == null) emailList = new ArrayList<String>();
|
||||
Iterator<String> eli = emailList.iterator();
|
||||
while (eli.hasNext()) {
|
||||
String email = eli.next();
|
||||
for(String email : emailList) {
|
||||
String contactMechId = this.delegator.getNextSeqId("ContactMech");
|
||||
GenericValue contactMech = this.delegator.makeValue("ContactMech",
|
||||
UtilMisc.toMap("contactMechId", contactMechId, "contactMechTypeId", "EMAIL_ADDRESS", "infoString", email));
|
||||
@@ -956,9 +945,7 @@ public class CheckOutHelper {
|
||||
List<EntityExpr> exprs = UtilMisc.toList(EntityCondition.makeCondition("manualRefNum", EntityOperator.NOT_EQUAL, null));
|
||||
List<GenericValue> manualRefPaymentPrefs = EntityUtil.filterByAnd(allPaymentPreferences, exprs);
|
||||
if (UtilValidate.isNotEmpty(manualRefPaymentPrefs)) {
|
||||
Iterator<GenericValue> i = manualRefPaymentPrefs.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue opp = i.next();
|
||||
for(GenericValue opp : manualRefPaymentPrefs) {
|
||||
Map<String, Object> authCtx = new HashMap<String, Object>();
|
||||
authCtx.put("orderPaymentPreference", opp);
|
||||
if (opp.get("paymentMethodId") == null) {
|
||||
@@ -1176,9 +1163,7 @@ public class CheckOutHelper {
|
||||
public static void adjustFaceToFacePayment(String orderId, BigDecimal cartTotal, List<GenericValue> allPaymentPrefs, GenericValue userLogin, Delegator delegator) throws GeneralException {
|
||||
BigDecimal prefTotal = BigDecimal.ZERO;
|
||||
if (allPaymentPrefs != null) {
|
||||
Iterator<GenericValue> i = allPaymentPrefs.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue pref = i.next();
|
||||
for(GenericValue pref : allPaymentPrefs) {
|
||||
BigDecimal maxAmount = pref.getBigDecimal("maxAmount");
|
||||
if (maxAmount == null) maxAmount = BigDecimal.ZERO;
|
||||
prefTotal = prefTotal.add(maxAmount);
|
||||
@@ -1217,9 +1202,7 @@ public class CheckOutHelper {
|
||||
String errMsg=null;
|
||||
|
||||
List<GenericValue> paymentMethods = this.cart.getPaymentMethods();
|
||||
Iterator<GenericValue> i = paymentMethods.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue paymentMethod = i.next();
|
||||
for(GenericValue paymentMethod : paymentMethods) {
|
||||
if ((paymentMethod != null) && ("CREDIT_CARD".equals(paymentMethod.getString("paymentMethodTypeId")))) {
|
||||
GenericValue creditCard = null;
|
||||
GenericValue billingAddress = null;
|
||||
@@ -1518,9 +1501,7 @@ public class CheckOutHelper {
|
||||
public Map<String, BigDecimal> makeBillingAccountMap(List<GenericValue> paymentPrefs) {
|
||||
Map<String, BigDecimal> accountMap = new HashMap<String, BigDecimal>();
|
||||
if (paymentPrefs != null) {
|
||||
Iterator<GenericValue> i = paymentPrefs.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue pp = i.next();
|
||||
for(GenericValue pp : paymentPrefs) {
|
||||
if (pp.get("billingAccountId") != null) {
|
||||
accountMap.put(pp.getString("billingAccountId"), pp.getBigDecimal("maxAmount"));
|
||||
}
|
||||
@@ -1557,18 +1538,14 @@ public class CheckOutHelper {
|
||||
// update the selected payment methods amount with valid numbers
|
||||
if (paymentMethods != null) {
|
||||
List<String> nullPaymentIds = new ArrayList<String>();
|
||||
Iterator<String> i = paymentMethods.iterator();
|
||||
while (i.hasNext()) {
|
||||
String paymentMethodId = i.next();
|
||||
for(String paymentMethodId : paymentMethods) {
|
||||
BigDecimal paymentAmount = cart.getPaymentAmount(paymentMethodId);
|
||||
if (paymentAmount == null || paymentAmount.compareTo(BigDecimal.ZERO) == 0) {
|
||||
if (Debug.verboseOn()) Debug.logVerbose("Found null paymentMethodId - " + paymentMethodId, module);
|
||||
nullPaymentIds.add(paymentMethodId);
|
||||
}
|
||||
}
|
||||
Iterator<String> npi = nullPaymentIds.iterator();
|
||||
while (npi.hasNext()) {
|
||||
String paymentMethodId = npi.next();
|
||||
for(String paymentMethodId : nullPaymentIds) {
|
||||
BigDecimal selectedPaymentTotal = cart.getPaymentTotal();
|
||||
BigDecimal requiredAmount = cart.getGrandTotal();
|
||||
BigDecimal newAmount = requiredAmount.subtract(selectedPaymentTotal);
|
||||
@@ -1636,9 +1613,7 @@ public class CheckOutHelper {
|
||||
String balanceField = null;
|
||||
|
||||
// get the gift card objects to check
|
||||
Iterator<GenericValue> i = cart.getGiftCards().iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue gc = i.next();
|
||||
for(GenericValue gc : cart.getGiftCards()) {
|
||||
Map<String, Object> gcBalanceMap = null;
|
||||
BigDecimal gcBalance = BigDecimal.ZERO;
|
||||
try {
|
||||
|
||||
@@ -218,9 +218,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
}
|
||||
|
||||
// clone the groups
|
||||
Iterator<ShoppingCartItemGroup> groupIt = cart.itemGroupByNumberMap.values().iterator();
|
||||
while (groupIt.hasNext()) {
|
||||
ShoppingCartItemGroup itemGroup = groupIt.next();
|
||||
for(ShoppingCartItemGroup itemGroup : cart.itemGroupByNumberMap.values()) {
|
||||
// get the new parent group by number from the existing set; as before the parent must come before all children to work...
|
||||
ShoppingCartItemGroup parentGroup = null;
|
||||
if (itemGroup.getParentGroup() != null) parentGroup = this.getItemGroupByNumber(itemGroup.getParentGroup().getGroupNumber());
|
||||
@@ -229,12 +227,10 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
}
|
||||
|
||||
// clone the items
|
||||
List<ShoppingCartItem> items = cart.items();
|
||||
Iterator<ShoppingCartItem> itIt = items.iterator();
|
||||
while (itIt.hasNext()) {
|
||||
cartLines.add(new ShoppingCartItem(itIt.next()));
|
||||
for(ShoppingCartItem item : cart.items()) {
|
||||
cartLines.add(new ShoppingCartItem(item));
|
||||
}
|
||||
|
||||
|
||||
this.facilityId = cart.facilityId;
|
||||
this.webSiteId = cart.webSiteId;
|
||||
}
|
||||
@@ -429,9 +425,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
String previousCurrency = this.currencyUom;
|
||||
this.currencyUom = currencyUom;
|
||||
if (!previousCurrency.equals(this.currencyUom)) {
|
||||
Iterator<ShoppingCartItem> itemIterator = this.iterator();
|
||||
while (itemIterator.hasNext()) {
|
||||
ShoppingCartItem item = itemIterator.next();
|
||||
for(ShoppingCartItem item : this) {
|
||||
item.updatePrice(dispatcher, this);
|
||||
}
|
||||
}
|
||||
@@ -758,18 +752,14 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
localList.addAll(multipleItems);
|
||||
// the ones to keep...
|
||||
for (int i=0; i<maxItems; i++) localList.remove(0);
|
||||
Iterator<ShoppingCartItem> localIter = localList.iterator();
|
||||
while (localIter.hasNext()) {
|
||||
ShoppingCartItem item = localIter.next();
|
||||
for(ShoppingCartItem item : localList) {
|
||||
this.removeCartItem(item, dispatcher);
|
||||
}
|
||||
}
|
||||
|
||||
public static BigDecimal getItemsTotalQuantity(List<ShoppingCartItem> cartItems) {
|
||||
BigDecimal totalQuantity = BigDecimal.ZERO;
|
||||
Iterator<ShoppingCartItem> localIter = cartItems.iterator();
|
||||
while (localIter.hasNext()) {
|
||||
ShoppingCartItem item = localIter.next();
|
||||
for(ShoppingCartItem item : cartItems) {
|
||||
totalQuantity = totalQuantity.add(item.getQuantity());
|
||||
}
|
||||
return totalQuantity;
|
||||
@@ -777,9 +767,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
|
||||
public static List<GenericValue> getItemsProducts(List<ShoppingCartItem> cartItems) {
|
||||
List<GenericValue> productList = FastList.newInstance();
|
||||
Iterator<ShoppingCartItem> localIter = cartItems.iterator();
|
||||
while (localIter.hasNext()) {
|
||||
ShoppingCartItem item = localIter.next();
|
||||
for(ShoppingCartItem item : cartItems) {
|
||||
GenericValue product = item.getProduct();
|
||||
if (product != null) {
|
||||
productList.add(product);
|
||||
@@ -789,9 +777,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
}
|
||||
|
||||
public void ensureItemsQuantity(List<ShoppingCartItem> cartItems, LocalDispatcher dispatcher, BigDecimal quantity) throws CartItemModifyException {
|
||||
Iterator<ShoppingCartItem> localIter = cartItems.iterator();
|
||||
while (localIter.hasNext()) {
|
||||
ShoppingCartItem item = localIter.next();
|
||||
for(ShoppingCartItem item : cartItems) {
|
||||
if (item.getQuantity() != quantity) {
|
||||
item.setQuantity(quantity, dispatcher, this);
|
||||
}
|
||||
@@ -802,10 +788,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
BigDecimal quantityRemoved = BigDecimal.ZERO;
|
||||
// go through the items and reduce quantityToKeep by the item quantities until it is 0, then remove the remaining...
|
||||
BigDecimal quantityToKeep = quantity;
|
||||
Iterator<ShoppingCartItem> localIter = cartItems.iterator();
|
||||
while (localIter.hasNext()) {
|
||||
ShoppingCartItem item = localIter.next();
|
||||
|
||||
for(ShoppingCartItem item : cartItems) {
|
||||
if (quantityToKeep.compareTo(item.getQuantity()) >= 0) {
|
||||
// quantityToKeep sufficient to keep it all... just reduce quantityToKeep and move on
|
||||
quantityToKeep = quantityToKeep.subtract(item.getQuantity());
|
||||
@@ -829,8 +812,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
// ============== WorkEffort related methods ===============
|
||||
public boolean containAnyWorkEffortCartItems() {
|
||||
// Check for existing cart item.
|
||||
for (int i = 0; i < this.cartLines.size(); i++) {
|
||||
ShoppingCartItem cartItem = cartLines.get(i);
|
||||
for(ShoppingCartItem cartItem : this.cartLines) {
|
||||
if (cartItem.getItemType().equals("RENTAL_ORDER_ITEM")) { // create workeffort items?
|
||||
return true;
|
||||
}
|
||||
@@ -840,8 +822,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
|
||||
public boolean containAllWorkEffortCartItems() {
|
||||
// Check for existing cart item.
|
||||
for (int i = 0; i < this.cartLines.size(); i++) {
|
||||
ShoppingCartItem cartItem = cartLines.get(i);
|
||||
for(ShoppingCartItem cartItem : this.cartLines) {
|
||||
if (!cartItem.getItemType().equals("RENTAL_ORDER_ITEM")) { // not a item to create workefforts?
|
||||
return false;
|
||||
}
|
||||
@@ -854,8 +835,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
* This is determined by making sure no Product has a type where ProductType.isPhysical!=N.
|
||||
*/
|
||||
public boolean containOnlyDigitalGoods() {
|
||||
for (int i = 0; i < this.cartLines.size(); i++) {
|
||||
ShoppingCartItem cartItem = cartLines.get(i);
|
||||
for(ShoppingCartItem cartItem : this.cartLines) {
|
||||
GenericValue product = cartItem.getProduct();
|
||||
try {
|
||||
GenericValue productType = product.getRelatedOneCache("ProductType");
|
||||
@@ -1024,16 +1004,12 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
if (itemGroup != null) {
|
||||
// go through all cart items and remove from group if they are in it
|
||||
List<ShoppingCartItem> cartItemList = this.getCartItemsInGroup(groupNumber);
|
||||
Iterator<ShoppingCartItem> cartItemIter = cartItemList.iterator();
|
||||
while (cartItemIter.hasNext()) {
|
||||
ShoppingCartItem cartItem = cartItemIter.next();
|
||||
for(ShoppingCartItem cartItem : cartItemList) {
|
||||
cartItem.setItemGroup(null);
|
||||
}
|
||||
|
||||
// if this is a parent of any set them to this group's parent (or null)
|
||||
Iterator<ShoppingCartItemGroup> itemGroupIter = this.itemGroupByNumberMap.values().iterator();
|
||||
while (itemGroupIter.hasNext()) {
|
||||
ShoppingCartItemGroup otherItemGroup = itemGroupIter.next();
|
||||
for(ShoppingCartItemGroup otherItemGroup : this.itemGroupByNumberMap.values()) {
|
||||
if (itemGroup.equals(otherItemGroup.getParentGroup())) {
|
||||
otherItemGroup.inheritParentsParent();
|
||||
}
|
||||
@@ -1089,9 +1065,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
String partyId = this.getPartyId();
|
||||
if (UtilValidate.isNotEmpty(partyId)) {
|
||||
// recalculate all prices
|
||||
Iterator<ShoppingCartItem> cartItemIter = this.iterator();
|
||||
while (cartItemIter.hasNext()) {
|
||||
ShoppingCartItem cartItem = cartItemIter.next();
|
||||
for(ShoppingCartItem cartItem : this) {
|
||||
cartItem.updatePrice(dispatcher, this);
|
||||
}
|
||||
|
||||
@@ -1576,9 +1550,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
/** Returns the CartPaymentInfo objects which have matching fields */
|
||||
public List<CartPaymentInfo> getPaymentInfos(boolean isPaymentMethod, boolean isPaymentMethodType, boolean hasRefNum) {
|
||||
List<CartPaymentInfo> foundRecords = new LinkedList<CartPaymentInfo>();
|
||||
Iterator<CartPaymentInfo> i = paymentInfo.iterator();
|
||||
while (i.hasNext()) {
|
||||
CartPaymentInfo inf = i.next();
|
||||
for(CartPaymentInfo inf : paymentInfo) {
|
||||
if (isPaymentMethod && inf.paymentMethodId != null) {
|
||||
if (hasRefNum && inf.refNum != null) {
|
||||
foundRecords.add(inf);
|
||||
@@ -1604,9 +1576,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
/** Locates an existing (or creates a new) CartPaymentInfo object */
|
||||
public CartPaymentInfo getPaymentInfo(String id, String refNum, String authCode, BigDecimal amount, boolean update) {
|
||||
CartPaymentInfo thisInf = this.makePaymentInfo(id, refNum, authCode, amount);
|
||||
Iterator<CartPaymentInfo> i = paymentInfo.iterator();
|
||||
while (i.hasNext()) {
|
||||
CartPaymentInfo inf = i.next();
|
||||
for(CartPaymentInfo inf : paymentInfo) {
|
||||
if (inf.compareTo(thisInf) == 0) {
|
||||
// update the info
|
||||
if (update) {
|
||||
@@ -1642,9 +1612,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
// this payment method will set the billing address for the order;
|
||||
// before it is set we have to verify if the billing address is
|
||||
// compatible with the ProductGeos
|
||||
Iterator<GenericValue> products = (ShoppingCart.getItemsProducts(this.cartLines)).iterator();
|
||||
while (products.hasNext()) {
|
||||
GenericValue product = products.next();
|
||||
for(GenericValue product : ShoppingCart.getItemsProducts(this.cartLines)) {
|
||||
if (!ProductWorker.isBillableToAddress(product, billingAddress)) {
|
||||
throw new IllegalArgumentException("The billing address is not compatible with ProductGeos rules.");
|
||||
}
|
||||
@@ -1687,9 +1655,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
}
|
||||
|
||||
public String getPaymentRef(String id) {
|
||||
Iterator<CartPaymentInfo> i = paymentInfo.iterator();
|
||||
while (i.hasNext()) {
|
||||
CartPaymentInfo inf = i.next();
|
||||
for(CartPaymentInfo inf : paymentInfo) {
|
||||
if (inf.paymentMethodId.equals(id) || inf.paymentMethodTypeId.equals(id)) {
|
||||
return inf.refNum[0];
|
||||
}
|
||||
@@ -1700,9 +1666,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
/** returns the total payment amounts */
|
||||
public BigDecimal getPaymentTotal() {
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
Iterator<CartPaymentInfo> i = paymentInfo.iterator();
|
||||
while (i.hasNext()) {
|
||||
CartPaymentInfo inf = i.next();
|
||||
for(CartPaymentInfo inf : paymentInfo) {
|
||||
if (inf.amount != null) {
|
||||
total = total.add(inf.amount);
|
||||
}
|
||||
@@ -1755,8 +1719,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
List<GenericValue> declinedPaymentMethods = delegator.findByAnd("OrderPaymentPreference", UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_DECLINED"));
|
||||
if (!UtilValidate.isEmpty(declinedPaymentMethods)) {
|
||||
List<String> paymentMethodIdsToRemove = new ArrayList<String>();
|
||||
for (Iterator<GenericValue> iter = declinedPaymentMethods.iterator(); iter.hasNext();) {
|
||||
GenericValue opp = iter.next();
|
||||
for(GenericValue opp : declinedPaymentMethods) {
|
||||
paymentMethodIdsToRemove.add(opp.getString("paymentMethodId"));
|
||||
}
|
||||
clearPaymentMethodsById(paymentMethodIdsToRemove);
|
||||
@@ -1770,9 +1733,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
|
||||
private void expireSingleUsePayments() {
|
||||
Timestamp now = UtilDateTime.nowTimestamp();
|
||||
Iterator<CartPaymentInfo> i = paymentInfo.iterator();
|
||||
while (i.hasNext()) {
|
||||
CartPaymentInfo inf = i.next();
|
||||
for(CartPaymentInfo inf : paymentInfo) {
|
||||
if (inf.paymentMethodId == null || !inf.singleUse) {
|
||||
continue;
|
||||
}
|
||||
@@ -1799,9 +1760,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
/** Returns the Payment Method Ids */
|
||||
public List<String> getPaymentMethodIds() {
|
||||
List<String> pmi = new LinkedList<String>();
|
||||
Iterator<CartPaymentInfo> i = paymentInfo.iterator();
|
||||
while (i.hasNext()) {
|
||||
CartPaymentInfo inf = i.next();
|
||||
for(CartPaymentInfo inf : paymentInfo) {
|
||||
if (inf.paymentMethodId != null) {
|
||||
pmi.add(inf.paymentMethodId);
|
||||
}
|
||||
@@ -1812,9 +1771,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
/** Returns the Payment Method Ids */
|
||||
public List<String> getPaymentMethodTypeIds() {
|
||||
List<String> pmt = FastList.newInstance();
|
||||
Iterator<CartPaymentInfo> i = paymentInfo.iterator();
|
||||
while (i.hasNext()) {
|
||||
CartPaymentInfo inf = i.next();
|
||||
for(CartPaymentInfo inf : paymentInfo) {
|
||||
if (inf.paymentMethodTypeId != null) {
|
||||
pmt.add(inf.paymentMethodTypeId);
|
||||
}
|
||||
@@ -1826,9 +1783,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
public List<GenericValue> getPaymentMethods() {
|
||||
List<GenericValue> methods = FastList.newInstance();
|
||||
if (UtilValidate.isNotEmpty(paymentInfo)) {
|
||||
Iterator<String> paymentMethodIdIter = getPaymentMethodIds().iterator();
|
||||
while (paymentMethodIdIter.hasNext()) {
|
||||
String paymentMethodId = paymentMethodIdIter.next();
|
||||
for(String paymentMethodId : getPaymentMethodIds()) {
|
||||
try {
|
||||
GenericValue paymentMethod = this.getDelegator().findByPrimaryKeyCache("PaymentMethod", UtilMisc.toMap("paymentMethodId", paymentMethodId));
|
||||
if (paymentMethod != null) {
|
||||
@@ -1849,9 +1804,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
public List<GenericValue> getPaymentMethodTypes() {
|
||||
List<GenericValue> types = new LinkedList<GenericValue>();
|
||||
if (UtilValidate.isNotEmpty(paymentInfo)) {
|
||||
Iterator<String> i = getPaymentMethodTypeIds().iterator();
|
||||
while (i.hasNext()) {
|
||||
String id = i.next();
|
||||
for(String id : getPaymentMethodIds()) {
|
||||
try {
|
||||
types.add(this.getDelegator().findByPrimaryKeyCache("PaymentMethodType", UtilMisc.toMap("paymentMethodTypeId", id)));
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -1867,9 +1820,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
List<GenericValue> paymentMethods = this.getPaymentMethods();
|
||||
List<GenericValue> creditCards = new LinkedList<GenericValue>();
|
||||
if (paymentMethods != null) {
|
||||
Iterator<GenericValue> i = paymentMethods.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue pm = i.next();
|
||||
for(GenericValue pm : paymentMethods) {
|
||||
if ("CREDIT_CARD".equals(pm.getString("paymentMethodTypeId"))) {
|
||||
try {
|
||||
GenericValue cc = pm.getRelatedOne("CreditCard");
|
||||
@@ -1888,9 +1839,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
List<GenericValue> paymentMethods = this.getPaymentMethods();
|
||||
List<GenericValue> giftCards = new LinkedList<GenericValue>();
|
||||
if (paymentMethods != null) {
|
||||
Iterator<GenericValue> i = paymentMethods.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue pm = i.next();
|
||||
for(GenericValue pm : paymentMethods) {
|
||||
if ("GIFT_CARD".equals(pm.getString("paymentMethodTypeId"))) {
|
||||
try {
|
||||
GenericValue gc = pm.getRelatedOne("GiftCard");
|
||||
@@ -1922,9 +1871,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
|
||||
public GenericValue getBillingAddress() {
|
||||
GenericValue billingAddress = null;
|
||||
Iterator<CartPaymentInfo> i = paymentInfo.iterator();
|
||||
while (i.hasNext()) {
|
||||
CartPaymentInfo inf = i.next();
|
||||
for(CartPaymentInfo inf : paymentInfo) {
|
||||
billingAddress = inf.getBillingAddress(this.getDelegator());
|
||||
if (billingAddress != null) {
|
||||
break;
|
||||
@@ -2109,8 +2056,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
Map<Integer, BigDecimal> shipGroups = this.getShipGroups(item);
|
||||
|
||||
if ((shipGroups != null) && (shipGroups.keySet() != null)) {
|
||||
for (Iterator<Integer> shipGroupKeys = shipGroups.keySet().iterator(); shipGroupKeys.hasNext();) {
|
||||
Integer shipGroup = shipGroupKeys.next();
|
||||
for(Integer shipGroup : shipGroups.keySet()) {
|
||||
CartShipInfo cartShipInfo = this.getShipInfo(shipGroup.intValue());
|
||||
|
||||
cartShipInfo.resetShipAfterDateIfBefore(item.getShipAfterDate());
|
||||
@@ -2258,9 +2204,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
if (shippingAddress != null) {
|
||||
Set<ShoppingCartItem> shipItems = csi.getShipItems();
|
||||
if (UtilValidate.isNotEmpty(shipItems)) {
|
||||
Iterator<ShoppingCartItem> siit = shipItems.iterator();
|
||||
while (siit.hasNext()) {
|
||||
ShoppingCartItem cartItem = siit.next();
|
||||
for(ShoppingCartItem cartItem : shipItems) {
|
||||
GenericValue product = cartItem.getProduct();
|
||||
if (UtilValidate.isNotEmpty(product)) {
|
||||
if (!ProductWorker.isShippableToAddress(product, shippingAddress)) {
|
||||
@@ -2607,11 +2551,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
public BigDecimal getTotalShipping() {
|
||||
BigDecimal tempShipping = BigDecimal.ZERO;
|
||||
|
||||
Iterator<CartShipInfo> shipIter = this.shipInfo.iterator();
|
||||
while (shipIter.hasNext()) {
|
||||
CartShipInfo csi = shipIter.next();
|
||||
for(CartShipInfo csi : this.shipInfo) {
|
||||
tempShipping = tempShipping.add(csi.shipEstimate);
|
||||
|
||||
}
|
||||
|
||||
return tempShipping;
|
||||
@@ -2620,10 +2561,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
/** Returns the item-total in the cart (not including discount/tax/shipping). */
|
||||
public BigDecimal getItemTotal() {
|
||||
BigDecimal itemTotal = BigDecimal.ZERO;
|
||||
Iterator<ShoppingCartItem> i = iterator();
|
||||
|
||||
while (i.hasNext()) {
|
||||
itemTotal = itemTotal.add((i.next()).getBasePrice());
|
||||
for(ShoppingCartItem cartItem : this.cartLines) {
|
||||
itemTotal = itemTotal.add(cartItem.getBasePrice());
|
||||
}
|
||||
return itemTotal;
|
||||
}
|
||||
@@ -2631,10 +2570,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
/** Returns the sub-total in the cart (item-total - discount). */
|
||||
public BigDecimal getSubTotal() {
|
||||
BigDecimal itemsTotal = BigDecimal.ZERO;
|
||||
Iterator<ShoppingCartItem> i = iterator();
|
||||
|
||||
while (i.hasNext()) {
|
||||
itemsTotal = itemsTotal.add((i.next()).getItemSubTotal());
|
||||
for(ShoppingCartItem cartItem : this.cartLines) {
|
||||
itemsTotal = itemsTotal.add(cartItem.getItemSubTotal());
|
||||
}
|
||||
return itemsTotal;
|
||||
}
|
||||
@@ -2651,9 +2588,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
|
||||
public BigDecimal getDisplaySubTotal() {
|
||||
BigDecimal itemsTotal = BigDecimal.ZERO;
|
||||
Iterator<ShoppingCartItem> i = iterator();
|
||||
while (i.hasNext()) {
|
||||
itemsTotal = itemsTotal.add((i.next()).getDisplayItemSubTotal());
|
||||
for(ShoppingCartItem cartItem : this.cartLines) {
|
||||
itemsTotal = itemsTotal.add(cartItem.getDisplayItemSubTotal());
|
||||
}
|
||||
return itemsTotal;
|
||||
}
|
||||
@@ -2665,9 +2601,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
|
||||
public BigDecimal getDisplayRecurringSubTotal() {
|
||||
BigDecimal itemsTotal = BigDecimal.ZERO;
|
||||
Iterator<ShoppingCartItem> i = iterator();
|
||||
while (i.hasNext()) {
|
||||
itemsTotal = itemsTotal.add((i.next()).getDisplayItemRecurringSubTotal());
|
||||
for(ShoppingCartItem cartItem : this.cartLines) {
|
||||
itemsTotal = itemsTotal.add(cartItem.getDisplayItemRecurringSubTotal());
|
||||
}
|
||||
return itemsTotal;
|
||||
}
|
||||
@@ -2684,10 +2619,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
/** Returns the sub-total in the cart (item-total - discount). */
|
||||
public BigDecimal getSubTotalForPromotions() {
|
||||
BigDecimal itemsTotal = BigDecimal.ZERO;
|
||||
Iterator<ShoppingCartItem> i = iterator();
|
||||
|
||||
while (i.hasNext()) {
|
||||
ShoppingCartItem cartItem = i.next();
|
||||
for(ShoppingCartItem cartItem : this.cartLines) {
|
||||
GenericValue product = cartItem.getProduct();
|
||||
if (product != null && "N".equals(product.getString("includeInPromotions"))) {
|
||||
// don't include in total if this is the case...
|
||||
@@ -2705,8 +2637,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
public BigDecimal getOrderPaymentPreferenceTotalByType(String paymentMethodTypeId) {
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
String thisPaymentMethodTypeId = null;
|
||||
for (Iterator<CartPaymentInfo> iter = paymentInfo.iterator(); iter.hasNext();) {
|
||||
CartPaymentInfo payment = iter.next();
|
||||
for(CartPaymentInfo payment : paymentInfo) {
|
||||
if (payment.amount == null) continue;
|
||||
if (payment.paymentMethodId != null) {
|
||||
try {
|
||||
@@ -2852,9 +2783,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
if (termTypeId == null) {
|
||||
return false;
|
||||
}
|
||||
Iterator<GenericValue> orderTermsIt = orderTerms.iterator();
|
||||
while (orderTermsIt.hasNext()) {
|
||||
GenericValue orderTerm = orderTermsIt.next();
|
||||
for(GenericValue orderTerm : orderTerms) {
|
||||
if (termTypeId.equals(orderTerm.getString("termTypeId"))) {
|
||||
return true;
|
||||
}
|
||||
@@ -2878,11 +2807,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
List<List<GenericValue>> adjsLists = FastList.newInstance();
|
||||
|
||||
adjsLists.add(this.getAdjustments());
|
||||
Iterator<ShoppingCartItem> cartIterator = this.iterator();
|
||||
|
||||
while (cartIterator.hasNext()) {
|
||||
ShoppingCartItem item = cartIterator.next();
|
||||
|
||||
for(ShoppingCartItem item : this) {
|
||||
if (item.getAdjustments() != null) {
|
||||
adjsLists.add(item.getAdjustments());
|
||||
}
|
||||
@@ -2907,11 +2833,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
/** Returns the total weight in the cart. */
|
||||
public BigDecimal getTotalWeight() {
|
||||
BigDecimal weight = BigDecimal.ZERO;
|
||||
Iterator<ShoppingCartItem> i = iterator();
|
||||
|
||||
while (i.hasNext()) {
|
||||
ShoppingCartItem item = i.next();
|
||||
|
||||
for(ShoppingCartItem item : this.cartLines) {
|
||||
weight = weight.add(item.getWeight().multiply(item.getQuantity()));
|
||||
}
|
||||
return weight;
|
||||
@@ -2920,10 +2843,9 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
/** Returns the total quantity in the cart. */
|
||||
public BigDecimal getTotalQuantity() {
|
||||
BigDecimal count = BigDecimal.ZERO;
|
||||
Iterator<ShoppingCartItem> i = iterator();
|
||||
|
||||
while (i.hasNext()) {
|
||||
count = count.add((i.next()).getQuantity());
|
||||
for(ShoppingCartItem item : this.cartLines) {
|
||||
count = count.add(item.getQuantity());
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@@ -3018,9 +2940,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
/** Returns true when there are shippable items in the cart */
|
||||
public boolean shippingApplies() {
|
||||
boolean shippingApplies = false;
|
||||
Iterator<ShoppingCartItem> i = this.iterator();
|
||||
while (i.hasNext()) {
|
||||
ShoppingCartItem item = i.next();
|
||||
for(ShoppingCartItem item : this) {
|
||||
if (item.shippingApplies()) {
|
||||
shippingApplies = true;
|
||||
break;
|
||||
@@ -3032,9 +2952,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
/** Returns true when there are taxable items in the cart */
|
||||
public boolean taxApplies() {
|
||||
boolean taxApplies = false;
|
||||
Iterator<ShoppingCartItem> i = this.iterator();
|
||||
while (i.hasNext()) {
|
||||
ShoppingCartItem item = i.next();
|
||||
for(ShoppingCartItem item : this) {
|
||||
if (item.taxApplies()) {
|
||||
taxApplies = true;
|
||||
break;
|
||||
@@ -3152,9 +3070,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
|
||||
public void clearCartItemUseInPromoInfo() {
|
||||
// clear out info about which cart items have been used in promos
|
||||
Iterator<ShoppingCartItem> cartLineIter = this.iterator();
|
||||
while (cartLineIter.hasNext()) {
|
||||
ShoppingCartItem cartLine = cartLineIter.next();
|
||||
for(ShoppingCartItem cartLine : this) {
|
||||
cartLine.clearPromoRuleUseInfo();
|
||||
}
|
||||
}
|
||||
@@ -3167,9 +3083,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
BigDecimal totalDiscount = BigDecimal.ZERO;
|
||||
List<GenericValue> cartAdjustments = this.getAdjustments();
|
||||
if (cartAdjustments != null) {
|
||||
Iterator<GenericValue> cartAdjustmentIter = cartAdjustments.iterator();
|
||||
while (cartAdjustmentIter.hasNext()) {
|
||||
GenericValue checkOrderAdjustment = cartAdjustmentIter.next();
|
||||
for(GenericValue checkOrderAdjustment : cartAdjustments) {
|
||||
if (UtilValidate.isNotEmpty(checkOrderAdjustment.getString("productPromoId")) &&
|
||||
UtilValidate.isNotEmpty(checkOrderAdjustment.getString("productPromoRuleId")) &&
|
||||
UtilValidate.isNotEmpty(checkOrderAdjustment.getString("productPromoActionSeqId"))) {
|
||||
@@ -3181,9 +3095,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
}
|
||||
|
||||
// add cart line adjustments from promo actions
|
||||
Iterator<ShoppingCartItem> cartItemIter = this.iterator();
|
||||
while (cartItemIter.hasNext()) {
|
||||
ShoppingCartItem checkItem = cartItemIter.next();
|
||||
for(ShoppingCartItem checkItem : this) {
|
||||
Iterator<GenericValue> checkOrderAdjustments = UtilMisc.toIterator(checkItem.getAdjustments());
|
||||
while (checkOrderAdjustments != null && checkOrderAdjustments.hasNext()) {
|
||||
GenericValue checkOrderAdjustment = checkOrderAdjustments.next();
|
||||
@@ -3287,17 +3199,13 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
// remove all cart adjustments
|
||||
this.adjustments.clear();
|
||||
// remove all cart item adjustments
|
||||
Iterator<ShoppingCartItem> cartItemIter = this.iterator();
|
||||
while (cartItemIter.hasNext()) {
|
||||
ShoppingCartItem checkItem = cartItemIter.next();
|
||||
for(ShoppingCartItem checkItem : this) {
|
||||
checkItem.getAdjustments().clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAllItemStatus() {
|
||||
Iterator<ShoppingCartItem> lineIter = this.iterator();
|
||||
while (lineIter.hasNext()) {
|
||||
ShoppingCartItem item = lineIter.next();
|
||||
for(ShoppingCartItem item : this) {
|
||||
item.setStatusId(null);
|
||||
}
|
||||
}
|
||||
@@ -3331,17 +3239,13 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
}
|
||||
|
||||
public synchronized void resetPromoRuleUse(String productPromoId, String productPromoRuleId) {
|
||||
Iterator<ShoppingCartItem> lineIter = this.iterator();
|
||||
while (lineIter.hasNext()) {
|
||||
ShoppingCartItem cartItem = lineIter.next();
|
||||
for(ShoppingCartItem cartItem : this) {
|
||||
cartItem.resetPromoRuleUse(productPromoId, productPromoRuleId);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void confirmPromoRuleUse(String productPromoId, String productPromoRuleId) {
|
||||
Iterator<ShoppingCartItem> lineIter = this.iterator();
|
||||
while (lineIter.hasNext()) {
|
||||
ShoppingCartItem cartItem = lineIter.next();
|
||||
for(ShoppingCartItem cartItem : this) {
|
||||
cartItem.confirmPromoRuleUse(productPromoId, productPromoRuleId);
|
||||
}
|
||||
}
|
||||
@@ -3355,9 +3259,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
// search if there is an existing entry
|
||||
List<String> parties = additionalPartyRole.get(roleTypeId);
|
||||
if (parties != null) {
|
||||
Iterator<String> it = parties.iterator();
|
||||
while (it.hasNext()) {
|
||||
if ((it.next()).equals(partyId)) {
|
||||
for(String pi : parties) {
|
||||
if (pi.equals(partyId)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -3491,9 +3394,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
|
||||
public List<GenericValue> makeOrderItemGroups() {
|
||||
List<GenericValue> result = FastList.newInstance();
|
||||
Iterator<ShoppingCartItemGroup> groupValueIter = this.itemGroupByNumberMap.values().iterator();
|
||||
while (groupValueIter.hasNext()) {
|
||||
ShoppingCart.ShoppingCartItemGroup itemGroup = groupValueIter.next();
|
||||
for(ShoppingCart.ShoppingCartItemGroup itemGroup : this.itemGroupByNumberMap.values()) {
|
||||
result.add(itemGroup.makeOrderItemGroup(this.getDelegator()));
|
||||
}
|
||||
return result;
|
||||
@@ -3503,11 +3404,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
if (dispatcher == null) return;
|
||||
synchronized (cartLines) {
|
||||
List<ShoppingCartItem> cartLineItems = new LinkedList<ShoppingCartItem>(cartLines);
|
||||
Iterator<ShoppingCartItem> itemIter = cartLineItems.iterator();
|
||||
|
||||
while (itemIter.hasNext()) {
|
||||
ShoppingCartItem item = itemIter.next();
|
||||
|
||||
for(ShoppingCartItem item : cartLineItems) {
|
||||
//Debug.logInfo("Item qty: " + item.getQuantity(), module);
|
||||
try {
|
||||
item.explodeItem(this, dispatcher);
|
||||
@@ -3528,10 +3425,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
public void explodeItems(List<ShoppingCartItem> shoppingCartItems, LocalDispatcher dispatcher) {
|
||||
if (dispatcher == null) return;
|
||||
synchronized (cartLines) {
|
||||
Iterator<ShoppingCartItem> itemIter = shoppingCartItems.iterator();
|
||||
while (itemIter.hasNext()) {
|
||||
ShoppingCartItem item = itemIter.next();
|
||||
|
||||
for(ShoppingCartItem item : shoppingCartItems) {
|
||||
//Debug.logInfo("Item qty: " + item.getQuantity(), module);
|
||||
try {
|
||||
item.explodeItem(this, dispatcher);
|
||||
@@ -3805,9 +3699,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
remainingAmount = BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
Iterator<CartPaymentInfo> i = paymentInfo.iterator();
|
||||
while (i.hasNext()) {
|
||||
CartPaymentInfo inf = i.next();
|
||||
for(CartPaymentInfo inf : paymentInfo) {
|
||||
if (inf.amount == null) {
|
||||
inf.amount = remainingAmount;
|
||||
remainingAmount = BigDecimal.ZERO;
|
||||
@@ -3826,11 +3718,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
Collection<GenericValue> infos = item.getOrderItemPriceInfos();
|
||||
|
||||
if (infos != null) {
|
||||
Iterator<GenericValue> infosIter = infos.iterator();
|
||||
|
||||
while (infosIter.hasNext()) {
|
||||
GenericValue orderItemPriceInfo = infosIter.next();
|
||||
|
||||
for(GenericValue orderItemPriceInfo : infos) {
|
||||
orderItemPriceInfo.set("orderItemSeqId", item.getOrderItemSeqId());
|
||||
allInfos.add(orderItemPriceInfo);
|
||||
}
|
||||
@@ -3861,15 +3749,11 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
/** make a list of SurveyResponse object to update with order information set */
|
||||
public List<GenericValue> makeAllOrderItemSurveyResponses() {
|
||||
List<GenericValue> allInfos = new LinkedList<GenericValue>();
|
||||
Iterator<ShoppingCartItem> itemIter = this.iterator();
|
||||
while (itemIter.hasNext()) {
|
||||
ShoppingCartItem item = itemIter.next();
|
||||
for(ShoppingCartItem item : this) {
|
||||
List<String> responses = UtilGenerics.checkList(item.getAttribute("surveyResponses"));
|
||||
GenericValue response = null;
|
||||
if (responses != null) {
|
||||
Iterator<String> ri = responses.iterator();
|
||||
while (ri.hasNext()) {
|
||||
String responseId = ri.next();
|
||||
for(String responseId : responses) {
|
||||
try {
|
||||
response = this.getDelegator().findByPrimaryKey("SurveyResponse", UtilMisc.toMap("surveyResponseId", responseId));
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -3935,10 +3819,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
|
||||
public List<GenericValue> makeAllShipGroupInfos() {
|
||||
List<GenericValue> groups = new LinkedList<GenericValue>();
|
||||
Iterator<CartShipInfo> grpIterator = this.shipInfo.iterator();
|
||||
long seqId = 1;
|
||||
while (grpIterator.hasNext()) {
|
||||
CartShipInfo csi = grpIterator.next();
|
||||
for(CartShipInfo csi : this.shipInfo) {
|
||||
groups.addAll(csi.makeItemShipGroupAndAssoc(this.getDelegator(), this, seqId));
|
||||
seqId++;
|
||||
}
|
||||
@@ -3961,9 +3843,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
|
||||
for (ShoppingCartItem item : cartLines) {
|
||||
Map<String, String> orderItemAttributes = item.getOrderItemAttributes();
|
||||
Iterator<String> attributesIter = orderItemAttributes.keySet().iterator();
|
||||
while (attributesIter.hasNext()) {
|
||||
String key = attributesIter.next();
|
||||
for(String key : orderItemAttributes.keySet()) {
|
||||
String value = orderItemAttributes.get(key);
|
||||
|
||||
GenericValue orderItemAttribute = getDelegator().makeValue("OrderItemAttribute");
|
||||
@@ -4200,11 +4080,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
Set<ShoppingCartItem> shipItems = shipInfo.getShipItems();
|
||||
if (UtilValidate.isEmpty(shipItems)) continue;
|
||||
|
||||
Iterator<ShoppingCartItem> siit = shipItems.iterator();
|
||||
while (siit.hasNext()) {
|
||||
|
||||
ShoppingCartItem cartItem = siit.next();
|
||||
|
||||
for(ShoppingCartItem cartItem : shipItems) {
|
||||
BigDecimal itemQuantity = cartItem.getQuantity();
|
||||
BigDecimal dropShipQuantity = BigDecimal.ZERO;
|
||||
|
||||
@@ -4276,10 +4152,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
}
|
||||
|
||||
// Reassign the drop-shippable item quantities to new or existing drop-ship groups
|
||||
Iterator<String> dsit = dropShipItems.keySet().iterator();
|
||||
while (dsit.hasNext()) {
|
||||
String supplierPartyId = dsit.next();
|
||||
|
||||
for (String supplierPartyId : dropShipItems.keySet()) {
|
||||
CartShipInfo shipInfo = null;
|
||||
int newShipGroupIndex = -1 ;
|
||||
|
||||
@@ -4296,15 +4169,9 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
shipInfo.supplierPartyId = supplierPartyId;
|
||||
|
||||
Map<ShoppingCartItem, Map<Integer, BigDecimal>> supplierCartItems = UtilGenerics.checkMap(dropShipItems.get(supplierPartyId));
|
||||
Iterator<ShoppingCartItem> itit = supplierCartItems.keySet().iterator();
|
||||
while (itit.hasNext()) {
|
||||
|
||||
ShoppingCartItem cartItem = itit.next();
|
||||
for(ShoppingCartItem cartItem : supplierCartItems.keySet()) {
|
||||
Map<Integer, BigDecimal> cartItemGroupQuantities = UtilGenerics.checkMap(supplierCartItems.get(cartItem));
|
||||
Iterator<Integer> cigit = cartItemGroupQuantities.keySet().iterator();
|
||||
while (cigit.hasNext()) {
|
||||
|
||||
Integer previousShipGroupIndex = cigit.next();
|
||||
for(Integer previousShipGroupIndex : cartItemGroupQuantities.keySet()) {
|
||||
BigDecimal dropShipQuantity = cartItemGroupQuantities.get(previousShipGroupIndex);
|
||||
positionItemToGroup(cartItem, dropShipQuantity, previousShipGroupIndex.intValue(), newShipGroupIndex, true);
|
||||
}
|
||||
@@ -4508,9 +4375,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
|
||||
public void clearAllTaxInfo() {
|
||||
this.shipTaxAdj.clear();
|
||||
Iterator<CartShipItemInfo> i = shipItemInfo.values().iterator();
|
||||
while (i.hasNext()) {
|
||||
CartShipItemInfo itemInfo = i.next();
|
||||
for(CartShipItemInfo itemInfo : shipItemInfo.values()) {
|
||||
itemInfo.itemTaxAdj.clear();
|
||||
}
|
||||
}
|
||||
@@ -4595,17 +4460,13 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
}
|
||||
|
||||
// create the top level tax adjustments
|
||||
Iterator<GenericValue> ti = shipTaxAdj.iterator();
|
||||
while (ti.hasNext()) {
|
||||
GenericValue taxAdj = ti.next();
|
||||
for(GenericValue taxAdj : shipTaxAdj) {
|
||||
taxAdj.set("shipGroupSeqId", shipGroupSeqId);
|
||||
values.add(taxAdj);
|
||||
}
|
||||
|
||||
// create the ship group item associations
|
||||
Iterator<ShoppingCartItem> i = shipItemInfo.keySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
ShoppingCartItem item = i.next();
|
||||
for(ShoppingCartItem item : shipItemInfo.keySet()) {
|
||||
CartShipItemInfo itemInfo = shipItemInfo.get(item);
|
||||
|
||||
GenericValue assoc = delegator.makeValue("OrderItemShipGroupAssoc");
|
||||
@@ -4615,9 +4476,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
values.add(assoc);
|
||||
|
||||
// create the item tax adjustment
|
||||
Iterator<GenericValue> iti = itemInfo.itemTaxAdj.iterator();
|
||||
while (iti.hasNext()) {
|
||||
GenericValue taxAdj = iti.next();
|
||||
for(GenericValue taxAdj : itemInfo.itemTaxAdj) {
|
||||
taxAdj.set("orderItemSeqId", item.getOrderItemSeqId());
|
||||
taxAdj.set("shipGroupSeqId", shipGroupSeqId);
|
||||
values.add(taxAdj);
|
||||
@@ -4871,9 +4730,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
throw new GeneralRuntimeException("Split Payment Preference per Ship Group does not yet support multiple Payment Methods");
|
||||
}
|
||||
if ("Y".equals(splitPayPrefPerShpGrp) && cart.paymentInfo.size() == 1) {
|
||||
Iterator<CartShipInfo> shipIter = cart.getShipGroups().iterator();
|
||||
while (shipIter.hasNext()) {
|
||||
CartShipInfo csi = shipIter.next();
|
||||
for(CartShipInfo csi : cart.getShipGroups()) {
|
||||
maxAmount = csi.getTotal().add(cart.getOrderOtherAdjustmentTotal().divide(new BigDecimal(cart.getShipGroupSize()), generalRounding)).add(csi.getShipEstimate().add(csi.getTotalTax(cart)));
|
||||
maxAmount = maxAmount.setScale(scale, rounding);
|
||||
|
||||
@@ -5065,10 +4922,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
}
|
||||
if (itemBasePrice == null) {
|
||||
List<GenericValue> productPriceList = EntityUtil.filterByDate(delegator.findList("ProductPrice", EntityCondition.makeCondition("productId", itemProductId), null, null, null, false));
|
||||
Iterator<GenericValue> it = productPriceList.iterator();
|
||||
Map<String, BigDecimal> productPriceMap = FastMap.newInstance();
|
||||
while (it.hasNext()) {
|
||||
GenericValue productPrice = it.next();
|
||||
for(GenericValue productPrice : productPriceList) {
|
||||
productPriceMap.put(productPrice.getString("productPriceTypeId"), productPrice.getBigDecimal("price"));
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(productPriceMap.get("SPECIAL_PROMO_PRICE"))) {
|
||||
|
||||
@@ -522,9 +522,7 @@ public class ShoppingCartEvents {
|
||||
productAssocs = delegator.findList("ProductAssoc", cond, null, null, null, false);
|
||||
productAssocs = EntityUtil.filterByDate(productAssocs);
|
||||
List<String> productList = FastList.newInstance();
|
||||
Iterator<GenericValue> iter = productAssocs.iterator();
|
||||
while (iter.hasNext()) {
|
||||
GenericValue productAssoc = iter.next();
|
||||
for(GenericValue productAssoc : productAssocs) {
|
||||
if (productId.equals(productAssoc.getString("productId"))) {
|
||||
productList.add(productAssoc.getString("productIdTo"));
|
||||
continue;
|
||||
@@ -534,9 +532,7 @@ public class ShoppingCartEvents {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Iterator<ShoppingCartItem> sciIter = cart.iterator();
|
||||
while (sciIter.hasNext()) {
|
||||
ShoppingCartItem sci = sciIter.next();
|
||||
for(ShoppingCartItem sci : cart) {
|
||||
if (productList.contains(sci.getProductId())) {
|
||||
try {
|
||||
cart.removeCartItem(sci, dispatcher);
|
||||
@@ -553,9 +549,7 @@ public class ShoppingCartEvents {
|
||||
EntityCondition.makeCondition("productAssocTypeId", EntityOperator.EQUALS, "PRODUCT_UPGRADE")), EntityOperator.AND);
|
||||
productList = delegator.findList("ProductAssoc", cond, UtilMisc.toSet("productId"), null, null, false);
|
||||
if (productList != null) {
|
||||
Iterator<ShoppingCartItem> sciIter = cart.iterator();
|
||||
while (sciIter.hasNext()) {
|
||||
ShoppingCartItem sci = sciIter.next();
|
||||
for(ShoppingCartItem sci : cart) {
|
||||
if (productList.contains(sci.getProductId())) {
|
||||
try {
|
||||
cart.removeCartItem(sci, dispatcher);
|
||||
|
||||
@@ -209,10 +209,8 @@ public class ShoppingCartHelper {
|
||||
|
||||
// Get the additional features selected for the product (if any)
|
||||
Map<String, Object> selectedFeatures = UtilHttp.makeParamMapWithPrefix(context, null, "FT", null);
|
||||
Iterator<String> selectedFeaturesTypes = selectedFeatures.keySet().iterator();
|
||||
Map<String, GenericValue> additionalFeaturesMap = FastMap.newInstance();
|
||||
while (selectedFeaturesTypes.hasNext()) {
|
||||
String selectedFeatureType = selectedFeaturesTypes.next();
|
||||
for(String selectedFeatureType : selectedFeatures.keySet()) {
|
||||
String selectedFeatureValue = (String)selectedFeatures.get(selectedFeatureType);
|
||||
if (UtilValidate.isNotEmpty(selectedFeatureValue)) {
|
||||
GenericValue productFeatureAndAppl = null;
|
||||
@@ -588,10 +586,7 @@ public class ShoppingCartHelper {
|
||||
}
|
||||
|
||||
BigDecimal totalQuantity = BigDecimal.ZERO;
|
||||
Iterator<GenericValue> pcmIter = prodCatMemberCol.iterator();
|
||||
|
||||
while (pcmIter.hasNext()) {
|
||||
GenericValue productCategoryMember = pcmIter.next();
|
||||
for(GenericValue productCategoryMember : prodCatMemberCol) {
|
||||
BigDecimal quantity = productCategoryMember.getBigDecimal("quantity");
|
||||
|
||||
if (quantity != null && quantity.compareTo(BigDecimal.ZERO) > 0) {
|
||||
@@ -621,13 +616,8 @@ public class ShoppingCartHelper {
|
||||
/** Delete an item from the shopping cart. */
|
||||
public Map<String, Object> deleteFromCart(Map<String, ? extends Object> context) {
|
||||
Map<String, Object> result = null;
|
||||
Set<String> names = context.keySet();
|
||||
Iterator<String> i = names.iterator();
|
||||
ArrayList<String> errorMsgs = new ArrayList<String>();
|
||||
|
||||
while (i.hasNext()) {
|
||||
String o = i.next();
|
||||
|
||||
for(String o : context.keySet()) {
|
||||
if (o.toUpperCase().startsWith("DELETE")) {
|
||||
try {
|
||||
String indexStr = o.substring(o.lastIndexOf('_') + 1);
|
||||
@@ -662,9 +652,6 @@ public class ShoppingCartHelper {
|
||||
ArrayList<ShoppingCartItem> deleteList = new ArrayList<ShoppingCartItem>();
|
||||
ArrayList<String> errorMsgs = new ArrayList<String>();
|
||||
|
||||
Set<String> parameterNames = context.keySet();
|
||||
Iterator<String> parameterNameIter = parameterNames.iterator();
|
||||
|
||||
BigDecimal oldQuantity = BigDecimal.ONE.negate();
|
||||
String oldDescription = "";
|
||||
BigDecimal oldPrice = BigDecimal.ONE.negate();
|
||||
@@ -677,8 +664,7 @@ public class ShoppingCartHelper {
|
||||
}
|
||||
|
||||
// TODO: This should be refactored to use UtilHttp.parseMultiFormData(parameters)
|
||||
while (parameterNameIter.hasNext()) {
|
||||
String parameterName = parameterNameIter.next();
|
||||
for(String parameterName : context.keySet()) {
|
||||
int underscorePos = parameterName.lastIndexOf('_');
|
||||
|
||||
if (underscorePos >= 0) {
|
||||
@@ -881,10 +867,7 @@ public class ShoppingCartHelper {
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<ShoppingCartItem> di = deleteList.iterator();
|
||||
|
||||
while (di.hasNext()) {
|
||||
ShoppingCartItem item = di.next();
|
||||
for(ShoppingCartItem item : deleteList) {
|
||||
int itemIndex = this.cart.getItemIndex(item);
|
||||
|
||||
if (Debug.infoOn())
|
||||
|
||||
@@ -1181,9 +1181,7 @@ public class ShoppingCartItem implements java.io.Serializable {
|
||||
if (UtilValidate.isNotEmpty(productSurvey) && UtilValidate.isNotEmpty(attributes)) {
|
||||
List<String> surveyResponses = UtilGenerics.checkList(attributes.get("surveyResponses"));
|
||||
if (UtilValidate.isNotEmpty(surveyResponses)) {
|
||||
Iterator<String> surveyItr = surveyResponses.iterator();
|
||||
while (surveyItr.hasNext()) {
|
||||
String surveyResponseId = surveyItr.next();
|
||||
for(String surveyResponseId : surveyResponses) {
|
||||
// TODO: implement multiple survey per product
|
||||
if (UtilValidate.isNotEmpty(surveyResponseId)) {
|
||||
priceContext.put("surveyResponseId", surveyResponseId);
|
||||
@@ -1860,17 +1858,13 @@ public class ShoppingCartItem implements java.io.Serializable {
|
||||
Debug.logError(e, "Unable to get features from product : " + product.get("productId"), module);
|
||||
}
|
||||
if (featureAppls != null) {
|
||||
Iterator<GenericValue> fai = featureAppls.iterator();
|
||||
while (fai.hasNext()) {
|
||||
GenericValue appl = fai.next();
|
||||
for(GenericValue appl : featureAppls) {
|
||||
featureSet.add(appl.getString("productFeatureId"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.additionalProductFeatureAndAppls != null) {
|
||||
Iterator<GenericValue> aapi = this.additionalProductFeatureAndAppls.values().iterator();
|
||||
while (aapi.hasNext()) {
|
||||
GenericValue appl = aapi.next();
|
||||
for(GenericValue appl : this.additionalProductFeatureAndAppls.values()) {
|
||||
featureSet.add(appl.getString("productFeatureId"));
|
||||
}
|
||||
}
|
||||
@@ -2111,9 +2105,7 @@ public class ShoppingCartItem implements java.io.Serializable {
|
||||
|
||||
public void addAllProductFeatureAndAppls(Map<String, GenericValue> productFeatureAndApplsToAdd) {
|
||||
if (productFeatureAndApplsToAdd == null) return;
|
||||
Iterator<GenericValue> productFeatureAndApplsToAddIter = productFeatureAndApplsToAdd.values().iterator();
|
||||
while (productFeatureAndApplsToAddIter.hasNext()) {
|
||||
GenericValue additionalProductFeatureAndAppl = productFeatureAndApplsToAddIter.next();
|
||||
for (GenericValue additionalProductFeatureAndAppl : productFeatureAndApplsToAdd.values()) {
|
||||
this.putAdditionalProductFeatureAndAppl(additionalProductFeatureAndAppl);
|
||||
}
|
||||
}
|
||||
@@ -2187,9 +2179,7 @@ public class ShoppingCartItem implements java.io.Serializable {
|
||||
Debug.logError(e, "Unable to get features from product : " + product.get("productId"), module);
|
||||
}
|
||||
if (featureAppls != null) {
|
||||
Iterator<GenericValue> fai = featureAppls.iterator();
|
||||
while (fai.hasNext()) {
|
||||
GenericValue appl = fai.next();
|
||||
for(GenericValue appl : featureAppls) {
|
||||
BigDecimal lastQuantity = featureMap.get(appl.getString("productFeatureId"));
|
||||
if (lastQuantity == null) {
|
||||
lastQuantity = BigDecimal.ZERO;
|
||||
@@ -2200,9 +2190,7 @@ public class ShoppingCartItem implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
if (this.additionalProductFeatureAndAppls != null) {
|
||||
Iterator<GenericValue> aapi = this.additionalProductFeatureAndAppls.values().iterator();
|
||||
while (aapi.hasNext()) {
|
||||
GenericValue appl = aapi.next();
|
||||
for(GenericValue appl : this.additionalProductFeatureAndAppls.values()) {
|
||||
BigDecimal lastQuantity = featureMap.get(appl.getString("productFeatureId"));
|
||||
if (lastQuantity == null) {
|
||||
lastQuantity = BigDecimal.ZERO;
|
||||
@@ -2575,10 +2563,8 @@ public class ShoppingCartItem implements java.io.Serializable {
|
||||
}
|
||||
|
||||
// add the cloned item(s) to the cart
|
||||
Iterator<ShoppingCartItem> newItemsItr = newItems.iterator();
|
||||
|
||||
while (newItemsItr.hasNext()) {
|
||||
cart.addItem(thisIndex, newItemsItr.next());
|
||||
for(ShoppingCartItem sci : newItems) {
|
||||
cart.addItem(thisIndex, sci);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -904,9 +904,7 @@ public class ShoppingCartServices {
|
||||
|
||||
// The cart item adjustments, derived from quote item adjustments, are added to the cart
|
||||
if (quoteItems != null) {
|
||||
Iterator<ShoppingCartItem> i = cart.iterator();
|
||||
while (i.hasNext()) {
|
||||
ShoppingCartItem item = i.next();
|
||||
for(ShoppingCartItem item : cart) {
|
||||
String orderItemSeqId = item.getOrderItemSeqId();
|
||||
if (orderItemSeqId != null) {
|
||||
adjs = orderAdjsMap.get(orderItemSeqId);
|
||||
@@ -1108,10 +1106,8 @@ public class ShoppingCartServices {
|
||||
result.put("displayGrandTotalCurrencyFormatted",org.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getDisplayGrandTotal(), isoCode, locale));
|
||||
BigDecimal orderAdjustmentsTotal = OrderReadHelper.calcOrderAdjustments(OrderReadHelper.getOrderHeaderAdjustments(shoppingCart.getAdjustments(), null), shoppingCart.getSubTotal(), true, true, true);
|
||||
result.put("displayOrderAdjustmentsTotalCurrencyFormatted", org.ofbiz.base.util.UtilFormatOut.formatCurrency(orderAdjustmentsTotal, isoCode, locale));
|
||||
Iterator<ShoppingCartItem> i = shoppingCart.iterator();
|
||||
Map<String, Object> cartItemData = FastMap.newInstance();
|
||||
while (i.hasNext()) {
|
||||
ShoppingCartItem cartLine = i.next();
|
||||
for(ShoppingCartItem cartLine : shoppingCart) {
|
||||
int cartLineIndex = shoppingCart.getItemIndex(cartLine);
|
||||
cartItemData.put("displayItemQty_" + cartLineIndex, cartLine.getQuantity());
|
||||
cartItemData.put("displayItemPrice_" + cartLineIndex, org.ofbiz.base.util.UtilFormatOut.formatCurrency(cartLine.getDisplayPrice(), isoCode, locale));
|
||||
@@ -1142,9 +1138,7 @@ public class ShoppingCartServices {
|
||||
public static Map<String, Object>resetShipGroupItems(DispatchContext dctx, Map<String, Object> context) {
|
||||
Map<String, Object> result = ServiceUtil.returnSuccess();
|
||||
ShoppingCart cart = (ShoppingCart) context.get("shoppingCart");
|
||||
Iterator<ShoppingCartItem> sciIter = cart.iterator();
|
||||
while (sciIter.hasNext()) {
|
||||
ShoppingCartItem item = sciIter.next();
|
||||
for(ShoppingCartItem item : cart) {
|
||||
cart.clearItemShipInfo(item);
|
||||
cart.setItemShipGroupQty(item, item.getQuantity(), 0);
|
||||
}
|
||||
@@ -1166,9 +1160,7 @@ public class ShoppingCartServices {
|
||||
return ServiceUtil.returnError(e.toString());
|
||||
}
|
||||
Map<String, Object> vendorMap = FastMap.newInstance();
|
||||
Iterator<ShoppingCartItem> sciIter = cart.iterator();
|
||||
while (sciIter.hasNext()) {
|
||||
ShoppingCartItem item = sciIter.next();
|
||||
for(ShoppingCartItem item : cart) {
|
||||
GenericValue vendorProduct = null;
|
||||
String productId = item.getParentProductId();
|
||||
if (productId == null) {
|
||||
|
||||
+4
-12
@@ -81,16 +81,12 @@ public class ProductDisplayWorker {
|
||||
List<GenericValue> productsCategories = delegator.findByAndCache("ProductCategoryMember", UtilMisc.toMap("productId", item.getProductId()), null);
|
||||
productsCategories = EntityUtil.filterByDate(productsCategories, true);
|
||||
if (productsCategories != null) {
|
||||
Iterator<GenericValue> productsCategoriesIter = productsCategories.iterator();
|
||||
while (productsCategoriesIter.hasNext()) {
|
||||
GenericValue productsCategoryMember = productsCategoriesIter.next();
|
||||
for(GenericValue productsCategoryMember : productsCategories) {
|
||||
GenericValue productsCategory = productsCategoryMember.getRelatedOneCache("ProductCategory");
|
||||
if ("CROSS_SELL_CATEGORY".equals(productsCategory.getString("productCategoryTypeId"))) {
|
||||
List<GenericValue> curPcms = productsCategory.getRelatedCache("ProductCategoryMember");
|
||||
if (curPcms != null) {
|
||||
Iterator<GenericValue> curPcmsIter = curPcms.iterator();
|
||||
while (curPcmsIter.hasNext()) {
|
||||
GenericValue curPcm = curPcmsIter.next();
|
||||
for(GenericValue curPcm : curPcms) {
|
||||
if (!products.containsKey(curPcm.getString("productId"))) {
|
||||
GenericValue product = curPcm.getRelatedOneCache("Product");
|
||||
products.put(product.getString("productId"), product);
|
||||
@@ -102,9 +98,7 @@ public class ProductDisplayWorker {
|
||||
}
|
||||
|
||||
if (UtilValidate.isNotEmpty(complementProducts)) {
|
||||
Iterator<GenericValue> complIter = complementProducts.iterator();
|
||||
while (complIter.hasNext()) {
|
||||
GenericValue productAssoc = complIter.next();
|
||||
for(GenericValue productAssoc : complementProducts) {
|
||||
if (!products.containsKey(productAssoc.getString("productIdTo"))) {
|
||||
GenericValue product = productAssoc.getRelatedOneCache("AssocProduct");
|
||||
products.put(product.getString("productId"), product);
|
||||
@@ -238,9 +232,7 @@ public class ProductDisplayWorker {
|
||||
// remove all products that are already in the cart
|
||||
ShoppingCart cart = (ShoppingCart) httpRequest.getSession().getAttribute("shoppingCart");
|
||||
if (UtilValidate.isNotEmpty(cart)) {
|
||||
Iterator<ShoppingCartItem> cartiter = cart.iterator();
|
||||
while (cartiter.hasNext()) {
|
||||
ShoppingCartItem item = cartiter.next();
|
||||
for(ShoppingCartItem item : cart) {
|
||||
String productId = item.getProductId();
|
||||
products.remove(productId);
|
||||
productQuantities.remove(productId);
|
||||
|
||||
+19
-55
@@ -328,9 +328,7 @@ public class ProductPromoWorker {
|
||||
// before sorting split into two lists and sort each list; one list for promos that have a order total condition, and the other list for all promos that don't; then we'll always run the ones that have no condition on the order total first
|
||||
List<Map<Object, Object>> productPromoDiscountMapList = FastList.newInstance();
|
||||
List<Map<Object, Object>> productPromoDiscountMapListOrderTotal = FastList.newInstance();
|
||||
Iterator<GenericValue> productPromoIter = productPromoList.iterator();
|
||||
while (productPromoIter.hasNext()) {
|
||||
GenericValue productPromo = productPromoIter.next();
|
||||
for(GenericValue productPromo : productPromoList) {
|
||||
Map<Object, Object> productPromoDiscountMap = UtilGenerics.checkMap(UtilMisc.toMap("productPromo", productPromo, "totalDiscountAmount", cart.getProductPromoUseTotalDiscount(productPromo.getString("productPromoId"))));
|
||||
if (hasOrderTotalCondition(productPromo, delegator)) {
|
||||
productPromoDiscountMapListOrderTotal.add(productPromoDiscountMap);
|
||||
@@ -370,9 +368,7 @@ public class ProductPromoWorker {
|
||||
protected static boolean hasOrderTotalCondition(GenericValue productPromo, Delegator delegator) throws GenericEntityException {
|
||||
boolean hasOtCond = false;
|
||||
List<GenericValue> productPromoConds = delegator.findByAndCache("ProductPromoCond", UtilMisc.toMap("productPromoId", productPromo.get("productPromoId")), UtilMisc.toList("productPromoCondSeqId"));
|
||||
Iterator<GenericValue> productPromoCondIter = productPromoConds.iterator();
|
||||
while (productPromoCondIter.hasNext()) {
|
||||
GenericValue productPromoCond = productPromoCondIter.next();
|
||||
for(GenericValue productPromoCond : productPromoConds) {
|
||||
String inputParamEnumId = productPromoCond.getString("inputParamEnumId");
|
||||
if ("PPIP_ORDER_TOTAL".equals(inputParamEnumId)) {
|
||||
hasOtCond = true;
|
||||
@@ -405,9 +401,7 @@ public class ProductPromoWorker {
|
||||
break;
|
||||
}
|
||||
|
||||
Iterator<GenericValue> productPromoIter = productPromoList.iterator();
|
||||
while (productPromoIter.hasNext()) {
|
||||
GenericValue productPromo = productPromoIter.next();
|
||||
for(GenericValue productPromo : productPromoList) {
|
||||
String productPromoId = productPromo.getString("productPromoId");
|
||||
|
||||
List<GenericValue> productPromoRules = productPromo.getRelatedCache("ProductPromoRule", null, null);
|
||||
@@ -742,7 +736,7 @@ public class ProductPromoWorker {
|
||||
}
|
||||
|
||||
protected static boolean runProductPromoRules(ShoppingCart cart, boolean cartChanged, Long useLimit, boolean requireCode, String productPromoCodeId, Long codeUseLimit, long maxUseLimit,
|
||||
GenericValue productPromo, List<GenericValue> productPromoRules, LocalDispatcher dispatcher, Delegator delegator, Timestamp nowTimestamp) throws GenericEntityException, UseLimitException {
|
||||
GenericValue productPromo, List<GenericValue> productPromoRules, LocalDispatcher dispatcher, Delegator delegator, Timestamp nowTimestamp) throws GenericEntityException, UseLimitException {
|
||||
String productPromoId = productPromo.getString("productPromoId");
|
||||
while ((useLimit == null || useLimit.longValue() > cart.getProductPromoUseCount(productPromoId)) &&
|
||||
(!requireCode || UtilValidate.isNotEmpty(productPromoCodeId)) &&
|
||||
@@ -920,9 +914,7 @@ public class ProductPromoWorker {
|
||||
Set<String> productIds = ProductPromoWorker.getPromoRuleCondProductIds(productPromoCond, delegator, nowTimestamp);
|
||||
|
||||
List<ShoppingCartItem> lineOrderedByBasePriceList = cart.getLineListOrderedByBasePrice(false);
|
||||
Iterator<ShoppingCartItem> lineOrderedByBasePriceIter = lineOrderedByBasePriceList.iterator();
|
||||
while (lineOrderedByBasePriceIter.hasNext()) {
|
||||
ShoppingCartItem cartItem = lineOrderedByBasePriceIter.next();
|
||||
for(ShoppingCartItem cartItem : lineOrderedByBasePriceList) {
|
||||
// only include if it is in the productId Set for this check and if it is not a Promo (GWP) item
|
||||
GenericValue product = cartItem.getProduct();
|
||||
String parentProductId = cartItem.getParentProductId();
|
||||
@@ -1408,9 +1400,7 @@ public class ProductPromoWorker {
|
||||
if ("Y".equals(productPromoAction.get("useCartQuantity"))) {
|
||||
quantity = BigDecimal.ZERO;
|
||||
List<ShoppingCartItem> used = getCartItemsUsed(cart, productPromoAction);
|
||||
Iterator<ShoppingCartItem> usedIt = used.iterator();
|
||||
while (usedIt.hasNext()) {
|
||||
ShoppingCartItem item = usedIt.next();
|
||||
for(ShoppingCartItem item : used) {
|
||||
BigDecimal available = item.getPromoQuantityAvailable();
|
||||
quantity = quantity.add(available).add(item.getPromoQuantityCandidateUseActionAndAllConds(productPromoAction));
|
||||
item.addPromoQuantityCandidateUse(available, productPromoAction, false);
|
||||
@@ -1435,9 +1425,7 @@ public class ProductPromoWorker {
|
||||
if ("Y".equals(product.getString("isVirtual"))) {
|
||||
List<GenericValue> productAssocs = EntityUtil.filterByDate(product.getRelatedCache("MainProductAssoc",
|
||||
UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("sequenceNum")));
|
||||
Iterator<GenericValue> productAssocIter = productAssocs.iterator();
|
||||
while (productAssocIter.hasNext()) {
|
||||
GenericValue productAssoc = productAssocIter.next();
|
||||
for(GenericValue productAssoc : productAssocs) {
|
||||
optionProductIds.add(productAssoc.getString("productIdTo"));
|
||||
}
|
||||
productId = null;
|
||||
@@ -1729,9 +1717,7 @@ public class ProductPromoWorker {
|
||||
Set<String> productIds = ProductPromoWorker.getPromoRuleActionProductIds(productPromoAction, delegator, nowTimestamp);
|
||||
|
||||
// go through the cart items and for each product that has a specialPromoPrice use that price
|
||||
Iterator<ShoppingCartItem> cartItemIter = cart.items().iterator();
|
||||
while (cartItemIter.hasNext()) {
|
||||
ShoppingCartItem cartItem = cartItemIter.next();
|
||||
for(ShoppingCartItem cartItem : cart.items()) {
|
||||
String itemProductId = cartItem.getProductId();
|
||||
if (UtilValidate.isEmpty(itemProductId)) {
|
||||
continue;
|
||||
@@ -1797,9 +1783,7 @@ public class ProductPromoWorker {
|
||||
|
||||
protected static List<ShoppingCartItem> getCartItemsUsed(ShoppingCart cart, GenericValue productPromoAction) {
|
||||
List<ShoppingCartItem> cartItemsUsed = FastList.newInstance();
|
||||
Iterator<ShoppingCartItem> cartItemsIter = cart.iterator();
|
||||
while (cartItemsIter.hasNext()) {
|
||||
ShoppingCartItem cartItem = cartItemsIter.next();
|
||||
for(ShoppingCartItem cartItem : cart) {
|
||||
BigDecimal quantityUsed = cartItem.getPromoQuantityCandidateUseActionAndAllConds(productPromoAction);
|
||||
if (quantityUsed.compareTo(BigDecimal.ZERO) > 0) {
|
||||
cartItemsUsed.add(cartItem);
|
||||
@@ -1810,9 +1794,7 @@ public class ProductPromoWorker {
|
||||
|
||||
protected static BigDecimal getCartItemsUsedTotalAmount(ShoppingCart cart, GenericValue productPromoAction) {
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
Iterator<ShoppingCartItem> cartItemsIter = cart.iterator();
|
||||
while (cartItemsIter.hasNext()) {
|
||||
ShoppingCartItem cartItem = cartItemsIter.next();
|
||||
for(ShoppingCartItem cartItem : cart) {
|
||||
BigDecimal quantityUsed = cartItem.getPromoQuantityCandidateUseActionAndAllConds(productPromoAction);
|
||||
if (quantityUsed.compareTo(BigDecimal.ZERO) > 0) {
|
||||
totalAmount = totalAmount.add(quantityUsed.multiply(cartItem.getBasePrice()));
|
||||
@@ -1994,9 +1976,7 @@ public class ProductPromoWorker {
|
||||
List<GenericValue> productPromoProductsAction = FastList.newInstance();
|
||||
List<GenericValue> productPromoCategoriesAction = FastList.newInstance();
|
||||
|
||||
Iterator<GenericValue> productPromoProductsAllIter = productPromoProductsAll.iterator();
|
||||
while (productPromoProductsAllIter.hasNext()) {
|
||||
GenericValue productPromoProduct = productPromoProductsAllIter.next();
|
||||
for(GenericValue productPromoProduct : productPromoProductsAll) {
|
||||
// if the rule id is null then this is a global promo one, so always include
|
||||
if (!"_NA_".equals(productPromoProduct.getString("productPromoCondSeqId")) || "_NA_".equals(productPromoProduct.getString("productPromoRuleId"))) {
|
||||
productPromoProductsCond.add(productPromoProduct);
|
||||
@@ -2005,9 +1985,7 @@ public class ProductPromoWorker {
|
||||
productPromoProductsAction.add(productPromoProduct);
|
||||
}
|
||||
}
|
||||
Iterator<GenericValue> productPromoCategoriesAllIter = productPromoCategoriesAll.iterator();
|
||||
while (productPromoCategoriesAllIter.hasNext()) {
|
||||
GenericValue productPromoCategory = productPromoCategoriesAllIter.next();
|
||||
for(GenericValue productPromoCategory : productPromoCategoriesAll) {
|
||||
if (!"_NA_".equals(productPromoCategory.getString("productPromoCondSeqId")) || "_NA_".equals(productPromoCategory.getString("productPromoRuleId"))) {
|
||||
productPromoCategoriesCond.add(productPromoCategory);
|
||||
}
|
||||
@@ -2054,9 +2032,7 @@ public class ProductPromoWorker {
|
||||
Set<String> productCategoryIds = FastSet.newInstance();
|
||||
Map<String, List<Set<String>>> productCategoryGroupSetListMap = FastMap.newInstance();
|
||||
|
||||
Iterator<GenericValue> productPromoCategoryIter = productPromoCategories.iterator();
|
||||
while (productPromoCategoryIter.hasNext()) {
|
||||
GenericValue productPromoCategory = productPromoCategoryIter.next();
|
||||
for(GenericValue productPromoCategory : productPromoCategories) {
|
||||
if (productPromoApplEnumId.equals(productPromoCategory.getString("productPromoApplEnumId"))) {
|
||||
Set<String> tempCatIdSet = FastSet.newInstance();
|
||||
if ("Y".equals(productPromoCategory.getString("includeSubCategories"))) {
|
||||
@@ -2104,17 +2080,13 @@ public class ProductPromoWorker {
|
||||
// now handle the productCategoryGroupSetListMap
|
||||
// if a set has more than one category (because of an include sub-cats) then do an or
|
||||
// all lists will have more than category because of the pre-pass that was done, so and them together
|
||||
Iterator<Map.Entry<String, List<Set<String>>>> pcgslmIter = productCategoryGroupSetListMap.entrySet().iterator();
|
||||
while (pcgslmIter.hasNext()) {
|
||||
Map.Entry<String, List<Set<String>>> entry = pcgslmIter.next();
|
||||
for(Map.Entry<String, List<Set<String>>> entry : productCategoryGroupSetListMap.entrySet()) {
|
||||
List<Set<String>> catIdSetList = entry.getValue();
|
||||
// get all productIds for this catIdSetList
|
||||
List<Set<String>> productIdSetList = FastList.newInstance();
|
||||
|
||||
Iterator<Set<String>> cidslIter = catIdSetList.iterator();
|
||||
while (cidslIter.hasNext()) {
|
||||
for(Set<String> catIdSet : catIdSetList) {
|
||||
// make a Set of productIds including all ids from all categories
|
||||
Set<String> catIdSet = cidslIter.next();
|
||||
Set<String> groupProductIdSet = FastSet.newInstance();
|
||||
getAllProductIds(catIdSet, groupProductIdSet, delegator, nowTimestamp, true);
|
||||
productIdSetList.add(groupProductIdSet);
|
||||
@@ -2123,9 +2095,7 @@ public class ProductPromoWorker {
|
||||
// now go through all productId sets and only include IDs that are in all sets
|
||||
// by definition if each id must be in all categories, then it must be in the first, so go through the first and drop each one that is not in all others
|
||||
Set<String> firstProductIdSet = productIdSetList.remove(0);
|
||||
Iterator<Set<String>> productIdSetIter = productIdSetList.iterator();
|
||||
while (productIdSetIter.hasNext()) {
|
||||
Set<String> productIdSet = productIdSetIter.next();
|
||||
for(Set<String> productIdSet : productIdSetList) {
|
||||
firstProductIdSet.retainAll(productIdSet);
|
||||
}
|
||||
|
||||
@@ -2161,15 +2131,11 @@ public class ProductPromoWorker {
|
||||
}
|
||||
|
||||
protected static void getAllProductIds(Set<String> productCategoryIdSet, Set<String> productIdSet, Delegator delegator, Timestamp nowTimestamp, boolean include) throws GenericEntityException {
|
||||
Iterator<String> productCategoryIdIter = productCategoryIdSet.iterator();
|
||||
while (productCategoryIdIter.hasNext()) {
|
||||
String productCategoryId = productCategoryIdIter.next();
|
||||
for(String productCategoryId : productCategoryIdSet) {
|
||||
// get all product category memebers, filter by date
|
||||
List<GenericValue> productCategoryMembers = delegator.findByAndCache("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId));
|
||||
productCategoryMembers = EntityUtil.filterByDate(productCategoryMembers, nowTimestamp);
|
||||
Iterator<GenericValue> productCategoryMemberIter = productCategoryMembers.iterator();
|
||||
while (productCategoryMemberIter.hasNext()) {
|
||||
GenericValue productCategoryMember = productCategoryMemberIter.next();
|
||||
for(GenericValue productCategoryMember : productCategoryMembers) {
|
||||
String productId = productCategoryMember.getString("productId");
|
||||
if (include) {
|
||||
productIdSet.add(productId);
|
||||
@@ -2182,9 +2148,7 @@ public class ProductPromoWorker {
|
||||
|
||||
protected static void handleProductPromoProducts(Set<String> productIds, List<GenericValue> productPromoProducts, String productPromoApplEnumId) throws GenericEntityException {
|
||||
boolean include = !"PPPA_EXCLUDE".equals(productPromoApplEnumId);
|
||||
Iterator<GenericValue> productPromoProductIter = productPromoProducts.iterator();
|
||||
while (productPromoProductIter.hasNext()) {
|
||||
GenericValue productPromoProduct = productPromoProductIter.next();
|
||||
for(GenericValue productPromoProduct : productPromoProducts) {
|
||||
if (productPromoApplEnumId.equals(productPromoProduct.getString("productPromoApplEnumId"))) {
|
||||
String productId = productPromoProduct.getString("productId");
|
||||
if (include) {
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.ofbiz.order.shoppinglist;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -228,9 +227,7 @@ public class ShoppingListEvents {
|
||||
// include all items of child lists if flagged to do so
|
||||
if (includeChild) {
|
||||
List<GenericValue> childShoppingLists = shoppingList.getRelated("ChildShoppingList");
|
||||
Iterator<GenericValue> ci = childShoppingLists.iterator();
|
||||
while (ci.hasNext()) {
|
||||
GenericValue v = ci.next();
|
||||
for(GenericValue v : childShoppingLists) {
|
||||
List<GenericValue> items = v.getRelated("ShoppingListItem");
|
||||
shoppingListItems.addAll(items);
|
||||
}
|
||||
@@ -260,9 +257,7 @@ public class ShoppingListEvents {
|
||||
|
||||
// add the items
|
||||
StringBuilder eventMessage = new StringBuilder();
|
||||
Iterator<GenericValue> i = shoppingListItems.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue shoppingListItem = i.next();
|
||||
for(GenericValue shoppingListItem : shoppingListItems) {
|
||||
String productId = shoppingListItem.getString("productId");
|
||||
BigDecimal quantity = shoppingListItem.getBigDecimal("quantity");
|
||||
Timestamp reservStart = shoppingListItem.getTimestamp("reservStart");
|
||||
@@ -556,10 +551,8 @@ public class ShoppingListEvents {
|
||||
*/
|
||||
public static int makeListItemSurveyResp(Delegator delegator, GenericValue item, List<String> surveyResps) throws GenericEntityException {
|
||||
if (UtilValidate.isNotEmpty(surveyResps)) {
|
||||
Iterator<String> i = surveyResps.iterator();
|
||||
int count = 0;
|
||||
while (i.hasNext()) {
|
||||
String responseId = i.next();
|
||||
for(String responseId : surveyResps) {
|
||||
GenericValue listResp = delegator.makeValue("ShoppingListItemSurvey");
|
||||
listResp.set("shoppingListId", item.getString("shoppingListId"));
|
||||
listResp.set("shoppingListItemSeqId", item.getString("shoppingListItemSeqId"));
|
||||
@@ -578,9 +571,7 @@ public class ShoppingListEvents {
|
||||
public static Map<String, List<String>> getItemSurveyInfos(List<GenericValue> items) {
|
||||
Map<String, List<String>> surveyInfos = FastMap.newInstance();
|
||||
if (UtilValidate.isNotEmpty(items)) {
|
||||
Iterator<GenericValue> itemIt = items.iterator();
|
||||
while (itemIt.hasNext()) {
|
||||
GenericValue item = itemIt.next();
|
||||
for(GenericValue item : items) {
|
||||
String listId = item.getString("shoppingListId");
|
||||
String itemId = item.getString("shoppingListItemSeqId");
|
||||
surveyInfos.put(listId + "." + itemId, getItemSurveyInfo(item));
|
||||
@@ -603,9 +594,7 @@ public class ShoppingListEvents {
|
||||
}
|
||||
|
||||
if (UtilValidate.isNotEmpty(surveyResp)) {
|
||||
Iterator<GenericValue> respIt = surveyResp.iterator();
|
||||
while (respIt.hasNext()) {
|
||||
GenericValue resp = respIt.next();
|
||||
for(GenericValue resp : surveyResp) {
|
||||
responseIds.add(resp.getString("surveyResponseId"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.ofbiz.order.shoppinglist;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Date;
|
||||
@@ -326,11 +325,8 @@ public class ShoppingListServices {
|
||||
}
|
||||
|
||||
List<GenericValue> orderItems = orh.getOrderItems();
|
||||
Iterator<GenericValue> i = orderItems.iterator();
|
||||
String productId = null;
|
||||
while (i.hasNext()) {
|
||||
GenericValue orderItem = i.next();
|
||||
productId = orderItem.getString("productId");
|
||||
for(GenericValue orderItem : orderItems) {
|
||||
String productId = orderItem.getString("productId");
|
||||
if (UtilValidate.isNotEmpty(productId)) {
|
||||
Map<String, Object> ctx = UtilMisc.<String, Object>toMap("userLogin", userLogin, "shoppingListId", shoppingListId, "productId",
|
||||
orderItem.get("productId"), "quantity", orderItem.get("quantity"));
|
||||
@@ -471,10 +467,8 @@ public class ShoppingListServices {
|
||||
}
|
||||
|
||||
|
||||
Iterator<GenericValue> i = items.iterator();
|
||||
ProductConfigWrapper configWrapper = null;
|
||||
while (i.hasNext()) {
|
||||
GenericValue shoppingListItem = i.next();
|
||||
for(GenericValue shoppingListItem : items) {
|
||||
String productId = shoppingListItem.getString("productId");
|
||||
BigDecimal quantity = shoppingListItem.getBigDecimal("quantity");
|
||||
Timestamp reservStart = shoppingListItem.getTimestamp("reservStart");
|
||||
@@ -565,9 +559,7 @@ public class ShoppingListServices {
|
||||
String orderId = (String) context.get("orderId");
|
||||
try {
|
||||
List<GenericValue> orderItems = delegator.findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId));
|
||||
Iterator<GenericValue> iter = orderItems.iterator();
|
||||
while (iter.hasNext()) {
|
||||
GenericValue orderItem = iter.next();
|
||||
for(GenericValue orderItem : orderItems) {
|
||||
String shoppingListId = orderItem.getString("shoppingListId");
|
||||
String shoppingListItemSeqId = orderItem.getString("shoppingListItemSeqId");
|
||||
if (UtilValidate.isNotEmpty(shoppingListId)) {
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.ofbiz.order.test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -96,9 +95,7 @@ public class OrderTestServices {
|
||||
if (result.get("categoryMembers") != null) {
|
||||
List<GenericValue> productCategoryMembers = UtilGenerics.checkList(result.get("categoryMembers"));
|
||||
if (productCategoryMembers != null) {
|
||||
Iterator<GenericValue> i = productCategoryMembers.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue prodCatMemb = i.next();
|
||||
for(GenericValue prodCatMemb : productCategoryMembers) {
|
||||
if (prodCatMemb != null) {
|
||||
productsList.add(prodCatMemb.getString("productId"));
|
||||
}
|
||||
|
||||
+1
-3
@@ -362,13 +362,11 @@ public class ZipSalesServices {
|
||||
}
|
||||
|
||||
if (ruleLookup != null) {
|
||||
Iterator<GenericValue> ruleIterator = ruleLookup.iterator();
|
||||
while (ruleIterator.hasNext()) {
|
||||
for(GenericValue rule : ruleLookup) {
|
||||
if (!taxShipping) {
|
||||
// if we found an rule which passes no need to contine (all rules are ||)
|
||||
break;
|
||||
}
|
||||
GenericValue rule = ruleIterator.next();
|
||||
String idCode = rule.getString("idCode");
|
||||
String taxable = rule.getString("taxable");
|
||||
String condition = rule.getString("shipCond");
|
||||
|
||||
Reference in New Issue
Block a user