Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
1081 posts
|
Modified: ofbiz/branches/20111205EmailHandling/applications/order/script/org/ofbiz/order/quote/QuoteServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/applications/order/script/org/ofbiz/order/quote/QuoteServices.xml?rev=1305581&r1=1305580&r2=1305581&view=diff ============================================================================== --- ofbiz/branches/20111205EmailHandling/applications/order/script/org/ofbiz/order/quote/QuoteServices.xml (original) +++ ofbiz/branches/20111205EmailHandling/applications/order/script/org/ofbiz/order/quote/QuoteServices.xml Mon Mar 26 20:56:02 2012 @@ -351,7 +351,10 @@ under the License. <if> <condition> <and> - <if-compare operator="equals" value="AGGREGATED" field="product.productTypeId"></if-compare> + <or> + <if-compare operator="equals" value="AGGREGATED" field="product.productTypeId"/> + <if-compare operator="equals" value="AGGREGATED_SERVICE" field="product.productTypeId"/> + </or> <not><if-empty field="parameters.configId"></if-empty></not> </and> </condition> Modified: ofbiz/branches/20111205EmailHandling/applications/order/script/org/ofbiz/order/test/ShoppingCartTests.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/applications/order/script/org/ofbiz/order/test/ShoppingCartTests.xml?rev=1305581&r1=1305580&r2=1305581&view=diff ============================================================================== --- ofbiz/branches/20111205EmailHandling/applications/order/script/org/ofbiz/order/test/ShoppingCartTests.xml (original) +++ ofbiz/branches/20111205EmailHandling/applications/order/script/org/ofbiz/order/test/ShoppingCartTests.xml Mon Mar 26 20:56:02 2012 @@ -541,7 +541,7 @@ under the License. <set field="createQuoteAdjustmentMap.quoteId" from-field="quoteId"/> <set field="createQuoteAdjustmentMap.quoteItemSeqId" from-field="quoteItemSeqId"/> <set field="createQuoteAdjustmentMap.amount" value="15.00" type="BigDecimal"/> - <set field="createQuoteAdjustmentMap.includeInShipping " value="N"/> + <set field="createQuoteAdjustmentMap.includeInShipping" value="N"/> <set field="createQuoteAdjustmentMap.includeInTax" value="Y"/> <set field="createQuoteAdjustmentMap.quoteAdjustmentTypeId" value="SALES_TAX"/> <set field="createQuoteAdjustmentMap.taxAuthGeoId" value="UT"/> @@ -576,4 +576,100 @@ under the License. <check-errors/> </simple-method> + <simple-method method-name="testCreateOrderConfigurableServiceProduct" short-description="Test create an order using a configurable service product" login-required="false"> + <set field="request" from-field="parameters.request"/> + <set field="response" from-field="parameters.response"/> + <call-class-method method-name="routeOrderEntry" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : routeOrderEntry, Response : ${result}"/> + <!-- Set parameters --> + <set field="testParams.add_product_id" value="CFSV1001"/> + <set field="testParams.product_id" value="CFSV1001"/> + <set field="testParams.FT0_0_0TYPE" value="SCAN_TYPE"/> + <set field="testParams.product_id0_0_0" value="SCAN_TYPE"/> + <set field="testParams.0" value="0"/> + <set field="testParams.add_product_id0_0_0" value="SCAN-EC"/> + <set field="testParams.productStoreId" value="9000"/> + <set field="testParams.currencyUom" value="USD"/> + <set field="testParams.quantity" value="1"/> + <set field="testParams.orderMode" value="SALES_ORDER"/> + <set field="testParams.partyId" value="DemoCustomer"/> + <set field="testParams.checkoutpage" value="quick"/> + <set field="testParams.shipping_contact_mech_id" value="9015"/> + <set field="testParams.shipping_method" value="GROUND@UPS"/> + <set field="testParams.checkOutPaymentId" value="EXT_COD"/> + <set field="testParams.is_gift" value="false"/> + <set field="testParams.may_split" value="false"/> + <call-object-method method-name="addParameters" obj-field="request"> + <field field="testParams" type="java.util.Map"/> + </call-object-method> + + <entity-one value-field="userLogin" entity-name="UserLogin"> + <field-map field-name="userLoginId" value="DemoCustomer"/> + </entity-one> + <call-bsh><![CDATA[ + session = request.getSession(); + session.setAttribute("userLogin", userLogin); + ]]></call-bsh> + <call-class-method method-name="initializeOrderEntry" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : initializeOrderEntry, Response : ${result}"/> + <call-class-method method-name="setOrderCurrencyAgreementShipDates" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : setOrderCurrencyAgreementShipDates, Response : ${result}"/> + + <call-class-method method-name="addToCart" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : addToCart, Response : ${result}"/> + + <field-to-request field="nullField" request-name="shoppingCart"/> + <call-class-method method-name="setQuickCheckOutOptions" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : setQuickCheckOutOptions, Response : ${result}"/> + <call-class-method method-name="createOrder" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="orderCreateResult"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : createOrder, Response : ${orderCreateResult}"/> + <call-class-method method-name="processPayment" class-name="org.ofbiz.order.shoppingcart.CheckOutEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : processPayment, Response : ${result}"/> + <call-service-asynch service-name="sendOrderConfirmation"/> + <call-class-method method-name="destroyCart" class-name="org.ofbiz.order.shoppingcart.ShoppingCartEvents" ret-field="result"> + <field field="request" type="javax.servlet.http.HttpServletRequest"/> + <field field="response" type="javax.servlet.http.HttpServletResponse"/> + </call-class-method> + <log level="info" message="===== >>> Event : destroyCart, Response = ${result}"/> + <entity-condition list="orderHeaders" entity-name="OrderHeader"> + <condition-expr field-name="orderTypeId" value="SALES_ORDER"/> + <order-by field-name="-entryDate"/> + </entity-condition> + <first-from-list entry="orderHeader" list="orderHeaders"/> + <set field="orderId" from-field="orderHeader.orderId"/> + <log level="info" message="======== Test order with id: [${orderId}] has been approved: [${approved}]========"/> + + <entity-one entity-name="UserLogin" value-field="systemUserLogin"> + <field-map field-name="userLoginId" value="system"/> + </entity-one> + <set field="quickShipEntireOrderMap.orderId" from-field="orderId"/> + <set field="quickShipEntireOrderMap.userLogin" from-field="systemUserLogin"/> + <call-service service-name="quickShipEntireOrder" in-map-name="quickShipEntireOrderMap"/> + <log level="info" message="========Test order with id: [${orderId}] has been shipped"/> + + <assert><not><if-empty field="orderId"/></not></assert> + <check-errors/> + </simple-method> + </simple-methods> Modified: ofbiz/branches/20111205EmailHandling/applications/order/servicedef/secas.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/applications/order/servicedef/secas.xml?rev=1305581&r1=1305580&r2=1305581&view=diff ============================================================================== --- ofbiz/branches/20111205EmailHandling/applications/order/servicedef/secas.xml (original) +++ ofbiz/branches/20111205EmailHandling/applications/order/servicedef/secas.xml Mon Mar 26 20:56:02 2012 @@ -314,6 +314,17 @@ under the License. <condition field-name="custRequestId" operator="is-not-empty"/> <action service="updateCommunicationEvent" mode="sync"/> </eca> + + <!-- send a system note to all Customer request participants (excluding the originator) + when a note is added to a particular customer request.--> + <eca service="createCustRequestItemNote" event="commit"> + <set field-name="noteParty" env-name="partyId"/> + <set field-name="noteInfo" value="A note has been added to customer request"/> + <set field-name="moreInfoItemName" value="custRequestId"/> + <set field-name="moreInfoItemId" env-name="custRequestId"/> + <set field-name="moreInfoUrl" value="/ordermgr/control/ViewRequest"/> + <action service="createSystemInfoNote" mode="sync"/> + </eca> <!-- Requirement / CustRequestItem association event --> <eca service="createRequirement" event="commit"> @@ -436,4 +447,8 @@ under the License. <condition field-name="orderTypeId" operator="equals" value="SALES_ORDER"/> <action service="checkOrderItemForProductGroupOrder" mode="sync"/> </eca> + <eca service="changeOrderStatus" event="commit"> + <condition field-name="statusId" operator="equals" value="ORDER_CANCELLED"/> + <action service="checkOrderItemForProductGroupOrder" mode="sync"/> + </eca> </service-eca> Modified: ofbiz/branches/20111205EmailHandling/applications/order/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/applications/order/servicedef/services.xml?rev=1305581&r1=1305580&r2=1305581&view=diff ============================================================================== --- ofbiz/branches/20111205EmailHandling/applications/order/servicedef/services.xml (original) +++ ofbiz/branches/20111205EmailHandling/applications/order/servicedef/services.xml Mon Mar 26 20:56:02 2012 @@ -184,12 +184,8 @@ under the License. <service name="orderAdjustmentPermissionCheck" engine="simple" location="component://order/script/org/ofbiz/order/order/OrderSimpleMethods.xml" invoke="orderAdjustmentPermissionCheck"> - <description> - Performs a party contact mech security check. The userLogin partyId must equal the partyId parameter. - Only the order owner should be able to cancel an item from Ecommerce. - </description> + <description>Permission service for the creation and editing of order adjustments</description> <implements service="permissionInterface"/> - <attribute name="partyId" type="String" mode="IN" optional="true"/> </service> <service name="createOrderAdjustment" default-entity-name="OrderAdjustment" engine="simple" Modified: ofbiz/branches/20111205EmailHandling/applications/order/servicedef/services_return.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/applications/order/servicedef/services_return.xml?rev=1305581&r1=1305580&r2=1305581&view=diff ============================================================================== --- ofbiz/branches/20111205EmailHandling/applications/order/servicedef/services_return.xml (original) +++ ofbiz/branches/20111205EmailHandling/applications/order/servicedef/services_return.xml Mon Mar 26 20:56:02 2012 @@ -63,7 +63,6 @@ under the License. <auto-attributes entity-name="ReturnItem" include="all" mode="IN" optional="true"> <exclude field-name="returnItemSeqId"/> </auto-attributes> - <attribute name="returnItemMapKey" type="String" mode="IN" optional="true"/> <attribute name="includeAdjustments" type="String" mode="IN" optional="true"/> <!-- The default is "Y": the adjustments associated with the item are included in the return --> <attribute name="returnItemSeqId" type="String" mode="OUT" optional="false"/> <override name="returnId" optional="false"/> Modified: ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/OrderManagerEvents.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/OrderManagerEvents.java?rev=1305581&r1=1305580&r2=1305581&view=diff ============================================================================== --- ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/OrderManagerEvents.java (original) +++ ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/OrderManagerEvents.java Mon Mar 26 20:56:02 2012 @@ -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; Modified: ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderChangeHelper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderChangeHelper.java?rev=1305581&r1=1305580&r2=1305581&view=diff ============================================================================== --- ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderChangeHelper.java (original) +++ ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderChangeHelper.java Mon Mar 26 20:56:02 2012 @@ -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)) { Modified: ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderListState.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderListState.java?rev=1305581&r1=1305580&r2=1305581&view=diff ============================================================================== --- ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderListState.java (original) +++ ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderListState.java Mon Mar 26 20:56:02 2012 @@ -18,6 +18,7 @@ */ package org.ofbiz.order.order; +import java.io.Serializable; import java.sql.Timestamp; import java.util.Iterator; import java.util.List; @@ -55,7 +56,8 @@ import org.ofbiz.entity.util.EntityListI * objects, including Pagination. Think about design * patterns in Fowler. */ -public class OrderListState { +@SuppressWarnings("serial") +public class OrderListState implements Serializable { public static final String module = OrderListState.class.getName(); public static final String SESSION_KEY = "__ORDER_LIST_STATUS__"; @@ -165,8 +167,7 @@ public class OrderListState { } 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"); @@ -174,8 +175,7 @@ public class OrderListState { 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"); @@ -183,8 +183,7 @@ public class OrderListState { 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"); @@ -242,14 +241,12 @@ public class OrderListState { } 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))); } Modified: ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java?rev=1305581&r1=1305580&r2=1305581&view=diff ============================================================================== --- ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java (original) +++ ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java Mon Mar 26 20:56:02 2012 @@ -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"))); } } @@ -563,7 +548,7 @@ public class OrderLookupServices { } if (Debug.verboseOn()) { - Debug.log("Find order query: " + cond.toString()); + Debug.logInfo("Find order query: " + cond.toString(), module); } List<GenericValue> orderList = FastList.newInstance(); @@ -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(); Modified: ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java?rev=1305581&r1=1305580&r2=1305581&view=diff ============================================================================== --- ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java (original) +++ ofbiz/branches/20111205EmailHandling/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java Mon Mar 26 20:56:02 2012 @@ -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); } } @@ -2454,7 +2362,7 @@ public class OrderReadHelper { while (itemIter != null && itemIter.hasNext()) { GenericValue orderItem = itemIter.next(); BigDecimal itemTotal = getOrderItemSubTotal(orderItem, adjustments); - // Debug.log("Item : " + orderItem.getString("orderId") + " / " + orderItem.getString("orderItemSeqId") + " = " + itemTotal, module); + // 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); @@ -2464,7 +2372,7 @@ public class OrderReadHelper { itemTotal = itemTotal.multiply(getWorkEffortRentalQuantity(workEffort)).setScale(scale, rounding); break; } -// Debug.log("Item : " + orderItem.getString("orderId") + " / " + orderItem.getString("orderItemSeqId") + " = " + itemTotal, module); +// Debug.logInfo("Item : " + orderItem.getString("orderId") + " / " + orderItem.getString("orderItemSeqId") + " = " + itemTotal, module); } } result = result.add(itemTotal).setScale(scale, rounding); @@ -2636,11 +2544,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 +2556,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 +2593,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 +2642,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 +2696,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 +2724,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 +2745,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); @@ -2884,6 +2773,37 @@ public class OrderReadHelper { return EntityUtil.orderBy(EntityUtil.filterByAnd(newOrderStatuses, contraints2), UtilMisc.toList("-statusDatetime")); } + public static String getOrderItemAttribute(GenericValue orderItem, String attributeName) { + String attributeValue = null; + if (orderItem != null) { + try { + GenericValue orderItemAttribute = EntityUtil.getFirst(orderItem.getRelatedByAnd("OrderItemAttribute", UtilMisc.toMap("attrName", attributeName))); + if (orderItemAttribute != null) { + attributeValue = orderItemAttribute.getString("attrValue"); + } + } catch (GenericEntityException e) { + Debug.logError(e, module); + } + } + return attributeValue; + } + + public String getOrderAttribute(String attributeName) { + String attributeValue = null; + if (orderHeader != null) { + try { + GenericValue orderAttribute = EntityUtil.getFirst(orderHeader.getRelatedByAnd("OrderAttribute", UtilMisc.toMap("attrName", attributeName))); + if (orderAttribute != null) { + attributeValue = orderAttribute.getString("attrValue"); + } + } catch (GenericEntityException e) { + Debug.logError(e, module); + } + } + return attributeValue; + } + + public static Map<String, Object> getOrderTaxByTaxAuthGeoAndParty(List<GenericValue> orderAdjustments) { BigDecimal taxGrandTotal = BigDecimal.ZERO; List<Map<String, Object>> taxByTaxAuthGeoAndPartyList = FastList.newInstance(); |
Free forum by Nabble | Edit this page |