You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2009/05/01 12:28:35 UTC

svn commit: r770618 - in /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting: ./ agreement/ finaccount/ invoice/ thirdparty/authorizedotnet/

Author: lektran
Date: Fri May  1 10:28:34 2009
New Revision: 770618

URL: http://svn.apache.org/viewvc?rev=770618&view=rev
Log:
Code cleanups, generics etc.

Modified:
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/agreement/AgreementServices.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountPaymentServices.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountProductServices.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountServices.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/thirdparty/authorizedotnet/AuthorizeResponse.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=770618&r1=770617&r2=770618&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java Fri May  1 10:28:34 2009
@@ -18,35 +18,32 @@
  *******************************************************************************/
 package org.ofbiz.accounting;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import java.math.BigDecimal;
-import java.util.Map;
 import java.util.List;
-import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.base.util.UtilDateTime;
-import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
+import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ServiceUtil;
-import org.ofbiz.service.GenericServiceException;
-import org.ofbiz.webapp.event.EventHandlerException;
 
 public class GlEvents {
 
 public static final String module = GlEvents.class.getName();
-public static String createReconcileAccount(HttpServletRequest request,HttpServletResponse response) {
+public static String createReconcileAccount(HttpServletRequest request, HttpServletResponse response) {
     LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
     final GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator");
     GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
-    Map ctx = UtilHttp.getParameterMap(request);
+    Map<String, Object> ctx = UtilHttp.getParameterMap(request);
     String acctgTransId;
     String acctgTransEntrySeqId;
     String glAccountId = null;
@@ -67,21 +64,16 @@
         acctgTransEntrySeqId = (String) ctx.get("acctgTransEntrySeqId" + suffix);
         organizationPartyId = (String) ctx.get("organizationPartyId" + suffix);
         glAccountId = (String) ctx.get("glAccountId" + suffix);
-        GenericValue acctgTransEntry;
         try {
-            List acctgTransEntries = delegator.findByAnd("AcctgTransEntry", UtilMisc.toMap("acctgTransId", acctgTransId, "acctgTransEntrySeqId", acctgTransEntrySeqId));
-            if (acctgTransEntries.size() > 0) {
-                Iterator acctgTransEntryItr = acctgTransEntries.iterator();
-                while (acctgTransEntryItr.hasNext()) {  //calculate amount for each AcctgTransEntry according to glAccountId based on debit and credit
-                    acctgTransEntry = (GenericValue) acctgTransEntryItr.next();
-                    debitCreditFlag = (String) acctgTransEntry.getString("debitCreditFlag");
+            List<GenericValue> acctgTransEntries = delegator.findByAnd("AcctgTransEntry", UtilMisc.toMap("acctgTransId", acctgTransId, "acctgTransEntrySeqId", acctgTransEntrySeqId));
+                for (GenericValue acctgTransEntry : acctgTransEntries) {  //calculate amount for each AcctgTransEntry according to glAccountId based on debit and credit
+                    debitCreditFlag = acctgTransEntry.getString("debitCreditFlag");
                     if ("D".equalsIgnoreCase(debitCreditFlag)) {
                         amount = amount.add(acctgTransEntry.getBigDecimal("amount")); //for debit
                     } else {
-                          amount = amount.subtract(acctgTransEntry.getBigDecimal("amount")); //for credit
+                        amount = amount.subtract(acctgTransEntry.getBigDecimal("amount")); //for credit
                     }
                 }
-            }
             reconciledBalance = reconciledBalance.add(amount);  //total balance per glAccountId
         } catch (GenericEntityException e) {
             Debug.logError(e, module);
@@ -89,8 +81,8 @@
         }
 
     }
-    Map fieldMap = UtilMisc.toMap("glReconciliationName", "Reconciliation at date " + UtilDateTime.nowTimestamp(), "glAccountId", glAccountId, "organizationPartyId", organizationPartyId, "reconciledDate", UtilDateTime.nowTimestamp(), "reconciledBalance", reconciledBalance, "userLogin", userLogin);
-    Map glReconResult = null;
+    Map<String, Object> fieldMap = UtilMisc.toMap("glReconciliationName", "Reconciliation at date " + UtilDateTime.nowTimestamp(), "glAccountId", glAccountId, "organizationPartyId", organizationPartyId, "reconciledDate", UtilDateTime.nowTimestamp(), "reconciledBalance", reconciledBalance, "userLogin", userLogin);
+    Map<String, Object> glReconResult = null;
     try {
         glReconResult = dispatcher.runSync("createGlReconciliation", fieldMap); //create GlReconciliation for the glAccountId
         if (ServiceUtil.isError(glReconResult)) {
@@ -110,27 +102,22 @@
         }
         acctgTransId = (String) ctx.get("acctgTransId" + suffix);
         acctgTransEntrySeqId = (String) ctx.get("acctgTransEntrySeqId" + suffix);
-        GenericValue acctgTransEntry;
         try {
-            List acctgTransEntries = delegator.findByAnd("AcctgTransEntry", UtilMisc.toMap("acctgTransId", acctgTransId, "acctgTransEntrySeqId", acctgTransEntrySeqId));
-            if (acctgTransEntries.size() > 0) {
-                Iterator acctgTransEntryItr = acctgTransEntries.iterator();
-                while (acctgTransEntryItr.hasNext()) {
-                    acctgTransEntry = (GenericValue) acctgTransEntryItr.next();
-                    reconciledAmount = acctgTransEntry.getString("amount");
-                    acctgTransId = acctgTransEntry.getString("acctgTransId");
-                    acctgTransEntrySeqId = acctgTransEntry.getString("acctgTransEntrySeqId");
-                    Map glReconEntryMap = UtilMisc.toMap("glReconciliationId", glReconciliationId, "acctgTransId", acctgTransId, "acctgTransEntrySeqId", acctgTransEntrySeqId, "reconciledAmount", reconciledAmount, "userLogin", userLogin);
-                    Map glReconEntryResult = null;
-                    try {
-                        glReconEntryResult = dispatcher.runSync("createGlReconciliationEntry", glReconEntryMap);
-                        if (ServiceUtil.isError(glReconEntryResult)) {
-                            return "error";
-                        }
-                    } catch (GenericServiceException e) {
-                        Debug.logError(e, module);
+            List<GenericValue> acctgTransEntries = delegator.findByAnd("AcctgTransEntry", UtilMisc.toMap("acctgTransId", acctgTransId, "acctgTransEntrySeqId", acctgTransEntrySeqId));
+            for (GenericValue acctgTransEntry : acctgTransEntries) {
+                reconciledAmount = acctgTransEntry.getString("amount");
+                acctgTransId = acctgTransEntry.getString("acctgTransId");
+                acctgTransEntrySeqId = acctgTransEntry.getString("acctgTransEntrySeqId");
+                Map<String, Object> glReconEntryMap = UtilMisc.toMap("glReconciliationId", glReconciliationId, "acctgTransId", acctgTransId, "acctgTransEntrySeqId", acctgTransEntrySeqId, "reconciledAmount", reconciledAmount, "userLogin", userLogin);
+                Map<String, Object> glReconEntryResult = null;
+                try {
+                    glReconEntryResult = dispatcher.runSync("createGlReconciliationEntry", glReconEntryMap);
+                    if (ServiceUtil.isError(glReconEntryResult)) {
                         return "error";
                     }
+                } catch (GenericServiceException e) {
+                    Debug.logError(e, module);
+                    return "error";
                 }
             }
         } catch (GenericEntityException e) {

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/agreement/AgreementServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/agreement/AgreementServices.java?rev=770618&r1=770617&r2=770618&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/agreement/AgreementServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/agreement/AgreementServices.java Fri May  1 10:28:34 2009
@@ -20,11 +20,12 @@
 package org.ofbiz.accounting.agreement;
 
 import java.math.BigDecimal;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+
 import javolution.util.FastList;
+
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilNumber;
@@ -75,11 +76,11 @@
      *              currencyUomId   String  Currency
      *              productId       String  Product Id
      */
-    public static Map getCommissionForProduct(DispatchContext ctx, Map context) {
+    public static Map<String, Object> getCommissionForProduct(DispatchContext ctx, Map<String, Object> context) {
         GenericDelegator delegator = ctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
         String errMsg = null;
-        List commissions = FastList.newInstance();
+        List<Map<String, Object>> commissions = FastList.newInstance();
 
         try {
             BigDecimal amount = ((BigDecimal)context.get("amount"));
@@ -94,12 +95,12 @@
 
             // Collect agreementItems applicable to this orderItem/returnItem
             // TODO: partyIds should be part of this query!
-            List agreementItems = delegator.findByAndCache("AgreementItemAndProductAppl", UtilMisc.toMap(
+            List<GenericValue> agreementItems = delegator.findByAndCache("AgreementItemAndProductAppl", UtilMisc.toMap(
                     "productId", productId,
                     "agreementItemTypeId", "AGREEMENT_COMMISSION"));
             // Try the first available virtual product if this is a variant product
             if (agreementItems.size() == 0) {
-                List productAssocs = delegator.findByAndCache("ProductAssoc", UtilMisc.toMap(
+                List<GenericValue> productAssocs = delegator.findByAndCache("ProductAssoc", UtilMisc.toMap(
                         "productIdTo", productId,
                         "productAssocTypeId", "PRODUCT_VARIANT"));
                 productAssocs = EntityUtil.filterByDate(productAssocs);
@@ -113,10 +114,8 @@
             // this is not very efficient if there were many
             agreementItems = EntityUtil.filterByDate(agreementItems);
 
-            Iterator it = agreementItems.iterator();
-            while (it.hasNext()) {
-                GenericValue agreementItem = (GenericValue) it.next();
-                List terms = delegator.findByAndCache("AgreementTerm", UtilMisc.toMap(
+            for (GenericValue agreementItem : agreementItems) {
+                List<GenericValue> terms = delegator.findByAndCache("AgreementTerm", UtilMisc.toMap(
                         "agreementId", agreementItem.getString("agreementId"),
                         "agreementItemSeqId", agreementItem.getString("agreementItemSeqId"),
                         "invoiceItemTypeId", invoiceItemTypeId));
@@ -127,11 +126,9 @@
 
                     // number of days due for commission, which will be the lowest termDays of all the AgreementTerms
                     long days = -1;
-                    Iterator itt = terms.iterator();
-                    while (itt.hasNext()) {
-                        GenericValue elem = (GenericValue) itt.next();
-                        String termTypeId = elem.getString("termTypeId");
-                        BigDecimal termValue = elem.getBigDecimal("termValue");
+                    for (GenericValue term : terms) {
+                        String termTypeId = term.getString("termTypeId");
+                        BigDecimal termValue = term.getBigDecimal("termValue");
                         if (termValue != null) {
                             if (termTypeId.equals("FIN_COMM_FIXED")) {
                                 commission = commission.add(termValue.multiply(quantity));
@@ -147,7 +144,7 @@
                         }
 
                         // see if we need to update the number of days for paying commission
-                        Long termDays = elem.getLong("termDays");
+                        Long termDays = term.getLong("termDays");
                         if (termDays != null) {
                             // if days is greater than zero, then it has been set with another value, so we use the lowest term days
                             // if days is less than zero, then it has not been set yet.
@@ -165,7 +162,7 @@
                     commission = negative ? commission.negate() : commission;
                     commission = commission.setScale(decimals, rounding);
 
-                    Map partyCommissionResult = UtilMisc.toMap(
+                    Map<String, Object> partyCommissionResult = UtilMisc.toMap(
                             "partyIdFrom", agreementItem.getString("partyIdFrom"),
                             "partyIdTo", agreementItem.getString("partyIdTo"),
                             "commission", commission,
@@ -179,7 +176,7 @@
             }
         } catch (GenericEntityException e) {
             Debug.logWarning(e, module);
-            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage());
             errMsg = UtilProperties.getMessage("CommonUiLabels", "CommonDatabaseProblem", messageMap, locale);
             return ServiceUtil.returnError(errMsg);
         }

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountPaymentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountPaymentServices.java?rev=770618&r1=770617&r2=770618&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountPaymentServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountPaymentServices.java Fri May  1 10:28:34 2009
@@ -19,33 +19,36 @@
 
 package org.ofbiz.accounting.finaccount;
 
-import org.ofbiz.service.DispatchContext;
-import org.ofbiz.service.LocalDispatcher;
-import org.ofbiz.service.ServiceUtil;
-import org.ofbiz.service.GenericServiceException;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.List;
+import java.util.Map;
+
+import javolution.util.FastList;
+import javolution.util.FastMap;
+
+import org.ofbiz.accounting.payment.PaymentGatewayServices;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.GenericDelegator;
-import org.ofbiz.entity.GenericValue;
 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.entity.condition.EntityConditionList;
 import org.ofbiz.entity.util.EntityFindOptions;
 import org.ofbiz.entity.util.EntityUtil;
-import org.ofbiz.base.util.*;
-import org.ofbiz.order.order.OrderReadHelper;
 import org.ofbiz.order.finaccount.FinAccountHelper;
-import org.ofbiz.accounting.payment.PaymentGatewayServices;
+import org.ofbiz.order.order.OrderReadHelper;
 import org.ofbiz.product.store.ProductStoreWorker;
-
-import java.util.Map;
-import java.util.List;
-import java.util.Set;
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-
-import javolution.util.FastMap;
-import javolution.util.FastList;
+import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ServiceUtil;
 
 /**
  * FinAccountPaymentServices - Financial account used as payment method
@@ -54,8 +57,8 @@
 
     public static final String module = FinAccountPaymentServices.class.getName();
 
-    // base payment intergration services
-    public static Map finAccountPreAuth(DispatchContext dctx, Map context) {
+    // base payment integration services
+    public static Map<String, Object> finAccountPreAuth(DispatchContext dctx, Map<String, Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericDelegator delegator = dctx.getDelegator();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -70,7 +73,7 @@
         // check for an existing auth trans and cancel it
         GenericValue authTrans = PaymentGatewayServices.getAuthTransaction(paymentPref);
         if (authTrans != null) {
-            Map input = UtilMisc.toMap("userLogin", userLogin, "finAccountAuthId", authTrans.get("referenceNum"));
+            Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "finAccountAuthId", authTrans.get("referenceNum"));
             try {
                 dispatcher.runSync("expireFinAccountAuth", input);
             } catch (GenericServiceException e) {
@@ -123,7 +126,7 @@
 
         try {
             // fin the store requires a pin number; validate the PIN with the code
-            Map findProductStoreFinActSettingMap = UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", finAccountTypeId);
+            Map<String, Object> findProductStoreFinActSettingMap = UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", finAccountTypeId);
             GenericValue finAccountSettings = delegator.findByPrimaryKeyCache("ProductStoreFinActSetting", findProductStoreFinActSettingMap);
 
             if (finAccountSettings == null) {
@@ -144,7 +147,7 @@
                 // validate the PIN if the store requires it
                 if ("Y".equals(finAccountSettings.getString("requirePinCode"))) {
                     if (!FinAccountHelper.validatePin(delegator, finAccountCode, finAccountPin)) {
-                        Map result = ServiceUtil.returnSuccess();
+                        Map<String, Object> result = ServiceUtil.returnSuccess();
                         result.put("authMessage", "Financial account PIN/CODE combination not found");
                         result.put("authResult", Boolean.FALSE);
                         result.put("processAmount", amount);
@@ -159,7 +162,7 @@
 
             // check for expiration date
             if ((finAccount.getTimestamp("thruDate") != null) && (finAccount.getTimestamp("thruDate").before(UtilDateTime.nowTimestamp()))) {
-                Map result = ServiceUtil.returnSuccess();
+                Map<String, Object> result = ServiceUtil.returnSuccess();
                 result.put("authMessage", "Account has expired as of " + finAccount.getTimestamp("thruDate"));
                 result.put("authResult", Boolean.FALSE);
                 result.put("processAmount", amount);
@@ -177,7 +180,7 @@
                 statusId = finAccount.getString("statusId");
 
                 if ("FNACT_NEGPENDREPL".equals(statusId) || "FNACT_MANFROZEN".equals(statusId) || "FNACT_CANCELLED".equals(statusId)) {
-                    Map result = ServiceUtil.returnSuccess();
+                    Map<String, Object> result = ServiceUtil.returnSuccess();
                     if ("FNACT_NEGPENDREPL".equals(statusId)) {
                         result.put("authMessage", "Account is currently negative and pending replenishment");
                     } else if ("FNACT_MANFROZEN".equals(statusId)) {
@@ -208,7 +211,7 @@
             }
 
 
-            Map result = ServiceUtil.returnSuccess();
+            Map<String, Object> result = ServiceUtil.returnSuccess();
             String authMessage = null;
             Boolean processResult;
             String refNum;
@@ -228,15 +231,14 @@
                     thruDate = UtilDateTime.getDayEnd(UtilDateTime.nowTimestamp(), new Long(30)); // default 30 days for an auth
                 }
 
-                Map tmpResult = dispatcher.runSync("createFinAccountAuth", UtilMisc.<String, Object>toMap("finAccountId", finAccountId,
+                Map<String, Object> tmpResult = dispatcher.runSync("createFinAccountAuth", UtilMisc.<String, Object>toMap("finAccountId", finAccountId,
                         "amount", amount, "thruDate", thruDate, "userLogin", userLogin));
 
                 if (ServiceUtil.isError(tmpResult)) {
                     return tmpResult;
-                } else {
-                    refNum = (String) tmpResult.get("finAccountAuthId");
-                    processResult = Boolean.TRUE;
                 }
+                refNum = (String) tmpResult.get("finAccountAuthId");
+                processResult = Boolean.TRUE;
 
                 // refresh the account
                 finAccount.refresh();
@@ -266,7 +268,7 @@
         }
     }
 
-    public static Map finAccountReleaseAuth(DispatchContext dctx, Map context) {
+    public static Map<String, Object> finAccountReleaseAuth(DispatchContext dctx, Map<String, Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
 
@@ -281,10 +283,10 @@
                 return ServiceUtil.returnError(err + " Could not find authorization transaction.");
             }
 
-            Map input = UtilMisc.toMap("userLogin", userLogin, "finAccountAuthId", authTransaction.get("referenceNum"));
-            Map serviceResults = dispatcher.runSync("expireFinAccountAuth", input);
+            Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "finAccountAuthId", authTransaction.get("referenceNum"));
+            Map<String, Object> serviceResults = dispatcher.runSync("expireFinAccountAuth", input);
 
-            Map result = ServiceUtil.returnSuccess();
+            Map<String, Object> result = ServiceUtil.returnSuccess();
             result.put("releaseRefNum", authTransaction.getString("referenceNum"));
             result.put("releaseAmount", authTransaction.getBigDecimal("amount"));
             result.put("releaseResult", Boolean.TRUE);
@@ -301,7 +303,7 @@
         }
     }
 
-    public static Map finAccountCapture(DispatchContext dctx, Map context) {
+    public static Map<String, Object> finAccountCapture(DispatchContext dctx, Map<String, Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericDelegator delegator = dctx.getDelegator();
 
@@ -367,10 +369,10 @@
         }
 
         // BIG NOTE: make sure the expireFinAccountAuth and finAccountWithdraw services are done in the SAME TRANSACTION
-        //(ie no require-new-transaction in either of them AND no running async)
+        //(i.e. no require-new-transaction in either of them AND no running async)
 
         // cancel the authorization before doing the withdraw to avoid problems with way negative available amount on account; should happen in same transaction to avoid conflict problems
-        Map releaseResult;
+        Map<String, Object> releaseResult;
         try {
             releaseResult = dispatcher.runSync("expireFinAccountAuth", UtilMisc.<String, Object>toMap("userLogin", userLogin, "finAccountAuthId", finAccountAuthId));
         } catch (GenericServiceException e) {
@@ -382,7 +384,7 @@
         }
 
         // build the withdraw context
-        Map withdrawCtx = FastMap.newInstance();
+        Map<String, Object> withdrawCtx = FastMap.newInstance();
         withdrawCtx.put("finAccountId", finAccountId);
         withdrawCtx.put("productStoreId", productStoreId);
         withdrawCtx.put("currency", currency);
@@ -394,7 +396,7 @@
         withdrawCtx.put("userLogin", userLogin);
 
         // call the withdraw service
-        Map withdrawResp;
+        Map<String, Object> withdrawResp;
         try {
             withdrawResp = dispatcher.runSync("finAccountWithdraw", withdrawCtx);
         } catch (GenericServiceException e) {
@@ -406,7 +408,7 @@
         }
 
         // create the capture response
-        Map result = ServiceUtil.returnSuccess();
+        Map<String, Object> result = ServiceUtil.returnSuccess();
         Boolean processResult = (Boolean) withdrawResp.get("processResult");
         BigDecimal withdrawAmount = (BigDecimal) withdrawResp.get("amount");
         String referenceNum = (String) withdrawResp.get("referenceNum");
@@ -419,7 +421,7 @@
         return result;
     }
 
-    public static Map finAccountRefund(DispatchContext dctx, Map context) {
+    public static Map<String, Object> finAccountRefund(DispatchContext dctx, Map<String, Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericDelegator delegator = dctx.getDelegator();
 
@@ -454,7 +456,7 @@
         }
 
         // call the deposit service
-        Map depositCtx = FastMap.newInstance();
+        Map<String, Object> depositCtx = FastMap.newInstance();
         depositCtx.put("finAccountId", finAccountId);
         depositCtx.put("productStoreId", productStoreId);
         depositCtx.put("isRefund", Boolean.TRUE);
@@ -465,7 +467,7 @@
         depositCtx.put("reasonEnumId", "FATR_REFUND");
         depositCtx.put("userLogin", userLogin);
 
-        Map depositResp;
+        Map<String, Object> depositResp;
         try {
             depositResp = dispatcher.runSync("finAccountDeposit", depositCtx);
         } catch (GenericServiceException e) {
@@ -477,7 +479,7 @@
         }
 
         // create the refund response
-        Map result = ServiceUtil.returnSuccess();
+        Map<String, Object> result = ServiceUtil.returnSuccess();
         Boolean processResult = (Boolean) depositResp.get("processResult");
         BigDecimal depositAmount = (BigDecimal) depositResp.get("amount");
         String referenceNum = (String) depositResp.get("referenceNum");
@@ -491,7 +493,7 @@
     }
 
     // base account transaction services
-    public static Map finAccountWithdraw(DispatchContext dctx, Map context) {
+    public static Map<String, Object> finAccountWithdraw(DispatchContext dctx, Map<String, Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericDelegator delegator = dctx.getDelegator();
 
@@ -570,7 +572,7 @@
             balance = FinAccountHelper.ZERO;
         }
 
-        Map result = ServiceUtil.returnSuccess();
+        Map<String, Object> result = ServiceUtil.returnSuccess();
         result.put("previousBalance", previousBalance);
         result.put("balance", balance);
         result.put("amount", amount);
@@ -580,7 +582,7 @@
     }
 
     // base deposit service
-    public static Map finAccountDeposit(DispatchContext dctx, Map context) {
+    public static Map<String, Object> finAccountDeposit(DispatchContext dctx, Map<String, Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericDelegator delegator = dctx.getDelegator();
 
@@ -649,7 +651,7 @@
             if (actualBalance.compareTo(BigDecimal.ZERO) < 0) {
                 // balance went below zero, set negative pending replenishment status so that no more auths or captures will go through until it is replenished
                 try {
-                    Map rollbackCtx = UtilMisc.toMap("userLogin", userLogin, "finAccountId", finAccountId, "statusId", "FNACT_NEGPENDREPL");
+                    Map<String, Object> rollbackCtx = UtilMisc.toMap("userLogin", userLogin, "finAccountId", finAccountId, "statusId", "FNACT_NEGPENDREPL");
                     dispatcher.addRollbackService("updateFinAccount", rollbackCtx, true);
                 } catch (GenericServiceException e) {
                     Debug.logError(e, module);
@@ -658,7 +660,7 @@
             }
         }
 
-        Map result = ServiceUtil.returnSuccess();
+        Map<String, Object> result = ServiceUtil.returnSuccess();
         result.put("previousBalance", previousBalance);
         result.put("balance", actualBalance);
         result.put("amount", amount);
@@ -668,7 +670,7 @@
     }
 
     // auto-replenish service (deposit)
-    public static Map finAccountReplenish(DispatchContext dctx, Map context) {
+    public static Map<String, Object> finAccountReplenish(DispatchContext dctx, Map<String, Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericDelegator delegator = dctx.getDelegator();
 
@@ -714,7 +716,7 @@
 
         // get the product store settings
         GenericValue finAccountSettings;
-        Map psfasFindMap = UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", finAccount.getString("finAccountTypeId"));
+        Map<String, Object> psfasFindMap = UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", finAccount.getString("finAccountTypeId"));
         try {
             finAccountSettings = delegator.findByPrimaryKeyCache("ProductStoreFinActSetting", psfasFindMap);
         } catch (GenericEntityException e) {
@@ -753,7 +755,7 @@
         // configure rollback service to set status to Negative Pending Replenishment
         if ("FNACT_NEGPENDREPL".equals(statusId)) {
             try {
-                Map rollbackCtx = UtilMisc.toMap("userLogin", userLogin, "finAccountId", finAccountId, "statusId", "FNACT_NEGPENDREPL");
+                Map<String, Object> rollbackCtx = UtilMisc.toMap("userLogin", userLogin, "finAccountId", finAccountId, "statusId", "FNACT_NEGPENDREPL");
                 dispatcher.addRollbackService("updateFinAccount", rollbackCtx, true);
             } catch (GenericServiceException e) {
                 Debug.logError(e, module);
@@ -802,15 +804,15 @@
         }
 
         // hit the payment method for the amount to replenish
-        Map orderItemMap = UtilMisc.toMap("Auto-Replenishment FA #" + finAccountId, depositAmount);
-        Map replOrderCtx = FastMap.newInstance();
+        Map<String, Object> orderItemMap = UtilMisc.toMap("Auto-Replenishment FA #" + finAccountId, depositAmount);
+        Map<String, Object> replOrderCtx = FastMap.newInstance();
         replOrderCtx.put("productStoreId", productStoreId);
         replOrderCtx.put("paymentMethodId", paymentMethod.getString("paymentMethodId"));
         replOrderCtx.put("currency", currency);
         replOrderCtx.put("partyId", ownerPartyId);
         replOrderCtx.put("itemMap", orderItemMap);
         replOrderCtx.put("userLogin", userLogin);
-        Map replResp;
+        Map<String, Object> replResp;
         try {
             replResp = dispatcher.runSync("createSimpleNonProductSalesOrder", replOrderCtx);
         } catch (GenericServiceException e) {
@@ -823,7 +825,7 @@
         String orderId = (String) replResp.get("orderId");
 
         // create the deposit
-        Map depositCtx = FastMap.newInstance();
+        Map<String, Object> depositCtx = FastMap.newInstance();
         depositCtx.put("productStoreId", productStoreId);
         depositCtx.put("finAccountId", finAccountId);
         depositCtx.put("currency", currency);
@@ -834,7 +836,7 @@
         depositCtx.put("reasonEnumId", "FATR_REPLENISH");
         depositCtx.put("userLogin", userLogin);
         try {
-            Map depositResp = dispatcher.runSync("finAccountDeposit", depositCtx);
+            Map<String, Object> depositResp = dispatcher.runSync("finAccountDeposit", depositCtx);
             if (ServiceUtil.isError(depositResp)) {
                 return depositResp;
             }
@@ -846,7 +848,7 @@
         // say we are in good standing again
         if ("FNACT_NEGPENDREPL".equals(statusId)) {
             try {
-                Map ufaResp = dispatcher.runSync("updateFinAccount", UtilMisc.<String, Object>toMap("finAccountId", finAccountId, "statusId", "FNACT_ACTIVE", "userLogin", userLogin));
+                Map<String, Object> ufaResp = dispatcher.runSync("updateFinAccount", UtilMisc.<String, Object>toMap("finAccountId", finAccountId, "statusId", "FNACT_ACTIVE", "userLogin", userLogin));
                 if (ServiceUtil.isError(ufaResp)) {
                     return ufaResp;
                 }
@@ -864,13 +866,13 @@
         opts.setMaxRows(1);
         opts.setFetchSize(1);
 
-        List exprs = FastList.newInstance();
+        List<EntityExpr> exprs = FastList.newInstance();
         exprs.add(EntityCondition.makeCondition("finAccountTransTypeId", EntityOperator.EQUALS, "DEPOSIT"));
         exprs.add(EntityCondition.makeCondition("finAccountId", EntityOperator.EQUALS, finAccountId));
         exprs.add(EntityCondition.makeCondition("orderId", EntityOperator.NOT_EQUAL, null));
-        List orderBy = UtilMisc.toList("-transactionDate");
+        List<String> orderBy = UtilMisc.toList("-transactionDate");
 
-        List transList = null;
+        List<GenericValue> transList = null;
         try {
             transList = delegator.findList("FinAccountTrans", EntityCondition.makeCondition(exprs, EntityOperator.AND), null, orderBy, opts, false);
         } catch (GenericEntityException e) {
@@ -940,7 +942,7 @@
 
         // payment amount should always be positive; adjustments may
         // create the payment for the transaction
-        Map paymentCtx = UtilMisc.toMap("paymentTypeId", paymentType);
+        Map<String, Object> paymentCtx = UtilMisc.toMap("paymentTypeId", paymentType);
         paymentCtx.put("paymentMethodTypeId", paymentMethodType);
         paymentCtx.put("partyIdTo", partyIdTo);
         paymentCtx.put("partyIdFrom", partyIdFrom);
@@ -951,7 +953,7 @@
         paymentCtx.put("paymentRefNum", Long.toString(UtilDateTime.nowTimestamp().getTime()));
 
         String paymentId;
-        Map payResult;
+        Map<String, Object> payResult;
         try {
             payResult = dispatcher.runSync("createPayment", paymentCtx);
         } catch (GenericServiceException e) {
@@ -962,12 +964,11 @@
         }
         if (ServiceUtil.isError(payResult)) {
             throw new GeneralException(ServiceUtil.getErrorMessage(payResult));
-        } else {
-            paymentId = (String) payResult.get("paymentId");
         }
+        paymentId = (String) payResult.get("paymentId");
 
         // create the initial transaction
-        Map transCtx = UtilMisc.toMap("finAccountTransTypeId", txType);
+        Map<String, Object> transCtx = UtilMisc.toMap("finAccountTransTypeId", txType);
         transCtx.put("finAccountId", finAccountId);
         transCtx.put("partyId", partyId);
         transCtx.put("orderId", orderId);
@@ -977,8 +978,7 @@
         transCtx.put("userLogin", userLogin);
         transCtx.put("paymentId", paymentId);
 
-        Map transResult;
-        String txId;
+        Map<String, Object> transResult;
         try {
             transResult = dispatcher.runSync("createFinAccountTrans", transCtx);
         } catch (GenericServiceException e) {
@@ -989,10 +989,8 @@
         }
         if (ServiceUtil.isError(transResult)) {
             throw new GeneralException(ServiceUtil.getErrorMessage(transResult));
-        } else {
-            txId = (String) transResult.get("finAccountTransId");
         }
 
-        return txId;
+        return (String) transResult.get("finAccountTransId");
     }
 }

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountProductServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountProductServices.java?rev=770618&r1=770617&r2=770618&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountProductServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountProductServices.java Fri May  1 10:28:34 2009
@@ -44,7 +44,7 @@
 
     public static final String module = FinAccountProductServices.class.getName();
 
-    public static Map createPartyFinAccountFromPurchase(DispatchContext dctx, Map context) {
+    public static Map<String, Object> createPartyFinAccountFromPurchase(DispatchContext dctx, Map<String, Object> context) {
         // this service should always be called via FULFILLMENT_EXTASYNC
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericDelegator delegator = dctx.getDelegator();
@@ -68,7 +68,7 @@
         String productId = orderItem.getString("productId");
         GenericValue featureAndAppl;
         try {
-            List featureAndAppls = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId,
+            List<GenericValue> featureAndAppls = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId,
                     "productFeatureTypeId", "TYPE", "productFeatureApplTypeId", "STANDARD_FEATURE"));
             featureAndAppls = EntityUtil.filterByDate(featureAndAppls);
             featureAndAppl = EntityUtil.getFirst(featureAndAppls);
@@ -129,13 +129,11 @@
         }
 
         // payment method info
-        List payPrefs = orh.getPaymentPreferences();
+        List<GenericValue> payPrefs = orh.getPaymentPreferences();
         String paymentMethodId = null;
         if (payPrefs != null) {
-            Iterator i = payPrefs.iterator();
-            while (i.hasNext()) {
+            for (GenericValue pref : payPrefs) {
                 // needs to be a CC or EFT account
-                GenericValue pref = (GenericValue) i.next();
                 String type = pref.getString("paymentMethodTypeId");
                 if ("CREDIT_CARD".equals(type) || "EFT_ACCOUNT".equals(type)) {
                     paymentMethodId = pref.getString("paymentMethodId");
@@ -164,14 +162,14 @@
         }
 
         // create the context for FSE
-        Map expContext = FastMap.newInstance();
+        Map<String, Object> expContext = FastMap.newInstance();
         expContext.put("orderHeader", orderHeader);
         expContext.put("orderItem", orderItem);
         expContext.put("party", party);
         expContext.put("person", person);
         expContext.put("partyGroup", partyGroup);
 
-        // expand the name field to dynamicly add information
+        // expand the name field to dynamically add information
         FlexibleStringExpander exp = FlexibleStringExpander.getInstance(finAccountName);
         finAccountName = exp.expandString(expContext);
 
@@ -181,7 +179,7 @@
         BigDecimal deposit = price.multiply(quantity).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding);
 
         // create the financial account
-        Map createCtx = FastMap.newInstance();
+        Map<String, Object> createCtx = FastMap.newInstance();
         String finAccountId;
 
         createCtx.put("finAccountTypeId", finAccountTypeId);
@@ -198,7 +196,7 @@
             createCtx.put("replenishPaymentId", paymentMethodId);
         }
 
-        Map createResp;
+        Map<String, Object> createResp;
         try {
             createResp = dispatcher.runSync("createFinAccountForStore", createCtx);
         } catch (GenericServiceException e) {
@@ -208,18 +206,18 @@
         if (ServiceUtil.isError(createResp)) {
             Debug.logFatal(ServiceUtil.getErrorMessage(createResp), module);
             return createResp;
-        } else {
-            finAccountId = (String) createResp.get("finAccountId");
         }
+        
+        finAccountId = (String) createResp.get("finAccountId");
 
         // create the owner role
-        Map roleCtx = FastMap.newInstance();
+        Map<String, Object> roleCtx = FastMap.newInstance();
         roleCtx.put("partyId", partyId);
         roleCtx.put("roleTypeId", "OWNER");
         roleCtx.put("finAccountId", finAccountId);
         roleCtx.put("userLogin", userLogin);
         roleCtx.put("fromDate", UtilDateTime.nowTimestamp());
-        Map roleResp;
+        Map<String, Object> roleResp;
         try {
             roleResp = dispatcher.runSync("createFinAccountRole", roleCtx);
         } catch (GenericServiceException e) {
@@ -232,7 +230,7 @@
         }
 
         // create the initial deposit
-        Map depositCtx = FastMap.newInstance();
+        Map<String, Object> depositCtx = FastMap.newInstance();
         depositCtx.put("finAccountId", finAccountId);
         depositCtx.put("productStoreId", productStoreId);
         depositCtx.put("currency", currency);
@@ -243,7 +241,7 @@
         depositCtx.put("reasonEnumId", "FATR_IDEPOSIT");
         depositCtx.put("userLogin", userLogin);
 
-        Map depositResp;
+        Map<String, Object> depositResp;
         try {
             depositResp = dispatcher.runSync("finAccountDeposit", depositCtx);
         } catch (GenericServiceException e) {
@@ -255,7 +253,7 @@
             return depositResp;
         }
 
-        Map result = ServiceUtil.returnSuccess();
+        Map<String, Object> result = ServiceUtil.returnSuccess();
         result.put("finAccountId", finAccountId);
         return result;
     }

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountServices.java?rev=770618&r1=770617&r2=770618&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountServices.java Fri May  1 10:28:34 2009
@@ -24,27 +24,34 @@
 import java.util.List;
 import java.util.Map;
 
-import org.ofbiz.base.util.*;
+import javolution.util.FastMap;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.GenericDelegator;
 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.EntityListIterator;
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.order.finaccount.FinAccountHelper;
 import org.ofbiz.product.store.ProductStoreWorker;
-import org.ofbiz.service.*;
-
-import javolution.util.FastMap;
+import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ModelService;
+import org.ofbiz.service.ServiceUtil;
 
 public class FinAccountServices {
 
     public static final String module = FinAccountServices.class.getName();
 
-    public static Map createAccountAndCredit(DispatchContext dctx, Map context) {
+    public static Map<String, Object> createAccountAndCredit(DispatchContext dctx, Map<String, Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
         String finAccountTypeId = (String) context.get("finAccountTypeId");
@@ -67,7 +74,7 @@
         try {
             // find the most recent (active) service credit account for the specified party
             String partyId = (String) context.get("partyId");
-            Map lookupMap = UtilMisc.toMap("finAccountTypeId", finAccountTypeId, "ownerPartyId", partyId);
+            Map<String, Object> lookupMap = UtilMisc.toMap("finAccountTypeId", finAccountTypeId, "ownerPartyId", partyId);
 
             // if a productStoreId is present, restrict the accounts returned using the store's payToPartyId
             String productStoreId = (String) context.get("productStoreId");
@@ -89,7 +96,7 @@
             if (finAccountId != null) {
                 creditAccount = delegator.findByPrimaryKey("FinAccount", UtilMisc.toMap("finAccountId", finAccountId));
             } else {
-                List creditAccounts = delegator.findByAnd("FinAccount", lookupMap, UtilMisc.toList("-fromDate"));
+                List<GenericValue> creditAccounts = delegator.findByAnd("FinAccount", lookupMap, UtilMisc.toList("-fromDate"));
                 creditAccount = EntityUtil.getFirst(EntityUtil.filterByDate(creditAccounts));
             }
 
@@ -101,13 +108,13 @@
                 }
                 // automatically set the parameters
                 ModelService createAccountService = dctx.getModelService(createAccountServiceName);
-                Map createAccountContext = createAccountService.makeValid(context, ModelService.IN_PARAM);
+                Map<String, Object> createAccountContext = createAccountService.makeValid(context, ModelService.IN_PARAM);
                 createAccountContext.put("finAccountTypeId", finAccountTypeId);
                 createAccountContext.put("finAccountName", accountName);
                 createAccountContext.put("ownerPartyId", partyId);
                 createAccountContext.put("userLogin", userLogin);
 
-                Map createAccountResult = dispatcher.runSync(createAccountServiceName, createAccountContext);
+                Map<String, Object> createAccountResult = dispatcher.runSync(createAccountServiceName, createAccountContext);
                 if (ServiceUtil.isError(createAccountResult) || ServiceUtil.isFailure(createAccountResult)) {
                     return createAccountResult;
                 }
@@ -118,13 +125,13 @@
                         creditAccount = delegator.findByPrimaryKey("FinAccount", UtilMisc.toMap("finAccountId", creditAccountId));
 
                         // create the owner role
-                        Map roleCtx = FastMap.newInstance();
+                        Map<String, Object> roleCtx = FastMap.newInstance();
                         roleCtx.put("partyId", partyId);
                         roleCtx.put("roleTypeId", "OWNER");
                         roleCtx.put("finAccountId", creditAccountId);
                         roleCtx.put("userLogin", userLogin);
                         roleCtx.put("fromDate", UtilDateTime.nowTimestamp());
-                        Map roleResp;
+                        Map<String, Object> roleResp;
                         try {
                             roleResp = dispatcher.runSync("createFinAccountRole", roleCtx);
                         } catch (GenericServiceException e) {
@@ -142,7 +149,7 @@
             }
 
             // create the credit transaction
-            Map transactionMap = FastMap.newInstance();
+            Map<String, Object> transactionMap = FastMap.newInstance();
             transactionMap.put("finAccountTransTypeId", "ADJUSTMENT");
             transactionMap.put("finAccountId", creditAccount.getString("finAccountId"));
             transactionMap.put("partyId", partyId);
@@ -151,7 +158,7 @@
             transactionMap.put("comments", context.get("comments"));
             transactionMap.put("userLogin", userLogin);
 
-            Map creditTransResult = dispatcher.runSync("createFinAccountTrans", transactionMap);
+            Map<String, Object> creditTransResult = dispatcher.runSync("createFinAccountTrans", transactionMap);
             if (ServiceUtil.isError(creditTransResult) || ServiceUtil.isFailure(creditTransResult)) {
                 return creditTransResult;
             }
@@ -161,12 +168,12 @@
             return ServiceUtil.returnError(gse.getMessage());
         }
 
-        Map result = ServiceUtil.returnSuccess();
+        Map<String, Object> result = ServiceUtil.returnSuccess();
         result.put("finAccountId", finAccountId);
         return result;
     }
 
-    public static Map createFinAccountForStore(DispatchContext dctx, Map context) {
+    public static Map<String, Object> createFinAccountForStore(DispatchContext dctx, Map<String, Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -187,7 +194,7 @@
 
             // automatically set the parameters for the create fin account service
             ModelService createService = dctx.getModelService("createFinAccount");
-            Map inContext = createService.makeValid(context, ModelService.IN_PARAM);
+            Map<String, Object> inContext = createService.makeValid(context, ModelService.IN_PARAM);
             Timestamp now = UtilDateTime.nowTimestamp();
 
             // now use our values
@@ -209,16 +216,15 @@
             String payToPartyId = ProductStoreWorker.getProductStorePayToPartyId(productStoreId, delegator);
             inContext.put("organizationPartyId", payToPartyId);
 
-            Map createResult = dispatcher.runSync("createFinAccount", inContext);
+            Map<String, Object> createResult = dispatcher.runSync("createFinAccount", inContext);
 
             if (ServiceUtil.isError(createResult)) {
                 return createResult;
-            } else {
-                Map result = ServiceUtil.returnSuccess();
-                result.put("finAccountId", createResult.get("finAccountId"));
-                result.put("finAccountCode", finAccountCode);
-                return result;
             }
+            Map<String, Object> result = ServiceUtil.returnSuccess();
+            result.put("finAccountId", createResult.get("finAccountId"));
+            result.put("finAccountCode", finAccountCode);
+            return result;
         } catch (GenericEntityException ex) {
             return ServiceUtil.returnError(ex.getMessage());
         } catch (GenericServiceException ex) {
@@ -226,7 +232,7 @@
         }
     }
 
-    public static Map checkFinAccountBalance(DispatchContext dctx, Map context) {
+    public static Map<String, Object> checkFinAccountBalance(DispatchContext dctx, Map<String, Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         String finAccountId = (String) context.get("finAccountId");
         String finAccountCode = (String) context.get("finAccountCode");
@@ -264,14 +270,14 @@
         String statusId = finAccount.getString("statusId");
         Debug.log("FinAccount Balance [" + balance + "] Available [" + availableBalance + "] - Status: " + statusId, module);
 
-        Map result = ServiceUtil.returnSuccess();
+        Map<String, Object> result = ServiceUtil.returnSuccess();
         result.put("availableBalance", availableBalance);
         result.put("balance", balance);
         result.put("statusId", statusId);
         return result;
     }
 
-    public static Map checkFinAccountStatus(DispatchContext dctx, Map context) {
+    public static Map<String, Object> checkFinAccountStatus(DispatchContext dctx, Map<String, Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         String finAccountId = (String) context.get("finAccountId");
 
@@ -314,13 +320,13 @@
         return ServiceUtil.returnSuccess();
     }
 
-    public static Map refundFinAccount(DispatchContext dctx, Map context) {
+    public static Map<String, Object> refundFinAccount(DispatchContext dctx, Map<String, Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericDelegator delegator = dctx.getDelegator();
 
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         String finAccountId = (String) context.get("finAccountId");
-        Map result = null;
+        Map<String, Object> result = null;
 
         GenericValue finAccount;
         try {
@@ -349,7 +355,7 @@
                 BigDecimal remainingBalance = new BigDecimal(actualBalance.toString());
                 BigDecimal refundAmount = BigDecimal.ZERO;
 
-                List exprs = UtilMisc.toList(EntityCondition.makeCondition("finAccountTransTypeId", EntityOperator.EQUALS, "DEPOSIT"),
+                List<EntityExpr> exprs = UtilMisc.toList(EntityCondition.makeCondition("finAccountTransTypeId", EntityOperator.EQUALS, "DEPOSIT"),
                         EntityCondition.makeCondition("finAccountId", EntityOperator.EQUALS, finAccountId));
                 EntityCondition condition = EntityCondition.makeCondition(exprs, EntityOperator.AND);
 
@@ -358,7 +364,7 @@
                     eli = delegator.find("FinAccountTrans", condition, null, null, UtilMisc.toList("-transactionDate"), null);
 
                     GenericValue trans;
-                    while (remainingBalance.compareTo(FinAccountHelper.ZERO) == 1 && (trans = (GenericValue) eli.next()) != null) {
+                    while (remainingBalance.compareTo(FinAccountHelper.ZERO) < 0 && (trans = eli.next()) != null) {
                         String orderId = trans.getString("orderId");
                         String orderItemSeqId = trans.getString("orderItemSeqId");
 
@@ -370,7 +376,7 @@
                             if (!"ITEM_CANCELLED".equals(orderItem.getString("statusId"))) {
 
                                 // make sure the item hasn't already been returned
-                                List returnItems = orderItem.getRelated("ReturnItem");
+                                List<GenericValue> returnItems = orderItem.getRelated("ReturnItem");
                                 if (returnItems == null || returnItems.size() == 0) {
                                     BigDecimal txAmt = trans.getBigDecimal("amount");
                                     BigDecimal refAmt = txAmt;
@@ -381,15 +387,15 @@
                                     refundAmount = refundAmount.add(refAmt);
 
                                     // create the return header
-                                    Map rhCtx = UtilMisc.toMap("returnHeaderTypeId", "CUSTOMER_RETURN", "fromPartyId", finAccount.getString("ownerPartyId"), "toPartyId", productStore.getString("payToPartyId"), "userLogin", userLogin);
-                                    Map rhResp = dispatcher.runSync("createReturnHeader", rhCtx);
+                                    Map<String, Object> rhCtx = UtilMisc.toMap("returnHeaderTypeId", "CUSTOMER_RETURN", "fromPartyId", finAccount.getString("ownerPartyId"), "toPartyId", productStore.getString("payToPartyId"), "userLogin", userLogin);
+                                    Map<String, Object> rhResp = dispatcher.runSync("createReturnHeader", rhCtx);
                                     if (ServiceUtil.isError(rhResp)) {
                                         throw new GeneralException(ServiceUtil.getErrorMessage(rhResp));
                                     }
                                     String returnId = (String) rhResp.get("returnId");
 
                                     // create the return item
-                                    Map returnItemCtx = FastMap.newInstance();
+                                    Map<String, Object> returnItemCtx = FastMap.newInstance();
                                     returnItemCtx.put("returnId", returnId);
                                     returnItemCtx.put("orderId", orderId);
                                     returnItemCtx.put("description", orderItem.getString("itemDescription"));
@@ -402,22 +408,22 @@
                                     returnItemCtx.put("returnItemTypeId", "RET_NPROD_ITEM");
                                     returnItemCtx.put("userLogin", userLogin);
 
-                                    Map retItResp = dispatcher.runSync("createReturnItem", returnItemCtx);
+                                    Map<String, Object> retItResp = dispatcher.runSync("createReturnItem", returnItemCtx);
                                     if (ServiceUtil.isError(retItResp)) {
                                         throw new GeneralException(ServiceUtil.getErrorMessage(retItResp));
                                     }
                                     String returnItemSeqId = (String) retItResp.get("returnItemSeqId");
 
                                     // approve the return
-                                    Map appRet = UtilMisc.toMap("statusId", "RETURN_ACCEPTED", "returnId", returnId, "userLogin", userLogin);
-                                    Map appResp = dispatcher.runSync("updateReturnHeader", appRet);
+                                    Map<String, Object> appRet = UtilMisc.toMap("statusId", "RETURN_ACCEPTED", "returnId", returnId, "userLogin", userLogin);
+                                    Map<String, Object> appResp = dispatcher.runSync("updateReturnHeader", appRet);
                                     if (ServiceUtil.isError(appResp)) {
                                         throw new GeneralException(ServiceUtil.getErrorMessage(appResp));
                                     }
 
                                     // "receive" the return - should trigger the refund
-                                    Map recRet = UtilMisc.toMap("statusId", "RETURN_RECEIVED", "returnId", returnId, "userLogin", userLogin);
-                                    Map recResp = dispatcher.runSync("updateReturnHeader", recRet);
+                                    Map<String, Object> recRet = UtilMisc.toMap("statusId", "RETURN_RECEIVED", "returnId", returnId, "userLogin", userLogin);
+                                    Map<String, Object> recResp = dispatcher.runSync("updateReturnHeader", recRet);
                                     if (ServiceUtil.isError(recResp)) {
                                         throw new GeneralException(ServiceUtil.getErrorMessage(recResp));
                                     }
@@ -432,7 +438,7 @@
                                     String paymentId = response.getString("paymentId");
 
                                     // create the adjustment transaction
-                                    Map txCtx = FastMap.newInstance();
+                                    Map<String, Object> txCtx = FastMap.newInstance();
                                     txCtx.put("finAccountTransTypeId", "ADJUSTMENT");
                                     txCtx.put("finAccountId", finAccountId);
                                     txCtx.put("orderId", orderId);
@@ -442,7 +448,7 @@
                                     txCtx.put("partyId", finAccount.getString("ownerPartyId"));
                                     txCtx.put("userLogin", userLogin);
 
-                                    Map txResp = dispatcher.runSync("createFinAccountTrans", txCtx);
+                                    Map<String, Object> txResp = dispatcher.runSync("createFinAccountTrans", txCtx);
                                     if (ServiceUtil.isError(txResp)) {
                                         throw new GeneralException(ServiceUtil.getErrorMessage(txResp));
                                     }

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=770618&r1=770617&r2=770618&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 Fri May  1 10:28:34 2009
@@ -435,7 +435,7 @@
                     Map createInvoiceItemContext = FastMap.newInstance();
                     createInvoiceItemContext.put("invoiceId", invoiceId);
                     createInvoiceItemContext.put("invoiceItemSeqId", invoiceItemSeqId);
-                    createInvoiceItemContext.put("invoiceItemTypeId", getInvoiceItemType(delegator, (orderItem == null ? null : orderItem.getString("orderItemTypeId")), (product == null ? null : product.getString("productTypeId")), invoiceType, "INV_FPROD_ITEM"));
+                    createInvoiceItemContext.put("invoiceItemTypeId", getInvoiceItemType(delegator, (orderItem.getString("orderItemTypeId")), (product == null ? null : product.getString("productTypeId")), invoiceType, "INV_FPROD_ITEM"));
                     createInvoiceItemContext.put("description", orderItem.get("itemDescription"));
                     createInvoiceItemContext.put("quantity", billingQuantity);
                     createInvoiceItemContext.put("amount", billingAmount);

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=770618&r1=770617&r2=770618&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 Fri May  1 10:28:34 2009
@@ -287,7 +287,7 @@
 
     public static GenericValue getInvoiceAddressByType(GenericValue invoice, String contactMechPurposeTypeId) {
         GenericDelegator delegator = invoice.getDelegator();
-        List locations = null;
+        List<GenericValue> locations = null;
         // first try InvoiceContactMech to see if we can find the address needed
         try {
             locations = invoice.getRelated("InvoiceContactMech", UtilMisc.toMap("contactMechPurposeTypeId", contactMechPurposeTypeId), null);
@@ -324,12 +324,12 @@
         GenericValue contactMech = null;
         if (UtilValidate.isNotEmpty(locations)) {
             try {
-                contactMech = ((GenericValue) locations.get(0)).getRelatedOne("ContactMech");
+                contactMech = locations.get(0).getRelatedOne("ContactMech");
             } catch (GenericEntityException e) {
-                Debug.logError(e, "Trouble getting Contact for contactMechId: " + contactMech.getString("contactMechId"), module);
+                Debug.logError(e, "Trouble getting Contact for contactMechId: " + locations.get(0).getString("contactMechId"), module);
             }
 
-            if (contactMech.getString("contactMechTypeId").equals("POSTAL_ADDRESS"))    {
+            if (contactMech != null && contactMech.getString("contactMechTypeId").equals("POSTAL_ADDRESS"))    {
                 try {
                     postalAddress = contactMech.getRelatedOne("PostalAddress");
                     return postalAddress;
@@ -532,9 +532,9 @@
                 party  = delegator.findByPrimaryKey("PartyAcctgPreference", UtilMisc.toMap("partyId", invoice.getString("partyId")));
             }
             if (UtilValidate.isNotEmpty(party) && party.getString("baseCurrencyUomId") != null) {
-                otherCurrencyUomId = new String(party.getString("baseCurrencyUomId"));
+                otherCurrencyUomId = party.getString("baseCurrencyUomId");
             } else {
-                otherCurrencyUomId = new String(UtilProperties.getPropertyValue("general", "currency.uom.id.default"));
+                otherCurrencyUomId = UtilProperties.getPropertyValue("general", "currency.uom.id.default");
             }
             if (otherCurrencyUomId == null) {
                 otherCurrencyUomId = "USD"; // final default

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AuthorizeResponse.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AuthorizeResponse.java?rev=770618&r1=770617&r2=770618&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AuthorizeResponse.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AuthorizeResponse.java Fri May  1 10:28:34 2009
@@ -24,7 +24,7 @@
 public class AuthorizeResponse {
 
     private String rawResp = null;
-    private List response = new ArrayList();
+    private List<String> response = new ArrayList<String>();
     private String respCode = "";
     private String reasonCode = "";
     private String reasonText = "";
@@ -93,7 +93,7 @@
     }
 
     private void setApproval() {
-        String rc = (String)response.get(RESPONSE_CODE);
+        String rc = response.get(RESPONSE_CODE);
 
         if (rc.equals("1")) {
             this.respCode = APPROVED;
@@ -107,8 +107,8 @@
             this.respCode = ERROR;
         }
 
-        this.reasonCode = (String)response.get(RESPONSE_REASON_CODE);
-        this.reasonText = (String)response.get(RESPONSE_REASON_TEXT);
+        this.reasonCode = response.get(RESPONSE_REASON_CODE);
+        this.reasonText = response.get(RESPONSE_REASON_TEXT);
 
     }
 
@@ -144,18 +144,16 @@
         if (posNum < 1 || posNum > maxPos) {
             return "unknown_field";
         }
-        else {
-            return (String)response.get(posNum);
-        }
+        return response.get(posNum);
     }
 
     public String getRawResponse() {
         return this.rawResp;
     }
 
-    private List splitResp(String r, String delim) {
+    private List<String> splitResp(String r, String delim) {
         int s1=0, s2=-1;
-        List out = new ArrayList(40);
+        List<String> out = new ArrayList<String>(40);
         out.add("empty");
         while (true) {
             s2 = r.indexOf(delim, s1);
@@ -175,6 +173,7 @@
         return out;
     }
 
+    @Override
     public String toString() {
         return response.toString();
     }