svn commit: r882342 [1/2] - in /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting: ./ invoice/ payment/ period/ tax/ test/ thirdparty/clearcommerce/ thirdparty/gosoftware/ thirdparty/valuelink/ util/

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

svn commit: r882342 [1/2] - in /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting: ./ invoice/ payment/ period/ tax/ test/ thirdparty/clearcommerce/ thirdparty/gosoftware/ thirdparty/valuelink/ util/

jleroux@apache.org
Author: jleroux
Date: Thu Nov 19 22:45:56 2009
New Revision: 882342

URL: http://svn.apache.org/viewvc?rev=882342&view=rev
Log:
Revert r882217 and by consequence r882217 from Adam's advice on dev ML

Modified:
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/GiftCertificateServices.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/gosoftware/PcChargeServices.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java?rev=882342&r1=882341&r2=882342&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java Thu Nov 19 22:45:56 2009
@@ -19,6 +19,7 @@
 package org.ofbiz.accounting;
 
 import java.math.BigDecimal;
+import java.util.List;
 import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?rev=882342&r1=882341&r2=882342&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java Thu Nov 19 22:45:56 2009
@@ -1158,7 +1158,7 @@
         return serviceResult;
     }
 
-    public static Map<String, Object> createInvoicesFromShipments(DispatchContext dctx, Map<String, Object> context) {
+    public static Map<String, Object> createInvoicesFromShipments(DispatchContext dctx, Map context) {
         Delegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
         List<String> shipmentIds = UtilGenerics.checkList(context.get("shipmentIds"));

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java?rev=882342&r1=882341&r2=882342&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java Thu Nov 19 22:45:56 2009
@@ -106,11 +106,12 @@
     }
 
     /** Method to get the taxable invoice item types as a List of invoiceItemTypeIds.  These are identified in Enumeration with enumTypeId TAXABLE_INV_ITM_TY. */
-    public static List<String> getTaxableInvoiceItemTypeIds(Delegator delegator) throws GenericEntityException {
-        List<String> typeIds = FastList.newInstance();
-        List<GenericValue> invoiceItemTaxTypes = delegator.findByAndCache("Enumeration", UtilMisc.toMap("enumTypeId", "TAXABLE_INV_ITM_TY"));
-        for (GenericValue invoiceItemTaxType : invoiceItemTaxTypes) {
-            typeIds.add((String) invoiceItemTaxType.get("enumId"));
+    public static List getTaxableInvoiceItemTypeIds(Delegator delegator) throws GenericEntityException {
+        List typeIds = FastList.newInstance();
+        List invoiceItemTaxTypes = delegator.findByAndCache("Enumeration", UtilMisc.toMap("enumTypeId", "TAXABLE_INV_ITM_TY"));
+        for (Iterator iter = invoiceItemTaxTypes.iterator(); iter.hasNext();) {
+            GenericValue invoiceItemTaxType = (GenericValue) iter.next();
+            typeIds.add(invoiceItemTaxType.getString("enumId"));
         }
         return typeIds;
     }
@@ -121,27 +122,32 @@
 
         if (invoice == null)
            throw new IllegalArgumentException("The invoiceId passed does not match an existing invoice");
-        List<GenericValue> invoiceTaxItems = null;
+        List invoiceTaxItems = null;
         try {
             Delegator delegator = invoice.getDelegator();
-            EntityConditionList<EntityCondition> condition = EntityCondition.makeCondition(UtilMisc.toList(
-                    (EntityCondition)EntityCondition.makeCondition("invoiceId", invoice.get("invoiceId")),
+            EntityConditionList condition = EntityCondition.makeCondition(UtilMisc.toList(
+                    EntityCondition.makeCondition("invoiceId", invoice.getString("invoiceId")),
                     EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.IN, getTaxableInvoiceItemTypeIds(delegator))),
                     EntityOperator.AND);
             invoiceTaxItems = delegator.findList("InvoiceItem", condition, null, null, null, false);
         } catch (GenericEntityException e) {
             Debug.logError(e, "Trouble getting InvoiceItem list", module);
         }
-        for(GenericValue invoiceItem : invoiceTaxItems) {
-            BigDecimal amount = invoiceItem.getBigDecimal("amount");
-            BigDecimal quantity = invoiceItem.getBigDecimal("quantity");
-            if (amount == null)
-                amount = ZERO;
-            if (quantity == null)
-                quantity = ONE;
-            invoiceTaxTotal = invoiceTaxTotal.add(amount.multiply(quantity)).setScale(decimals + 1, rounding);
+        if (UtilValidate.isNotEmpty(invoiceTaxItems)) {
+            Iterator invoiceItemsIter = invoiceTaxItems.iterator();
+            while (invoiceItemsIter.hasNext()) {
+                GenericValue invoiceItem = (GenericValue) invoiceItemsIter.next();
+                BigDecimal amount = invoiceItem.getBigDecimal("amount");
+                BigDecimal quantity = invoiceItem.getBigDecimal("quantity");
+                if (amount == null)
+                    amount = ZERO;
+                if (quantity == null)
+                    quantity = ONE;
+                invoiceTaxTotal = invoiceTaxTotal.add(amount.multiply(quantity)).setScale(decimals + 1, rounding);
+            }
         }
         return invoiceTaxTotal.setScale(decimals, rounding);
+
     }
 
     public static BigDecimal getInvoiceNoTaxTotal(GenericValue invoice) {
@@ -169,10 +175,11 @@
      public static BigDecimal getInvoiceTotal(GenericValue invoice, Boolean actualCurrency) {
         BigDecimal invoiceTotal = ZERO;
         BigDecimal invoiceTaxTotal = ZERO;
-        Map<String, Object> invoiceTaxByTaxAuthGeoAndPartyResult = getInvoiceTaxByTaxAuthGeoAndParty(invoice);
+        Map invoiceTaxByTaxAuthGeoAndPartyResult = getInvoiceTaxByTaxAuthGeoAndParty(invoice);
+        List taxByTaxAuthGeoAndPartyList = (List) invoiceTaxByTaxAuthGeoAndPartyResult.get("taxByTaxAuthGeoAndPartyList");
         invoiceTaxTotal = (BigDecimal) invoiceTaxByTaxAuthGeoAndPartyResult.get("taxGrandTotal");
 
-        List<GenericValue> invoiceItems = null;
+        List invoiceItems = null;
         try {
             invoiceItems = invoice.getRelated("InvoiceItem");
             if ("SALES_INVOICE".equals(invoice.getString("invoiceTypeId"))) {
@@ -190,9 +197,9 @@
             Debug.logError(e, "Trouble getting InvoiceItem list", module);
         }
         if (UtilValidate.isNotEmpty(invoiceItems)) {
-            Iterator<GenericValue> invoiceItemsIter = invoiceItems.iterator();
+            Iterator invoiceItemsIter = invoiceItems.iterator();
             while (invoiceItemsIter.hasNext()) {
-                GenericValue invoiceItem = invoiceItemsIter.next();
+                GenericValue invoiceItem = (GenericValue) invoiceItemsIter.next();
                 BigDecimal amount = invoiceItem.getBigDecimal("amount");
                 BigDecimal quantity = invoiceItem.getBigDecimal("quantity");
                 if (amount == null)
@@ -225,7 +232,7 @@
         }
 
         // remaining code is the old method, which we leave here for compatibility purposes
-        List<GenericValue> billToRoles = null;
+        List billToRoles = null;
         try {
             billToRoles = invoice.getRelated("InvoiceRole", UtilMisc.toMap("roleTypeId", "BILL_TO_CUSTOMER"),
                 UtilMisc.toList("-datetimePerformed"));
@@ -269,7 +276,7 @@
         }
 
         // remaining code is the old method, which we leave here for compatibility purposes
-        List<GenericValue> sendFromRoles = null;
+        List sendFromRoles = null;
         try {
             sendFromRoles = invoice.getRelated("InvoiceRole", UtilMisc.toMap("roleTypeId", "BILL_FROM_VENDOR"),
                 UtilMisc.toList("-datetimePerformed"));
@@ -365,6 +372,39 @@
         return contactMech;
     }
 
+    private static GenericValue getAddressFromParty(GenericValue party, String purposeTypeId) {
+        if (party == null) return null;
+
+        GenericValue contactMech = null;
+        GenericValue postalAddress = null;
+        try {
+            List mecs = party.getRelated("PartyContactMechPurpose",
+                UtilMisc.toMap("contactMechPurposeTypeId", purposeTypeId), null);
+            if (mecs != null) {
+                List filteredMecs = EntityUtil.filterByDate(mecs);
+                GenericValue mecPurpose = EntityUtil.getFirst(filteredMecs);
+                if (mecPurpose != null)
+                    contactMech = mecPurpose.getRelatedOne("ContactMech");
+            }
+        } catch (GenericEntityException e) {
+            Debug.logError(e, "Trouble getting current ContactMech for Party/Purpose", module);
+        }
+
+        if (contactMech != null) {
+            if (contactMech.getString("contactMechTypeId").equals("POSTAL_ADDRESS")) {
+                try {
+                    postalAddress = contactMech.getRelatedOne("PostalAddress");
+                } catch (GenericEntityException e) {
+                    Debug.logError(e, "Trouble getting PostalAddress from ContactMech", module);
+                }
+            }
+        }
+
+        if (postalAddress != null)
+            return postalAddress;
+        return null;
+    }
+
     /**
      * Method to return the total amount of an invoice which is not yet applied to a payment
      * @param invoice GenericValue object of the Invoice
@@ -417,13 +457,13 @@
         }
 
         BigDecimal invoiceApplied = ZERO;
-        List<GenericValue> paymentApplications = null;
+        List paymentApplications = null;
 
         // lookup payment applications which took place before the asOfDateTime for this invoice
-        EntityConditionList<EntityCondition> dateCondition = EntityCondition.makeCondition(UtilMisc.toList(
-                (EntityCondition)EntityCondition.makeCondition("effectiveDate", EntityOperator.EQUALS, null),
+        EntityConditionList dateCondition = EntityCondition.makeCondition(UtilMisc.toList(
+                EntityCondition.makeCondition("effectiveDate", EntityOperator.EQUALS, null),
                 EntityCondition.makeCondition("effectiveDate", EntityOperator.LESS_THAN_EQUAL_TO, asOfDateTime)), EntityOperator.OR);
-        EntityConditionList<EntityCondition> conditions = EntityCondition.makeCondition(UtilMisc.toList(
+        EntityConditionList conditions = EntityCondition.makeCondition(UtilMisc.toList(
                 dateCondition,
                 EntityCondition.makeCondition("invoiceId", EntityOperator.EQUALS, invoiceId)),
                 EntityOperator.AND);
@@ -434,9 +474,9 @@
             Debug.logError(e, "Trouble getting paymentApplicationlist", module);
         }
         if (UtilValidate.isNotEmpty(paymentApplications)) {
-            Iterator<GenericValue> p = paymentApplications.iterator();
+            Iterator p = paymentApplications.iterator();
             while (p.hasNext()) {
-                GenericValue paymentApplication = p.next();
+                GenericValue paymentApplication = (GenericValue) p.next();
                 invoiceApplied = invoiceApplied.add(paymentApplication.getBigDecimal("amountApplied")).setScale(decimals,rounding);
             }
         }
@@ -497,16 +537,16 @@
      */
     public static BigDecimal getInvoiceItemApplied(GenericValue invoiceItem) {
         BigDecimal invoiceItemApplied = ZERO;
-        List<GenericValue> paymentApplications = null;
+        List paymentApplications = null;
         try {
             paymentApplications = invoiceItem.getRelated("PaymentApplication");
         } catch (GenericEntityException e) {
             Debug.logError(e, "Trouble getting paymentApplicationlist", module);
         }
         if (UtilValidate.isNotEmpty(paymentApplications)) {
-            Iterator<GenericValue> p = paymentApplications.iterator();
+            Iterator p = paymentApplications.iterator();
             while (p.hasNext()) {
-                GenericValue paymentApplication = p.next();
+                GenericValue paymentApplication = (GenericValue) p.next();
                 invoiceItemApplied = invoiceItemApplied.add(paymentApplication.getBigDecimal("amountApplied")).setScale(decimals,rounding);
             }
         }
@@ -539,17 +579,17 @@
 
         try {
             // check if the invoice is posted and get the conversion from there
-            List<GenericValue> acctgTransEntries = invoice.getRelated("AcctgTrans");
+            List acctgTransEntries = invoice.getRelated("AcctgTrans");
             if (UtilValidate.isNotEmpty(acctgTransEntries)) {
                 GenericValue acctgTransEntry = ((GenericValue) acctgTransEntries.get(0)).getRelated("AcctgTransEntry").get(0);
                 conversionRate = acctgTransEntry.getBigDecimal("amount").divide(acctgTransEntry.getBigDecimal("origAmount"), new MathContext(100)).setScale(decimals,rounding);
             }
             // check if a payment is applied and use the currency conversion from there
             if (UtilValidate.isEmpty(conversionRate)) {
-                List<GenericValue> paymentAppls = invoice.getRelated("PaymentApplication");
-                Iterator<GenericValue> ii = paymentAppls.iterator();
+                List paymentAppls = invoice.getRelated("PaymentApplication");
+                Iterator ii = paymentAppls.iterator();
                 while (ii.hasNext()) {
-                    GenericValue paymentAppl = ii.next();
+                    GenericValue paymentAppl = (GenericValue) ii.next();
                     GenericValue payment = paymentAppl.getRelatedOne("Payment");
                     if (UtilValidate.isNotEmpty(payment.getBigDecimal("actualCurrencyAmount"))) {
                         if (UtilValidate.isEmpty(conversionRate)) {
@@ -562,9 +602,9 @@
             }
             // use the dated conversion entity
             if (UtilValidate.isEmpty(conversionRate)) {
-                List<GenericValue> rates = EntityUtil.filterByDate(delegator.findByAnd("UomConversionDated", UtilMisc.toMap("uomIdTo", invoice.getString("currencyUomId"), "uomId", otherCurrencyUomId)), invoice.getTimestamp("invoiceDate"));
+                List rates = EntityUtil.filterByDate(delegator.findByAnd("UomConversionDated", UtilMisc.toMap("uomIdTo", invoice.getString("currencyUomId"), "uomId", otherCurrencyUomId)), invoice.getTimestamp("invoiceDate"));
                 if (UtilValidate.isNotEmpty(rates)) {
-                    conversionRate = (BigDecimal.ONE).divide(rates.get(0).getBigDecimal("conversionFactor"), new MathContext(100)).setScale(decimals,rounding);
+                    conversionRate = (BigDecimal.ONE).divide(((GenericValue) rates.get(0)).getBigDecimal("conversionFactor"), new MathContext(100)).setScale(decimals,rounding);
                 } else {
                     Debug.logError("Could not find conversionrate for invoice: " + invoice.getString("invoiceId"), module);
                     return new BigDecimal("1");

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java?rev=882342&r1=882341&r2=882342&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java Thu Nov 19 22:45:56 2009
@@ -18,21 +18,23 @@
  *******************************************************************************/
 package org.ofbiz.accounting.payment;
 
-import java.math.BigDecimal;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.TreeMap;
+import java.util.Collections;
+import java.util.Comparator;
+import java.math.BigDecimal;
 
 import javolution.util.FastList;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.UtilDateTime;
-import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilNumber;
+import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
@@ -42,6 +44,7 @@
 import org.ofbiz.entity.condition.EntityJoinOperator;
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.order.order.OrderReadHelper;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ServiceUtil;
@@ -63,15 +66,15 @@
         if (decimals != -1) ZERO = ZERO.setScale(decimals);
     }
 
-    public static List<Map<String, BigDecimal>> makePartyBillingAccountList(GenericValue userLogin, String currencyUomId, String partyId, Delegator delegator, LocalDispatcher dispatcher) throws GeneralException {
-        List<Map<String, BigDecimal>> billingAccountList = FastList.newInstance();
+    public static List makePartyBillingAccountList(GenericValue userLogin, String currencyUomId, String partyId, Delegator delegator, LocalDispatcher dispatcher) throws GeneralException {
+        List billingAccountList = FastList.newInstance();
 
-        Map<String, Object> agentResult = dispatcher.runSync("getRelatedParties", UtilMisc.<String, Object>toMap("userLogin", userLogin, "partyIdFrom", partyId,
+        Map agentResult = dispatcher.runSync("getRelatedParties", UtilMisc.<String, Object>toMap("userLogin", userLogin, "partyIdFrom", partyId,
                 "roleTypeIdFrom", "AGENT", "roleTypeIdTo", "CUSTOMER", "partyRelationshipTypeId", "AGENT", "includeFromToSwitched", "Y"));
         if (ServiceUtil.isError(agentResult)) {
             throw new GeneralException("Error while finding party BillingAccounts when getting Customers that this party is an agent of: " + ServiceUtil.getErrorMessage(agentResult));
         }
-        List<String> relatedPartyIdList = UtilGenerics.cast(agentResult.get("relatedPartyIdList"));
+        List relatedPartyIdList = (List) agentResult.get("relatedPartyIdList");
 
         EntityCondition barFindCond = EntityCondition.makeCondition(UtilMisc.toList(
                 EntityCondition.makeCondition("partyId", EntityOperator.IN, relatedPartyIdList),
@@ -81,7 +84,9 @@
 
         if (billingAccountRoleList.size() > 0) {
             BigDecimal totalAvailable = BigDecimal.ZERO;
-            for (GenericValue billingAccountRole : billingAccountRoleList) {
+            Iterator billingAcctIter = billingAccountRoleList.iterator();
+            while (billingAcctIter.hasNext()) {
+                GenericValue billingAccountRole = (GenericValue) billingAcctIter.next();
                 GenericValue billingAccountVO = billingAccountRole.getRelatedOne("BillingAccount");
 
                 // skip accounts that have thruDate < nowTimestamp
@@ -91,7 +96,7 @@
                 if (currencyUomId.equals(billingAccountVO.getString("accountCurrencyUomId"))) {
                     BigDecimal accountBalance = BillingAccountWorker.getBillingAccountBalance(billingAccountVO);
 
-                    Map<String, BigDecimal> billingAccount = new HashMap<String, BigDecimal>(UtilGenerics.<Map<String,BigDecimal>>cast(billingAccountVO));
+                    Map billingAccount = new HashMap(billingAccountVO);
                     BigDecimal accountLimit = getAccountLimit(billingAccountVO);
 
                     billingAccount.put("accountBalance", accountBalance);
@@ -142,22 +147,24 @@
         BigDecimal accountLimit = getAccountLimit(billingAccount);
         balance = balance.add(accountLimit);
         // pending (not cancelled, rejected, or received) order payments
-        EntityConditionList<EntityExpr> whereConditions = EntityCondition.makeCondition(UtilMisc.toList(
+        EntityConditionList whereConditions = EntityCondition.makeCondition(UtilMisc.toList(
                 EntityCondition.makeCondition("billingAccountId", EntityOperator.EQUALS, billingAccountId),
                 EntityCondition.makeCondition("paymentMethodTypeId", EntityOperator.EQUALS, "EXT_BILLACT"),
                 EntityCondition.makeCondition("statusId", EntityOperator.NOT_IN, UtilMisc.toList("ORDER_CANCELLED", "ORDER_REJECTED")),
                 EntityCondition.makeCondition("preferenceStatusId", EntityOperator.NOT_IN, UtilMisc.toList("PAYMENT_SETTLED", "PAYMENT_RECEIVED", "PAYMENT_DECLINED", "PAYMENT_CANCELLED")) // PAYMENT_NOT_AUTH
            ), EntityOperator.AND);
 
-        List<GenericValue>  orderPaymentPreferenceSums = delegator.findList("OrderPurchasePaymentSummary", whereConditions, UtilMisc.toSet("maxAmount"), null, null, false);
-        for (GenericValue orderPaymentPreferenceSum : orderPaymentPreferenceSums) {
+        List orderPaymentPreferenceSums = delegator.findList("OrderPurchasePaymentSummary", whereConditions, UtilMisc.toSet("maxAmount"), null, null, false);
+        for (Iterator oppsi = orderPaymentPreferenceSums.iterator(); oppsi.hasNext();) {
+            GenericValue orderPaymentPreferenceSum = (GenericValue) oppsi.next();
             BigDecimal maxAmount = orderPaymentPreferenceSum.getBigDecimal("maxAmount");
             balance = maxAmount != null ? balance.subtract(maxAmount) : balance;
         }
 
-        List<GenericValue> paymentAppls = delegator.findByAnd("PaymentApplication", UtilMisc.toMap("billingAccountId", billingAccountId));
+        List paymentAppls = delegator.findByAnd("PaymentApplication", UtilMisc.toMap("billingAccountId", billingAccountId));
         // TODO: cancelled payments?
-        for (GenericValue paymentAppl : paymentAppls) {
+        for (Iterator pAi = paymentAppls.iterator(); pAi.hasNext();) {
+            GenericValue paymentAppl = (GenericValue) pAi.next();
             if (paymentAppl.getString("invoiceId") == null) {
                 BigDecimal amountApplied = paymentAppl.getBigDecimal("amountApplied");
                 balance = balance.add(amountApplied);
@@ -176,7 +183,10 @@
         // now the amounts of all the pending orders (not cancelled, rejected or completed)
         List orderHeaders = getBillingAccountOpenOrders(delegator, billingAccountId);
 
-        for (GenericValue orderHeader : orderHeaders) {
+        if (orderHeaders != null) {
+            Iterator ohi = orderHeaders.iterator();
+            while (ohi.hasNext()) {
+                GenericValue orderHeader = (GenericValue) ohi.next();
                 OrderReadHelper orh = new OrderReadHelper(orderHeader);
                 balance = balance.add(orh.getOrderGrandTotal());
             }
@@ -198,7 +208,7 @@
     /**
      * Returns list of orders which are currently open against a billing account
      */
-    public static List<GenericValue> getBillingAccountOpenOrders(Delegator delegator, String billingAccountId) throws GenericEntityException {
+    public static List getBillingAccountOpenOrders(Delegator delegator, String billingAccountId) throws GenericEntityException {
         EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(UtilMisc.toList(
                 EntityCondition.makeCondition("billingAccountId", EntityOperator.EQUALS, billingAccountId),
                 EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED"),
@@ -243,8 +253,9 @@
         BigDecimal balance = ZERO;
 
         // search through all PaymentApplications and add the amount that was applied to invoice and subtract the amount applied from payments
-        List<GenericValue> paymentAppls = delegator.findByAnd("PaymentApplication", UtilMisc.toMap("billingAccountId", billingAccountId));
-        for (GenericValue paymentAppl : paymentAppls) {
+        List paymentAppls = delegator.findByAnd("PaymentApplication", UtilMisc.toMap("billingAccountId", billingAccountId));
+        for (Iterator pAi = paymentAppls.iterator(); pAi.hasNext();) {
+            GenericValue paymentAppl = (GenericValue) pAi.next();
             BigDecimal amountApplied = paymentAppl.getBigDecimal("amountApplied");
             GenericValue invoice = paymentAppl.getRelatedOne("Invoice");
             if (invoice != null) {
@@ -274,10 +285,10 @@
         return accountLimit.subtract(netBalance).setScale(decimals, rounding);
     }
 
-    public static Map<String, Object> calcBillingAccountBalance(DispatchContext dctx, Map<String, Object> context) {
+    public static Map calcBillingAccountBalance(DispatchContext dctx, Map context) {
         Delegator delegator = dctx.getDelegator();
         String billingAccountId = (String) context.get("billingAccountId");
-        Map<String, Object> result = ServiceUtil.returnSuccess();
+        Map result = ServiceUtil.returnSuccess();
 
         try {
             GenericValue billingAccount = delegator.findByPrimaryKey("BillingAccount", UtilMisc.toMap("billingAccountId", billingAccountId));
@@ -298,9 +309,9 @@
         }
     }
 
-    private static class BillingAccountComparator implements Comparator<Map<String, BigDecimal>> {
-        public int compare(Map<String, BigDecimal> billingAccount1, Map<String, BigDecimal> billingAccount2) {
-            return billingAccount1.get("accountBalance").compareTo(billingAccount2.get("accountBalance"));
+    private static class BillingAccountComparator implements Comparator {
+        public int compare(Object billingAccount1, Object billingAccount2) {
+            return ((BigDecimal)((Map)billingAccount1).get("accountBalance")).compareTo((BigDecimal)((Map)billingAccount2).get("accountBalance"));
         }
     }
 }

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/GiftCertificateServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/GiftCertificateServices.java?rev=882342&r1=882341&r2=882342&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/GiftCertificateServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/GiftCertificateServices.java Thu Nov 19 22:45:56 2009
@@ -21,6 +21,7 @@
 import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -56,7 +57,7 @@
     public static BigDecimal ZERO = BigDecimal.ZERO;
 
     // Base Gift Certificate Services
-    public static Map<String, Object> createGiftCertificate(DispatchContext dctx, Map<String, Object> context) {
+    public static Map createGiftCertificate(DispatchContext dctx, Map context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
 
@@ -82,7 +83,7 @@
             final String deposit = "DEPOSIT";
 
             GenericValue giftCertSettings = delegator.findByPrimaryKeyCache("ProductStoreFinActSetting", UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId));
-            Map<String, Object> acctResult = null;
+            Map acctResult = null;
 
             if ("Y".equals(giftCertSettings.getString("requirePinCode"))) {
                 // TODO: move this code to createFinAccountForStore as well
@@ -101,7 +102,7 @@
                 finAccountId = cardNumber;
 
                 // create the FinAccount
-                Map<String, Object> acctCtx = UtilMisc.toMap("finAccountId", (Object)finAccountId);
+                Map acctCtx = UtilMisc.toMap("finAccountId", finAccountId);
                 acctCtx.put("finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId);
                 acctCtx.put("finAccountName", accountName);
                 acctCtx.put("finAccountCode", pinNumber);
@@ -140,7 +141,7 @@
             return ServiceUtil.returnError(e.getMessage());
         }
 
-        Map<String, Object> result = ServiceUtil.returnSuccess();
+        Map result = ServiceUtil.returnSuccess();
         result.put("cardNumber", cardNumber);
         result.put("pinNumber", pinNumber);
         result.put("initialAmount", initialAmount);
@@ -151,7 +152,7 @@
         return result;
     }
 
-    public static Map<String, Object> addFundsToGiftCertificate(DispatchContext dctx, Map<String, Object> context) {
+    public static Map addFundsToGiftCertificate(DispatchContext dctx, Map context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
         final String deposit = "DEPOSIT";
@@ -222,7 +223,7 @@
             return ServiceUtil.returnError(e.getMessage());
         }
 
-        Map<String, Object> result = ServiceUtil.returnSuccess();
+        Map result = ServiceUtil.returnSuccess();
         result.put("previousBalance", previousBalance);
         result.put("balance", balance);
         result.put("amount", amount);
@@ -233,7 +234,7 @@
         return result;
     }
 
-    public static Map<String, Object> redeemGiftCertificate(DispatchContext dctx, Map<String, Object> context) {
+    public static Map redeemGiftCertificate(DispatchContext dctx, Map context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
         final String withdrawl = "WITHDRAWAL";
@@ -299,7 +300,7 @@
             refNum = "N/A";
         }
 
-        Map<String, Object> result = ServiceUtil.returnSuccess();
+        Map result = ServiceUtil.returnSuccess();
         result.put("previousBalance", previousBalance);
         result.put("balance", balance);
         result.put("amount", amount);
@@ -310,7 +311,7 @@
         return result;
     }
 
-    public static Map<String, Object> checkGiftCertificateBalance(DispatchContext dctx, Map<String, Object> context) {
+    public static Map checkGiftCertificateBalance(DispatchContext dctx, Map context) {
         Delegator delegator = dctx.getDelegator();
         String cardNumber = (String) context.get("cardNumber");
         String pinNumber = (String) context.get("pinNumber");
@@ -332,14 +333,14 @@
         // get the balance
         BigDecimal balance = finAccount.get("availableBalance") == null ? BigDecimal.ZERO : finAccount.getBigDecimal("availableBalance");
 
-        Map<String, Object> result = ServiceUtil.returnSuccess();
+        Map result = ServiceUtil.returnSuccess();
         result.put("balance", balance);
         Debug.log("GC Balance Result - " + result, module);
         return result;
     }
 
     // Fullfilment Services
-    public static Map<String, Object> giftCertificateProcessor(DispatchContext dctx, Map<String, Object> context) {
+    public static Map giftCertificateProcessor(DispatchContext dctx, Map context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -379,7 +380,7 @@
             // obtain the order information
             OrderReadHelper orh = new OrderReadHelper(delegator, orderPaymentPreference.getString("orderId"));
 
-            Map<String, Object> redeemCtx = new HashMap<String, Object>();
+            Map redeemCtx = new HashMap();
             redeemCtx.put("userLogin", userLogin);
             redeemCtx.put("productStoreId", orh.getProductStoreId());
             redeemCtx.put("cardNumber", giftCard.get("finAccountId"));
@@ -391,20 +392,20 @@
             redeemCtx.put("amount", amount);
 
             // invoke the redeem service
-            Map<String, Object> redeemResult = null;
+            Map redeemResult = null;
             redeemResult = dispatcher.runSync("redeemGiftCertificate", redeemCtx);
             if (ServiceUtil.isError(redeemResult)) {
                 return redeemResult;
             }
 
             // now release the authorization should this use the gift card release service?
-            Map<String, Object> releaseResult = dispatcher.runSync("expireFinAccountAuth", UtilMisc.<String, Object>toMap("userLogin", userLogin, "finAccountAuthId", finAccountAuthId));
+            Map releaseResult = dispatcher.runSync("expireFinAccountAuth", UtilMisc.<String, Object>toMap("userLogin", userLogin, "finAccountAuthId", finAccountAuthId));
             if (ServiceUtil.isError(releaseResult)) {
                 return releaseResult;
             }
 
             String authRefNum = authTransaction.getString("referenceNum");
-            Map<String, Object> result = ServiceUtil.returnSuccess();
+            Map result = ServiceUtil.returnSuccess();
             if (redeemResult != null) {
                 Boolean processResult = (Boolean) redeemResult.get("processResult");
                 result.put("processAmount", amount);
@@ -424,7 +425,7 @@
 }
 
 
-    public static Map<String, Object> giftCertificateAuthorize(DispatchContext dctx, Map<String, Object> context) {
+    public static Map giftCertificateAuthorize(DispatchContext dctx, Map context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -478,7 +479,7 @@
             BigDecimal availableBalance = finAccount.getBigDecimal("availableBalance");
             Boolean processResult = null;
             String refNum = null;
-            Map<String, Object> result = ServiceUtil.returnSuccess();
+            Map result = ServiceUtil.returnSuccess();
 
             // make sure to round and scale it to the same as availableBalance
             amount = amount.setScale(FinAccountHelper.decimals, FinAccountHelper.rounding);
@@ -489,7 +490,7 @@
                 if (giftCertSettings.getLong("authValidDays") != null) {
                     thruDate = UtilDateTime.getDayEnd(UtilDateTime.nowTimestamp(), giftCertSettings.getLong("authValidDays"));
                 }
-                Map<String, Object> tmpResult = dispatcher.runSync("createFinAccountAuth", UtilMisc.<String, Object>toMap("finAccountId", finAccountId, "amount", amount, "currencyUomId", currency,
+                Map tmpResult = dispatcher.runSync("createFinAccountAuth", UtilMisc.<String, Object>toMap("finAccountId", finAccountId, "amount", amount, "currencyUomId", currency,
                         "thruDate", thruDate, "userLogin", userLogin));
                 if (ServiceUtil.isError(tmpResult)) {
                     return tmpResult;
@@ -521,7 +522,7 @@
         }
     }
 
-    public static Map<String, Object> giftCertificateRefund(DispatchContext dctx, Map<String, Object> context) {
+    public static Map giftCertificateRefund(DispatchContext dctx, Map context) {
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference");
         String currency = (String) context.get("currency");
@@ -529,7 +530,7 @@
         return giftCertificateRestore(dctx, userLogin, paymentPref, amount, currency, "refund");
     }
 
-    public static Map<String, Object> giftCertificateRelease(DispatchContext dctx, Map<String, Object> context) {
+    public static Map giftCertificateRelease(DispatchContext dctx, Map context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
 
@@ -542,10 +543,10 @@
             if (authTransaction == null) {
                 return ServiceUtil.returnError(err + " Could not find authorization transaction.");
             }
-            Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "finAccountAuthId", authTransaction.get("referenceNum"));
-            Map<String, Object> serviceResults = dispatcher.runSync("expireFinAccountAuth", input);
+            Map input = UtilMisc.toMap("userLogin", userLogin, "finAccountAuthId", authTransaction.get("referenceNum"));
+            Map serviceResults = dispatcher.runSync("expireFinAccountAuth", input);
 
-            Map<String, Object> result = ServiceUtil.returnSuccess();
+            Map result = ServiceUtil.returnSuccess();
             result.put("releaseRefNum", authTransaction.getString("referenceNum"));
             result.put("releaseAmount", authTransaction.getBigDecimal("amount"));
             result.put("releaseResult", Boolean.TRUE);
@@ -562,7 +563,7 @@
         }
     }
 
-    private static Map<String, Object> giftCertificateRestore(DispatchContext dctx, GenericValue userLogin, GenericValue paymentPref, BigDecimal amount, String currency, String resultPrefix) {
+    private static Map giftCertificateRestore(DispatchContext dctx, GenericValue userLogin, GenericValue paymentPref, BigDecimal amount, String currency, String resultPrefix) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
 
@@ -596,7 +597,7 @@
             currency = UtilProperties.getPropertyValue("general.properties", "currency.uom.id.default", "USD");
         }
 
-        Map<String, Object> refundCtx = new HashMap<String, Object>();
+        Map refundCtx = new HashMap();
         refundCtx.put("productStoreId", productStoreId);
         refundCtx.put("currency", currency);
         refundCtx.put("partyId", partyId);
@@ -606,7 +607,7 @@
         refundCtx.put("amount", amount);
         refundCtx.put("userLogin", userLogin);
 
-        Map<String, Object> restoreGcResult = null;
+        Map restoreGcResult = null;
         try {
             restoreGcResult = dispatcher.runSync("addFundsToGiftCertificate", refundCtx);
         } catch (GenericServiceException e) {
@@ -617,7 +618,7 @@
             return ServiceUtil.returnError(ServiceUtil.getErrorMessage(restoreGcResult));
         }
 
-        Map<String, Object> result = ServiceUtil.returnSuccess();
+        Map result = ServiceUtil.returnSuccess();
         if (restoreGcResult != null) {
             Boolean processResult = (Boolean) restoreGcResult.get("processResult");
             result.put(resultPrefix + "Amount", amount);
@@ -630,7 +631,7 @@
         return result;
     }
 
-    public static Map<String, Object> giftCertificatePurchase(DispatchContext dctx, Map<String, Object> context) {
+    public static Map giftCertificatePurchase(DispatchContext dctx, Map context) {
         // this service should always be called via FULFILLMENT_EXTASYNC
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
@@ -707,9 +708,9 @@
         // get the survey response
         GenericValue surveyResponse = null;
         try {
-            Map<String, Object> fields = UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "surveyId", surveyId);
-            List<String> order = UtilMisc.toList("-responseDate");
-            List<GenericValue> responses = delegator.findByAnd("SurveyResponse", fields, order);
+            Map fields = UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "surveyId", surveyId);
+            List order = UtilMisc.toList("-responseDate");
+            List responses = delegator.findByAnd("SurveyResponse", fields, order);
             // there should be only one
             surveyResponse = EntityUtil.getFirst(responses);
         } catch (GenericEntityException e) {
@@ -721,7 +722,7 @@
         }
 
         // get the response answers
-        List<GenericValue> responseAnswers = null;
+        List responseAnswers = null;
         try {
             responseAnswers = surveyResponse.getRelated("SurveyResponseAnswer");
         } catch (GenericEntityException e) {
@@ -730,9 +731,11 @@
         }
 
         // make a map of answer info
-        Map<String, Object> answerMap = new HashMap<String, Object>();
+        Map answerMap = new HashMap();
         if (responseAnswers != null) {
-            for (GenericValue answer : responseAnswers) {
+            Iterator rai = responseAnswers.iterator();
+            while (rai.hasNext()) {
+                GenericValue answer = (GenericValue) rai.next();
                 GenericValue question = null;
                 try {
                     question = answer.getRelatedOne("SurveyQuestion");
@@ -762,7 +765,7 @@
         int qtyLoop = quantity.intValue();
         for (int i = 0; i < qtyLoop; i++) {
             // create a gift certificate
-            Map<String, Object> createGcCtx = new HashMap<String, Object>();
+            Map createGcCtx = new HashMap();
             //createGcCtx.put("paymentConfig", paymentConfig);
             createGcCtx.put("productStoreId", productStoreId);
             createGcCtx.put("currency", currency);
@@ -771,7 +774,7 @@
             createGcCtx.put("initialAmount", amount);
             createGcCtx.put("userLogin", userLogin);
 
-            Map<String, Object> createGcResult = null;
+            Map createGcResult = null;
             try {
                 createGcResult = dispatcher.runSync("createGiftCertificate", createGcCtx);
             } catch (GenericServiceException e) {
@@ -783,7 +786,7 @@
             }
 
             // create the fulfillment record
-            Map<String, Object> gcFulFill = new HashMap<String, Object>();
+            Map gcFulFill = new HashMap();
             gcFulFill.put("typeEnumId", "GC_ACTIVATE");
             gcFulFill.put("partyId", partyId);
             gcFulFill.put("orderId", orderId);
@@ -834,7 +837,7 @@
                     }
                 }
 
-                Map<String, Object> emailCtx = new HashMap<String, Object>();
+                Map emailCtx = new HashMap();
                 String bodyScreenLocation = productStoreEmail.getString("bodyScreenLocation");
                 if (UtilValidate.isEmpty(bodyScreenLocation)) {
                     bodyScreenLocation = ProductStoreWorker.getDefaultProductStoreEmailScreenLocation(emailType);
@@ -865,7 +868,7 @@
         return ServiceUtil.returnSuccess();
     }
 
-    public static Map<String, Object> giftCertificateReload(DispatchContext dctx, Map<String, Object> context) {
+    public static Map giftCertificateReload(DispatchContext dctx, Map context) {
         // this service should always be called via FULFILLMENT_EXTSYNC
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
@@ -931,9 +934,9 @@
         // get the survey response
         GenericValue surveyResponse = null;
         try {
-            Map<String, Object> fields = UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "surveyId", surveyId);
-            List<String> order = UtilMisc.toList("-responseDate");
-            List<GenericValue> responses = delegator.findByAnd("SurveyResponse", fields, order);
+            Map fields = UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "surveyId", surveyId);
+            List order = UtilMisc.toList("-responseDate");
+            List responses = delegator.findByAnd("SurveyResponse", fields, order);
             // there should be only one
             surveyResponse = EntityUtil.getFirst(responses);
         } catch (GenericEntityException e) {
@@ -942,7 +945,7 @@
         }
 
         // get the response answers
-        List<GenericValue> responseAnswers = null;
+        List responseAnswers = null;
         try {
             responseAnswers = surveyResponse.getRelated("SurveyResponseAnswer");
         } catch (GenericEntityException e) {
@@ -951,9 +954,11 @@
         }
 
         // make a map of answer info
-        Map<String, Object> answerMap = new HashMap<String, Object>();
+        Map answerMap = new HashMap();
         if (responseAnswers != null) {
-            for (GenericValue answer : responseAnswers) {
+            Iterator rai = responseAnswers.iterator();
+            while (rai.hasNext()) {
+                GenericValue answer = (GenericValue) rai.next();
                 GenericValue question = null;
                 try {
                     question = answer.getRelatedOne("SurveyQuestion");
@@ -975,7 +980,7 @@
         String pinNumber = (String) answerMap.get(pinNumberKey);
 
         // reload the gift card
-        Map<String, Object> reloadCtx = new HashMap<String, Object>();
+        Map reloadCtx = new HashMap();
         reloadCtx.put("productStoreId", productStoreId);
         reloadCtx.put("currency", currency);
         reloadCtx.put("partyId", partyId);
@@ -986,7 +991,7 @@
         reloadCtx.put("userLogin", userLogin);
 
         String errorMessage = null;
-        Map<String, Object> reloadGcResult = null;
+        Map reloadGcResult = null;
         try {
             reloadGcResult = dispatcher.runSync("addFundsToGiftCertificate", reloadCtx);
         } catch (GenericServiceException e) {
@@ -998,7 +1003,7 @@
         }
 
         // create the fulfillment record
-        Map<String, Object> gcFulFill = new HashMap<String, Object>();
+        Map gcFulFill = new HashMap();
         gcFulFill.put("typeEnumId", "GC_RELOAD");
         gcFulFill.put("userLogin", userLogin);
         gcFulFill.put("partyId", partyId);
@@ -1025,7 +1030,7 @@
 
             // process the return
             try {
-                Map<String, Object> refundCtx = UtilMisc.toMap("orderItem", orderItem, "partyId", partyId, "userLogin", userLogin);
+                Map refundCtx = UtilMisc.toMap("orderItem", orderItem, "partyId", partyId, "userLogin", userLogin);
                 dispatcher.runAsync("refundGcPurchase", refundCtx, null, true, 300, true);
             } catch (GenericServiceException e) {
                 Debug.logError(e, "ERROR! Unable to call create refund service; this failed reload will NOT be refunded", module);
@@ -1057,7 +1062,7 @@
             answerMap.put("uiLabelMap", uiLabelMap);
             answerMap.put("locale", locale);
 
-            Map<String, Object> emailCtx = new HashMap<String, Object>();
+            Map emailCtx = new HashMap();
             String bodyScreenLocation = productStoreEmail.getString("bodyScreenLocation");
             if (UtilValidate.isEmpty(bodyScreenLocation)) {
                 bodyScreenLocation = ProductStoreWorker.getDefaultProductStoreEmailScreenLocation(emailType);
@@ -1086,7 +1091,7 @@
     }
 
     // Tracking Service
-    public static Map<String, Object> createFulfillmentRecord(DispatchContext dctx, Map<String, Object> context) {
+    public static Map createFulfillmentRecord(DispatchContext dctx, Map context) {
         Delegator delegator = dctx.getDelegator();
 
         // create the fulfillment record
@@ -1115,7 +1120,7 @@
     }
 
     // Refund Service
-    public static Map<String, Object> refundGcPurchase(DispatchContext dctx, Map<String, Object> context) {
+    public static Map refundGcPurchase(DispatchContext dctx, Map context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -1129,7 +1134,7 @@
             Debug.logError(e, module);
         }
 
-        Map<String, Object> returnableInfo = null;
+        Map returnableInfo = null;
         try {
             returnableInfo = dispatcher.runSync("getReturnableQuantity", UtilMisc.toMap("orderItem", orderItem, "userLogin", userLogin));
         } catch (GenericServiceException e) {
@@ -1143,10 +1148,10 @@
             Debug.logInfo("Returnable INFO : " + returnableQuantity + " @ " + returnablePrice + " :: " + orderItem, module);
 
             // create the return header
-            Map<String, Object> returnHeaderInfo = new HashMap<String, Object>();
+            Map returnHeaderInfo = new HashMap();
             returnHeaderInfo.put("fromPartyId", partyId);
             returnHeaderInfo.put("userLogin", userLogin);
-            Map<String, Object> returnHeaderResp = null;
+            Map returnHeaderResp = null;
             try {
                 returnHeaderResp = dispatcher.runSync("createReturnHeader", returnHeaderInfo);
             } catch (GenericServiceException e) {
@@ -1171,7 +1176,7 @@
             }
 
             // create the return item
-            Map<String, Object> returnItemInfo = new HashMap<String, Object>();
+            Map returnItemInfo = new HashMap();
             returnItemInfo.put("returnId", returnId);
             returnItemInfo.put("returnReasonId", "RTN_DIG_FILL_FAIL");
             returnItemInfo.put("returnTypeId", "RTN_REFUND");
@@ -1182,7 +1187,7 @@
             returnItemInfo.put("returnQuantity", returnableQuantity);
             returnItemInfo.put("returnPrice", returnablePrice);
             returnItemInfo.put("userLogin", userLogin);
-            Map<String, Object> returnItemResp = null;
+            Map returnItemResp = null;
             try {
                 returnItemResp = dispatcher.runSync("createReturnItem", returnItemInfo);
             } catch (GenericServiceException e) {
@@ -1218,12 +1223,12 @@
             }
 
             // update the status to received so it can process
-            Map<String, Object> updateReturnInfo = new HashMap<String, Object>();
+            Map updateReturnInfo = new HashMap();
             updateReturnInfo.put("returnId", returnId);
             updateReturnInfo.put("statusId", "RETURN_RECEIVED");
             updateReturnInfo.put("currentStatusId", "RETURN_REQUESTED");
             updateReturnInfo.put("userLogin", admin);
-            Map<String, Object> updateReturnResp = null;
+            Map updateReturnResp = null;
             try {
                 updateReturnResp = dispatcher.runSync("updateReturnHeader", updateReturnInfo);
             } catch (GenericServiceException e) {
@@ -1287,7 +1292,7 @@
         }
 
         // create the payment for the transaction
-        Map<String, Object> paymentCtx = UtilMisc.toMap("paymentTypeId", (Object)paymentType);
+        Map paymentCtx = UtilMisc.toMap("paymentTypeId", paymentType);
         paymentCtx.put("paymentMethodTypeId", paymentMethodType);
         //paymentCtx.put("paymentMethodId", "");
         //paymentCtx.put("paymentGatewayResponseId", "");
@@ -1301,7 +1306,7 @@
         paymentCtx.put("paymentRefNum", "N/A");
 
         String paymentId = null;
-        Map<String, Object> payResult = null;
+        Map payResult = null;
         try {
             payResult = dispatcher.runSync("createPayment", paymentCtx);
         } catch (GenericServiceException e) {
@@ -1317,14 +1322,14 @@
         }
 
         // create the initial transaction
-        Map<String, Object> transCtx = UtilMisc.toMap("finAccountTransTypeId", (Object)txType);
+        Map transCtx = UtilMisc.toMap("finAccountTransTypeId", txType);
         transCtx.put("finAccountId", finAccountId);
         transCtx.put("partyId", userLogin.getString("partyId"));
         transCtx.put("userLogin", userLogin);
         transCtx.put("paymentId", paymentId);
         transCtx.put("amount", amount);
 
-        Map<String, Object> transResult = null;
+        Map transResult = null;
         String txId = null;
         try {
             transResult = dispatcher.runSync("createFinAccountTrans", transCtx);

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java?rev=882342&r1=882341&r2=882342&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java Thu Nov 19 22:45:56 2009
@@ -387,7 +387,7 @@
 
             if (((Boolean) results.get("finished")).booleanValue()) finished += 1;
             if (((Boolean) results.get("errors")).booleanValue()) hadError += 1;
-            if (results.get("messages") != null) messages.addAll(UtilGenerics.<List<String>>cast(results.get("messages")));
+            if (results.get("messages") != null) messages.addAll((List) results.get("messages"));
             if (results.get("processAmount") != null) totalRemaining = totalRemaining.subtract(((BigDecimal) results.get("processAmount")));
         }
 

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java?rev=882342&r1=882341&r2=882342&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java Thu Nov 19 22:45:56 2009
@@ -50,8 +50,8 @@
      * @param context Map containing the input parameters
      * @return Map with the result of the service, the output parameters
      */
-    public static Map<String, Object> deletePaymentMethod(DispatchContext ctx, Map<String, Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+    public static Map deletePaymentMethod(DispatchContext ctx, Map context) {
+        Map result = new HashMap();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -92,8 +92,8 @@
         return result;
     }
 
-    public static Map<String, Object> makeExpireDate(DispatchContext ctx, Map<String, Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+    public static Map makeExpireDate(DispatchContext ctx, Map context) {
+        Map result = new HashMap();
         String expMonth = (String) context.get("expMonth");
         String expYear = (String) context.get("expYear");
 
@@ -113,8 +113,8 @@
      * @param context Map containing the input parameters
      * @return Map with the result of the service, the output parameters
      */
-    public static Map<String, Object> createCreditCard(DispatchContext ctx, Map<String, Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+    public static Map createCreditCard(DispatchContext ctx, Map context) {
+        Map result = new HashMap();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -126,7 +126,7 @@
         if (result.size() > 0) return result;
 
         // do some more complicated/critical validation...
-        List<String> messages = new LinkedList<String>();
+        List messages = new LinkedList();
 
         // first remove all spaces from the credit card number
         context.put("cardNumber", StringUtil.removeSpaces((String) context.get("cardNumber")));
@@ -145,7 +145,7 @@
             return ServiceUtil.returnError(messages);
         }
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List toBeStored = new LinkedList();
         GenericValue newPm = delegator.makeValue("PaymentMethod");
 
         toBeStored.add(newPm);
@@ -192,7 +192,7 @@
             GenericValue tempVal = null;
 
             try {
-                List<GenericValue> allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose",
+                List allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose",
                         UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId), null), true);
 
                 tempVal = EntityUtil.getFirst(allPCMPs);
@@ -229,8 +229,8 @@
      * @param context Map containing the input parameters
      * @return Map with the result of the service, the output parameters
      */
-    public static Map<String, Object> updateCreditCard(DispatchContext ctx, Map<String, Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+    public static Map updateCreditCard(DispatchContext ctx, Map context) {
+        Map result = new HashMap();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -241,7 +241,7 @@
 
         if (result.size() > 0) return result;
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List toBeStored = new LinkedList();
         boolean isModified = false;
 
         GenericValue paymentMethod = null;
@@ -267,7 +267,7 @@
         }
 
         // do some more complicated/critical validation...
-        List<String> messages = new LinkedList<String>();
+        List messages = new LinkedList();
 
         // first remove all spaces from the credit card number
         String updatedCardNumber = StringUtil.removeSpaces((String) context.get("cardNumber"));
@@ -355,7 +355,7 @@
             GenericValue tempVal = null;
 
             try {
-                List<GenericValue> allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose",
+                List allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose",
                         UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId), null), true);
 
                 tempVal = EntityUtil.getFirst(allPCMPs);
@@ -403,7 +403,7 @@
         return result;
     }
 
-    public static Map<String, Object> clearCreditCardData(DispatchContext dctx, Map<String, Object> context) {
+    public static Map clearCreditCardData(DispatchContext dctx, Map context) {
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         String paymentMethodId = (String) context.get("paymentMethodId");
 
@@ -429,8 +429,8 @@
 
         // expire the payment method
         LocalDispatcher dispatcher = dctx.getDispatcher();
-        Map<String, Object> expireCtx = UtilMisc.toMap("userLogin", userLogin, "paymentMethodId", paymentMethodId);
-        Map<String, Object> expireResp;
+        Map expireCtx = UtilMisc.toMap("userLogin", userLogin, "paymentMethodId", paymentMethodId);
+        Map expireResp;
         try {
             expireResp = dispatcher.runSync("deletePaymentMethod", expireCtx);
         } catch (GenericServiceException e) {
@@ -444,8 +444,8 @@
         return ServiceUtil.returnSuccess();
     }
 
-    public static Map<String, Object> createGiftCard(DispatchContext ctx, Map<String, Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+    public static Map createGiftCard(DispatchContext ctx, Map context) {
+        Map result = new HashMap();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -457,7 +457,7 @@
         if (result.size() > 0)
             return result;
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List toBeStored = new LinkedList();
         GenericValue newPm = delegator.makeValue("PaymentMethod");
         toBeStored.add(newPm);
         GenericValue newGc = delegator.makeValue("GiftCard");
@@ -497,8 +497,8 @@
         return result;
     }
 
-    public static Map<String, Object> updateGiftCard(DispatchContext ctx, Map<String, Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+    public static Map updateGiftCard(DispatchContext ctx, Map context) {
+        Map result = new HashMap();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -511,7 +511,7 @@
         if (result.size() > 0)
             return result;
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List toBeStored = new LinkedList();
         boolean isModified = false;
 
         GenericValue paymentMethod = null;
@@ -623,8 +623,8 @@
      * @param context Map containing the input parameters
      * @return Map with the result of the service, the output parameters
      */
-    public static Map<String, Object> createEftAccount(DispatchContext ctx, Map<String, Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+    public static Map createEftAccount(DispatchContext ctx, Map context) {
+        Map result = new HashMap();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -635,7 +635,7 @@
 
         if (result.size() > 0) return result;
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List toBeStored = new LinkedList();
         GenericValue newPm = delegator.makeValue("PaymentMethod");
 
         toBeStored.add(newPm);
@@ -677,7 +677,7 @@
 
             GenericValue tempVal = null;
             try {
-                List<GenericValue> allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose",
+                List allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose",
                         UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId), null), true);
 
                 tempVal = EntityUtil.getFirst(allPCMPs);
@@ -715,8 +715,8 @@
      * @param context Map containing the input parameters
      * @return Map with the result of the service, the output parameters
      */
-    public static Map<String, Object> updateEftAccount(DispatchContext ctx, Map<String, Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+    public static Map updateEftAccount(DispatchContext ctx, Map context) {
+        Map result = new HashMap();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -727,7 +727,7 @@
 
         if (result.size() > 0) return result;
 
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List toBeStored = new LinkedList();
         boolean isModified = false;
 
         GenericValue paymentMethod = null;
@@ -794,7 +794,7 @@
             GenericValue tempVal = null;
 
             try {
-                List<GenericValue> allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose",
+                List allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose",
                             UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId",contactMechPurposeTypeId), null), true);
                 tempVal = EntityUtil.getFirst(allPCMPs);
             } catch (GenericEntityException e) {

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java?rev=882342&r1=882341&r2=882342&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java Thu Nov 19 22:45:56 2009
@@ -29,6 +29,7 @@
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityExpr;
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.ServiceUtil;

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java?rev=882342&r1=882341&r2=882342&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java Thu Nov 19 22:45:56 2009
@@ -21,6 +21,7 @@
 import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -30,19 +31,22 @@
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilDateTime;
-import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.base.util.UtilNumber;
 import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.UtilNumber;
 import org.ofbiz.common.geo.GeoWorker;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityConditionList;
+import org.ofbiz.entity.condition.EntityExpr;
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.party.contact.ContactMechWorker;
 import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ServiceUtil;
 
 /**
@@ -59,7 +63,7 @@
     public static int salestaxCalcDecimals = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
     public static int salestaxRounding = UtilNumber.getBigDecimalRoundingMode("salestax.rounding");
 
-    public static Map<String, Object> rateProductTaxCalcForDisplay(DispatchContext dctx, Map<String, Object> context) {
+    public static Map rateProductTaxCalcForDisplay(DispatchContext dctx, Map context) {
         Delegator delegator = dctx.getDelegator();
         String productStoreId = (String) context.get("productStoreId");
         String billToPartyId = (String) context.get("billToPartyId");
@@ -84,9 +88,9 @@
             }
 
             if ("Y".equals(productStore.getString("showPricesWithVatTax"))) {
-                Set<GenericValue> taxAuthoritySet = FastSet.newInstance();
+                Set taxAuthoritySet = FastSet.newInstance();
                 if (productStore.get("vatTaxAuthPartyId") == null) {
-                    List<GenericValue> taxAuthorityRawList = delegator.findList("TaxAuthority", EntityCondition.makeCondition("taxAuthGeoId", EntityOperator.EQUALS, productStore.get("vatTaxAuthGeoId")), null, null, null, true);
+                    List taxAuthorityRawList = delegator.findList("TaxAuthority", EntityCondition.makeCondition("taxAuthGeoId", EntityOperator.EQUALS, productStore.get("vatTaxAuthGeoId")), null, null, null, true);
                     taxAuthoritySet.addAll(taxAuthorityRawList);
                 } else {
                     GenericValue taxAuthority = delegator.findByPrimaryKeyCache("TaxAuthority", UtilMisc.toMap("taxAuthGeoId", productStore.get("vatTaxAuthGeoId"), "taxAuthPartyId", productStore.get("vatTaxAuthPartyId")));
@@ -97,14 +101,16 @@
                     throw new IllegalArgumentException("Could not find any Tax Authories for store with ID [" + productStoreId + "] for tax calculation; the store settings may need to be corrected.");
                 }
 
-                List<GenericValue> taxAdustmentList = getTaxAdjustments(delegator, product, productStore, null, billToPartyId, taxAuthoritySet, basePrice, amount, shippingPrice, ZERO_BASE);
+                List taxAdustmentList = getTaxAdjustments(delegator, product, productStore, null, billToPartyId, taxAuthoritySet, basePrice, amount, shippingPrice, ZERO_BASE);
                 if (taxAdustmentList.size() == 0) {
                     // this is something that happens every so often for different products and such, so don't blow up on it...
                     Debug.logWarning("Could not find any Tax Authories Rate Rules for store with ID [" + productStoreId + "], productId [" + productId + "], basePrice [" + basePrice + "], amount [" + amount + "], for tax calculation; the store settings may need to be corrected.", module);
                 }
 
                 // add up amounts from adjustments (amount OR exemptAmount, sourcePercentage)
-                for (GenericValue taxAdjustment : taxAdustmentList) {
+                Iterator taxAdustmentIter = taxAdustmentList.iterator();
+                while (taxAdustmentIter.hasNext()) {
+                    GenericValue taxAdjustment = (GenericValue) taxAdustmentIter.next();
                     taxPercentage = taxPercentage.add(taxAdjustment.getBigDecimal("sourcePercentage"));
                     BigDecimal adjAmount = taxAdjustment.getBigDecimal("amount");
                     taxTotal = taxTotal.add(adjAmount);
@@ -122,22 +128,22 @@
         taxTotal = taxTotal.setScale(salestaxFinalDecimals, salestaxRounding);
         priceWithTax = priceWithTax.setScale(salestaxFinalDecimals, salestaxRounding);
 
-        Map<String, Object> result = ServiceUtil.returnSuccess();
+        Map result = ServiceUtil.returnSuccess();
         result.put("taxTotal", taxTotal);
         result.put("taxPercentage", taxPercentage);
         result.put("priceWithTax", priceWithTax);
         return result;
     }
 
-    public static Map<String, Object> rateProductTaxCalc(DispatchContext dctx, Map<String, Object> context) {
+    public static Map rateProductTaxCalc(DispatchContext dctx, Map context) {
         Delegator delegator = dctx.getDelegator();
         String productStoreId = (String) context.get("productStoreId");
         String payToPartyId = (String) context.get("payToPartyId");
         String billToPartyId = (String) context.get("billToPartyId");
-        List<GenericValue> itemProductList = UtilGenerics.cast(context.get("itemProductList"));
-        List<BigDecimal> itemAmountList = UtilGenerics.cast(context.get("itemAmountList"));
-        List<BigDecimal> itemPriceList = UtilGenerics.cast(context.get("itemPriceList"));
-        List<BigDecimal> itemShippingList = UtilGenerics.cast(context.get("itemShippingList"));
+        List itemProductList = (List) context.get("itemProductList");
+        List itemAmountList = (List) context.get("itemAmountList");
+        List itemPriceList = (List) context.get("itemPriceList");
+        List itemShippingList = (List) context.get("itemShippingList");
         BigDecimal orderShippingAmount = (BigDecimal) context.get("orderShippingAmount");
         BigDecimal orderPromotionsAmount = (BigDecimal) context.get("orderPromotionsAmount");
         GenericValue shippingAddress = (GenericValue) context.get("shippingAddress");
@@ -147,7 +153,7 @@
         }
 
         // without knowing the TaxAuthority parties, just find all TaxAuthories for the set of IDs...
-        Set<GenericValue> taxAuthoritySet = FastSet.newInstance();
+        Set taxAuthoritySet = FastSet.newInstance();
         GenericValue productStore = null;
         // Check value productStore *** New
         if (productStoreId!=null) {
@@ -179,16 +185,16 @@
         }
     
         // Setup the return lists.
-        List<GenericValue> orderAdjustments = FastList.newInstance();
-        List<List<GenericValue>> itemAdjustments = FastList.newInstance();
+        List orderAdjustments = FastList.newInstance();
+        List itemAdjustments = FastList.newInstance();
 
         // Loop through the products; get the taxCategory; and lookup each in the cache.
         for (int i = 0; i < itemProductList.size(); i++) {
-            GenericValue product = itemProductList.get(i);
-            BigDecimal itemAmount = itemAmountList.get(i);
-            BigDecimal itemPrice = itemPriceList.get(i);
-            BigDecimal shippingAmount = itemShippingList.get(i);
-            List<GenericValue> taxList = null;
+            GenericValue product = (GenericValue) itemProductList.get(i);
+            BigDecimal itemAmount = (BigDecimal) itemAmountList.get(i);
+            BigDecimal itemPrice = (BigDecimal) itemPriceList.get(i);
+            BigDecimal shippingAmount = (BigDecimal) itemShippingList.get(i);
+            List taxList = null;
             if (shippingAddress != null) {
                 taxList = getTaxAdjustments(delegator, product, productStore, payToPartyId, billToPartyId, taxAuthoritySet, itemPrice, itemAmount, shippingAmount, ZERO_BASE);
             }
@@ -196,23 +202,23 @@
             itemAdjustments.add(taxList);
         }
         if (orderShippingAmount != null && orderShippingAmount.compareTo(BigDecimal.ZERO) > 0) {
-            List<GenericValue> taxList = getTaxAdjustments(delegator, null, productStore, payToPartyId, billToPartyId, taxAuthoritySet, ZERO_BASE, ZERO_BASE, orderShippingAmount, ZERO_BASE);
+            List taxList = getTaxAdjustments(delegator, null, productStore, payToPartyId, billToPartyId, taxAuthoritySet, ZERO_BASE, ZERO_BASE, orderShippingAmount, ZERO_BASE);
             orderAdjustments.addAll(taxList);
         }
         if (orderPromotionsAmount != null && orderPromotionsAmount.compareTo(BigDecimal.ZERO) != 0) {
-            List<GenericValue> taxList = getTaxAdjustments(delegator, null, productStore, payToPartyId, billToPartyId, taxAuthoritySet, ZERO_BASE, ZERO_BASE, ZERO_BASE, orderPromotionsAmount);
+            List taxList = getTaxAdjustments(delegator, null, productStore, payToPartyId, billToPartyId, taxAuthoritySet, ZERO_BASE, ZERO_BASE, ZERO_BASE, orderPromotionsAmount);
             orderAdjustments.addAll(taxList);
         }
 
-        Map<String, Object> result = ServiceUtil.returnSuccess();
+        Map result = ServiceUtil.returnSuccess();
         result.put("orderAdjustments", orderAdjustments);
         result.put("itemAdjustments", itemAdjustments);
 
         return result;
     }
 
-    private static void getTaxAuthorities(Delegator delegator, GenericValue shippingAddress, Set<GenericValue> taxAuthoritySet) throws GenericEntityException {
-        Set<String> geoIdSet = FastSet.newInstance();
+    private static void getTaxAuthorities(Delegator delegator, GenericValue shippingAddress, Set taxAuthoritySet) throws GenericEntityException {
+        Set geoIdSet = FastSet.newInstance();
         if (shippingAddress != null) {
             if (UtilValidate.isNotEmpty(shippingAddress.getString("countryGeoId"))) {
                 geoIdSet.add(shippingAddress.getString("countryGeoId"));
@@ -236,14 +242,14 @@
         geoIdSet = GeoWorker.expandGeoRegionDeep(geoIdSet, delegator);
         //Debug.logInfo("Tax calc geoIdSet after expand:" + geoIdSet, module);
 
-        List<GenericValue> taxAuthorityRawList = delegator.findList("TaxAuthority", EntityCondition.makeCondition("taxAuthGeoId", EntityOperator.IN, geoIdSet), null, null, null, true);
+        List taxAuthorityRawList = delegator.findList("TaxAuthority", EntityCondition.makeCondition("taxAuthGeoId", EntityOperator.IN, geoIdSet), null, null, null, true);
         taxAuthoritySet.addAll(taxAuthorityRawList);
         //Debug.logInfo("Tax calc taxAuthoritySet after expand:" + taxAuthoritySet, module);
     }
 
-    private static List<GenericValue> getTaxAdjustments(Delegator delegator, GenericValue product, GenericValue productStore, String payToPartyId, String billToPartyId, Set<GenericValue> taxAuthoritySet, BigDecimal itemPrice, BigDecimal itemAmount, BigDecimal shippingAmount, BigDecimal orderPromotionsAmount) {
+    private static List getTaxAdjustments(Delegator delegator, GenericValue product, GenericValue productStore, String payToPartyId, String billToPartyId, Set taxAuthoritySet, BigDecimal itemPrice, BigDecimal itemAmount, BigDecimal shippingAmount, BigDecimal orderPromotionsAmount) {
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
-        List<GenericValue> adjustments = FastList.newInstance();
+        List adjustments = FastList.newInstance();
 
         if (payToPartyId == null) {
             if (productStore != null) {
@@ -263,14 +269,16 @@
         }
 
         // build the TaxAuthority expressions (taxAuthGeoId, taxAuthPartyId)
-        List<EntityCondition> taxAuthCondOrList = FastList.newInstance();
+        List taxAuthCondOrList = FastList.newInstance();
         // start with the _NA_ TaxAuthority...
         taxAuthCondOrList.add(EntityCondition.makeCondition(
                 EntityCondition.makeCondition("taxAuthPartyId", EntityOperator.EQUALS, "_NA_"),
                 EntityOperator.AND,
                 EntityCondition.makeCondition("taxAuthGeoId", EntityOperator.EQUALS, "_NA_")));
 
-        for (GenericValue taxAuthority : taxAuthoritySet) {
+        Iterator taxAuthorityIter = taxAuthoritySet.iterator();
+        while (taxAuthorityIter.hasNext()) {
+            GenericValue taxAuthority = (GenericValue) taxAuthorityIter.next();
             EntityCondition taxAuthCond = EntityCondition.makeCondition(
                     EntityCondition.makeCondition("taxAuthPartyId", EntityOperator.EQUALS, taxAuthority.getString("taxAuthPartyId")),
                     EntityOperator.AND,
@@ -284,11 +292,13 @@
             if (product != null) {
                 // find the tax categories associated with the product and filter by those, with an IN clause or some such
                 // question: get all categories, or just a special type? for now let's do all categories...
-                Set<String> productCategoryIdSet = FastSet.newInstance();
-                List<GenericValue> pcmList = delegator.findByAndCache("ProductCategoryMember", UtilMisc.toMap("productId", product.get("productId")));
+                Set productCategoryIdSet = FastSet.newInstance();
+                List pcmList = delegator.findByAndCache("ProductCategoryMember", UtilMisc.toMap("productId", product.get("productId")));
                 pcmList = EntityUtil.filterByDate(pcmList, true);
-                for (GenericValue pcm : pcmList) {
-                    productCategoryIdSet.add((String) pcm.get("productCategoryId"));
+                Iterator pcmIter = pcmList.iterator();
+                while (pcmIter.hasNext()) {
+                    GenericValue pcm = (GenericValue) pcmIter.next();
+                    productCategoryIdSet.add(pcm.get("productCategoryId"));
                 }
 
                 if (productCategoryIdSet.size() == 0) {
@@ -304,17 +314,17 @@
             }
 
             // build the main condition clause
-            List<EntityCondition> mainExprs = UtilMisc.toList(storeCond, taxAuthoritiesCond, productCategoryCond);
+            List mainExprs = UtilMisc.toList(storeCond, taxAuthoritiesCond, productCategoryCond);
             mainExprs.add(EntityCondition.makeCondition(EntityCondition.makeCondition("minItemPrice", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("minItemPrice", EntityOperator.LESS_THAN_EQUAL_TO, itemPrice)));
             mainExprs.add(EntityCondition.makeCondition(EntityCondition.makeCondition("minPurchase", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("minPurchase", EntityOperator.LESS_THAN_EQUAL_TO, itemAmount)));
             EntityCondition mainCondition = EntityCondition.makeCondition(mainExprs, EntityOperator.AND);
     
             // create the orderby clause
-            List<String> orderList = UtilMisc.toList("minItemPrice", "minPurchase", "fromDate");
+            List orderList = UtilMisc.toList("minItemPrice", "minPurchase", "fromDate");
 
             // finally ready... do the rate query
-            List<GenericValue> lookupList = delegator.findList("TaxAuthorityRateProduct", mainCondition, null, orderList, null, false);
-            List<GenericValue> filteredList = EntityUtil.filterByDate(lookupList, true);
+            List lookupList = delegator.findList("TaxAuthorityRateProduct", mainCondition, null, orderList, null, false);
+            List filteredList = EntityUtil.filterByDate(lookupList, true);
           
             if (filteredList.size() == 0) {
                 Debug.logWarning("In TaxAuthority Product Rate no records were found for condition:" + mainCondition.toString(), module);
@@ -322,7 +332,9 @@
             }
 
             // find the right entry(s) based on purchase amount
-            for(GenericValue taxAuthorityRateProduct : filteredList) {
+            Iterator flIt = filteredList.iterator();
+            while (flIt.hasNext()) {
+                GenericValue taxAuthorityRateProduct = (GenericValue) flIt.next();
                 BigDecimal taxRate = taxAuthorityRateProduct.get("taxPercentage") != null ? taxAuthorityRateProduct.getBigDecimal("taxPercentage") : ZERO_BASE;
                 BigDecimal taxable = ZERO_BASE;
 
@@ -372,11 +384,13 @@
                 if (UtilValidate.isNotEmpty(billToPartyId) && UtilValidate.isNotEmpty(taxAuthGeoId)) {
                     // see if partyId is a member of any groups, if so honor their tax exemptions
                     // look for PartyRelationship with partyRelationshipTypeId=GROUP_ROLLUP, the partyIdTo is the group member, so the partyIdFrom is the groupPartyId
-                    Set<String> billToPartyIdSet = FastSet.newInstance();
+                    Set billToPartyIdSet = FastSet.newInstance();
                     billToPartyIdSet.add(billToPartyId);
-                    List<GenericValue> partyRelationshipList = EntityUtil.filterByDate(delegator.findByAndCache("PartyRelationship", UtilMisc.toMap("partyIdTo", billToPartyId, "partyRelationshipTypeId", "GROUP_ROLLUP")), true);
-                    for(GenericValue partyRelationship : partyRelationshipList) {
-                        billToPartyIdSet.add((String) partyRelationship.get("partyIdFrom"));
+                    List partyRelationshipList = EntityUtil.filterByDate(delegator.findByAndCache("PartyRelationship", UtilMisc.toMap("partyIdTo", billToPartyId, "partyRelationshipTypeId", "GROUP_ROLLUP")), true);
+                    Iterator partyRelationshipIter = partyRelationshipList.iterator();
+                    while (partyRelationshipIter.hasNext()) {
+                        GenericValue partyRelationship = (GenericValue) partyRelationshipIter.next();
+                        billToPartyIdSet.add(partyRelationship.get("partyIdFrom"));
                     }
                     handlePartyTaxExempt(adjValue, billToPartyIdSet, taxAuthGeoId, taxAuthPartyId, taxAmount, nowTimestamp, delegator);
                 } else {
@@ -387,23 +401,23 @@
             }
         } catch (GenericEntityException e) {
             Debug.logError(e, "Problems looking up tax rates", module);
-            return new ArrayList<GenericValue>();
+            return new ArrayList();
         }
 
         return adjustments;
     }
 
-    private static void handlePartyTaxExempt(GenericValue adjValue, Set<String> billToPartyIdSet, String taxAuthGeoId, String taxAuthPartyId, BigDecimal taxAmount, Timestamp nowTimestamp, Delegator delegator) throws GenericEntityException {
+    private static void handlePartyTaxExempt(GenericValue adjValue, Set billToPartyIdSet, String taxAuthGeoId, String taxAuthPartyId, BigDecimal taxAmount, Timestamp nowTimestamp, Delegator delegator) throws GenericEntityException {
         Debug.logInfo("Checking for tax exemption : " + taxAuthGeoId + " / " + taxAuthPartyId, module);
-        List<EntityCondition> ptiConditionList = UtilMisc.toList(
-                (EntityCondition)EntityCondition.makeCondition("partyId", EntityOperator.IN, billToPartyIdSet),
+        List ptiConditionList = UtilMisc.toList(
+                EntityCondition.makeCondition("partyId", EntityOperator.IN, billToPartyIdSet),
                 EntityCondition.makeCondition("taxAuthGeoId", EntityOperator.EQUALS, taxAuthGeoId),
                 EntityCondition.makeCondition("taxAuthPartyId", EntityOperator.EQUALS, taxAuthPartyId));
         ptiConditionList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp));
         ptiConditionList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, nowTimestamp)));
         EntityCondition ptiCondition = EntityCondition.makeCondition(ptiConditionList, EntityOperator.AND);
         // sort by -fromDate to get the newest (largest) first, just in case there is more than one, we only want the most recent valid one, should only be one per jurisdiction...
-        List<GenericValue> partyTaxInfos = delegator.findList("PartyTaxAuthInfo", ptiCondition, null, UtilMisc.toList("-fromDate"), null, false);
+        List partyTaxInfos = delegator.findList("PartyTaxAuthInfo", ptiCondition, null, UtilMisc.toList("-fromDate"), null, false);
 
         boolean foundExemption = false;
         if (partyTaxInfos.size() > 0) {
@@ -419,7 +433,7 @@
         // if no exceptions were found for the current; try the parent
         if (!foundExemption) {
             // try the "parent" TaxAuthority
-            List<GenericValue> taxAuthorityAssocList = delegator.findByAndCache("TaxAuthorityAssoc",
+            List taxAuthorityAssocList = delegator.findByAndCache("TaxAuthorityAssoc",
                     UtilMisc.toMap("toTaxAuthGeoId", taxAuthGeoId, "toTaxAuthPartyId", taxAuthPartyId, "taxAuthorityAssocTypeId", "EXEMPT_INHER"),
                     UtilMisc.toList("-fromDate"));
             taxAuthorityAssocList = EntityUtil.filterByDate(taxAuthorityAssocList, true);