Author: jleroux
Date: Thu Nov 19 17:44:00 2009
New Revision: 882217
URL: http://svn.apache.org/viewvc?rev=882217&view=rev
Log:
Complete 882210, contains InvoiceWorker.java (got a conflict) and some other
changes, mostly enhanced for loops instead of iterators with while loops
Modified:
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/tax/TaxAuthorityServices.java
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/gosoftware/RitaApi.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/invoice/InvoiceWorker.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java?rev=882217&r1=882216&r2=882217&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 17:44:00 2009
@@ -106,12 +106,11 @@
}
/** 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 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"));
+ 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"));
}
return typeIds;
}
@@ -122,32 +121,27 @@
if (invoice == null)
throw new IllegalArgumentException("The invoiceId passed does not
match an existing invoice");
- List invoiceTaxItems = null;
+ List<GenericValue> invoiceTaxItems = null;
try {
Delegator delegator = invoice.getDelegator();
- EntityConditionList condition =
EntityCondition.makeCondition(UtilMisc.toList(
- EntityCondition.makeCondition("invoiceId",
invoice.getString("invoiceId")),
+ EntityConditionList<EntityCondition> condition =
EntityCondition.makeCondition(UtilMisc.toList(
+
(EntityCondition)EntityCondition.makeCondition("invoiceId",
invoice.get("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);
}
- 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);
- }
+ 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);
}
return invoiceTaxTotal.setScale(decimals, rounding);
-
}
public static BigDecimal getInvoiceNoTaxTotal(GenericValue invoice) {
@@ -175,11 +169,10 @@
public static BigDecimal getInvoiceTotal(GenericValue invoice, Boolean
actualCurrency) {
BigDecimal invoiceTotal = ZERO;
BigDecimal invoiceTaxTotal = ZERO;
- Map invoiceTaxByTaxAuthGeoAndPartyResult =
getInvoiceTaxByTaxAuthGeoAndParty(invoice);
- List taxByTaxAuthGeoAndPartyList = (List)
invoiceTaxByTaxAuthGeoAndPartyResult.get("taxByTaxAuthGeoAndPartyList");
+ Map<String, Object> invoiceTaxByTaxAuthGeoAndPartyResult =
getInvoiceTaxByTaxAuthGeoAndParty(invoice);
invoiceTaxTotal = (BigDecimal)
invoiceTaxByTaxAuthGeoAndPartyResult.get("taxGrandTotal");
- List invoiceItems = null;
+ List<GenericValue> invoiceItems = null;
try {
invoiceItems = invoice.getRelated("InvoiceItem");
if ("SALES_INVOICE".equals(invoice.getString("invoiceTypeId"))) {
@@ -197,9 +190,9 @@
Debug.logError(e, "Trouble getting InvoiceItem list", module);
}
if (UtilValidate.isNotEmpty(invoiceItems)) {
- Iterator invoiceItemsIter = invoiceItems.iterator();
+ Iterator<GenericValue> invoiceItemsIter = invoiceItems.iterator();
while (invoiceItemsIter.hasNext()) {
- GenericValue invoiceItem = (GenericValue)
invoiceItemsIter.next();
+ GenericValue invoiceItem = invoiceItemsIter.next();
BigDecimal amount = invoiceItem.getBigDecimal("amount");
BigDecimal quantity = invoiceItem.getBigDecimal("quantity");
if (amount == null)
@@ -232,7 +225,7 @@
}
// remaining code is the old method, which we leave here for
compatibility purposes
- List billToRoles = null;
+ List<GenericValue> billToRoles = null;
try {
billToRoles = invoice.getRelated("InvoiceRole",
UtilMisc.toMap("roleTypeId", "BILL_TO_CUSTOMER"),
UtilMisc.toList("-datetimePerformed"));
@@ -276,7 +269,7 @@
}
// remaining code is the old method, which we leave here for
compatibility purposes
- List sendFromRoles = null;
+ List<GenericValue> sendFromRoles = null;
try {
sendFromRoles = invoice.getRelated("InvoiceRole",
UtilMisc.toMap("roleTypeId", "BILL_FROM_VENDOR"),
UtilMisc.toList("-datetimePerformed"));
@@ -372,39 +365,6 @@
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
@@ -457,13 +417,13 @@
}
BigDecimal invoiceApplied = ZERO;
- List paymentApplications = null;
+ List<GenericValue> paymentApplications = null;
// lookup payment applications which took place before the
asOfDateTime for this invoice
- EntityConditionList dateCondition =
EntityCondition.makeCondition(UtilMisc.toList(
- EntityCondition.makeCondition("effectiveDate",
EntityOperator.EQUALS, null),
+ EntityConditionList<EntityCondition> dateCondition =
EntityCondition.makeCondition(UtilMisc.toList(
+
(EntityCondition)EntityCondition.makeCondition("effectiveDate",
EntityOperator.EQUALS, null),
EntityCondition.makeCondition("effectiveDate",
EntityOperator.LESS_THAN_EQUAL_TO, asOfDateTime)), EntityOperator.OR);
- EntityConditionList conditions =
EntityCondition.makeCondition(UtilMisc.toList(
+ EntityConditionList<EntityCondition> conditions =
EntityCondition.makeCondition(UtilMisc.toList(
dateCondition,
EntityCondition.makeCondition("invoiceId",
EntityOperator.EQUALS, invoiceId)),
EntityOperator.AND);
@@ -474,9 +434,9 @@
Debug.logError(e, "Trouble getting paymentApplicationlist",
module);
}
if (UtilValidate.isNotEmpty(paymentApplications)) {
- Iterator p = paymentApplications.iterator();
+ Iterator<GenericValue> p = paymentApplications.iterator();
while (p.hasNext()) {
- GenericValue paymentApplication = (GenericValue) p.next();
+ GenericValue paymentApplication = p.next();
invoiceApplied =
invoiceApplied.add(paymentApplication.getBigDecimal("amountApplied")).setScale(decimals,rounding);
}
}
@@ -537,16 +497,16 @@
*/
public static BigDecimal getInvoiceItemApplied(GenericValue invoiceItem) {
BigDecimal invoiceItemApplied = ZERO;
- List paymentApplications = null;
+ List<GenericValue> paymentApplications = null;
try {
paymentApplications = invoiceItem.getRelated("PaymentApplication");
} catch (GenericEntityException e) {
Debug.logError(e, "Trouble getting paymentApplicationlist",
module);
}
if (UtilValidate.isNotEmpty(paymentApplications)) {
- Iterator p = paymentApplications.iterator();
+ Iterator<GenericValue> p = paymentApplications.iterator();
while (p.hasNext()) {
- GenericValue paymentApplication = (GenericValue) p.next();
+ GenericValue paymentApplication = p.next();
invoiceItemApplied =
invoiceItemApplied.add(paymentApplication.getBigDecimal("amountApplied")).setScale(decimals,rounding);
}
}
@@ -579,17 +539,17 @@
try {
// check if the invoice is posted and get the conversion from there
- List acctgTransEntries = invoice.getRelated("AcctgTrans");
+ List<GenericValue> 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 paymentAppls = invoice.getRelated("PaymentApplication");
- Iterator ii = paymentAppls.iterator();
+ List<GenericValue> paymentAppls =
invoice.getRelated("PaymentApplication");
+ Iterator<GenericValue> ii = paymentAppls.iterator();
while (ii.hasNext()) {
- GenericValue paymentAppl = (GenericValue) ii.next();
+ GenericValue paymentAppl = ii.next();
GenericValue payment =
paymentAppl.getRelatedOne("Payment");
if
(UtilValidate.isNotEmpty(payment.getBigDecimal("actualCurrencyAmount"))) {
if (UtilValidate.isEmpty(conversionRate)) {
@@ -602,9 +562,9 @@
}
// use the dated conversion entity
if (UtilValidate.isEmpty(conversionRate)) {
- List rates =
EntityUtil.filterByDate(delegator.findByAnd("UomConversionDated",
UtilMisc.toMap("uomIdTo", invoice.getString("currencyUomId"), "uomId",
otherCurrencyUomId)), invoice.getTimestamp("invoiceDate"));
+ List<GenericValue> 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(((GenericValue)
rates.get(0)).getBigDecimal("conversionFactor"), new
MathContext(100)).setScale(decimals,rounding);
+ conversionRate =
(BigDecimal.ONE).divide(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=882217&r1=882216&r2=882217&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 17:44:00 2009
@@ -18,23 +18,21 @@
*******************************************************************************/
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;
@@ -44,7 +42,6 @@
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;
@@ -66,15 +63,15 @@
if (decimals != -1) ZERO = ZERO.setScale(decimals);
}
- public static List makePartyBillingAccountList(GenericValue userLogin,
String currencyUomId, String partyId, Delegator delegator, LocalDispatcher
dispatcher) throws GeneralException {
- List billingAccountList = FastList.newInstance();
+ 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();
- Map agentResult = dispatcher.runSync("getRelatedParties",
UtilMisc.<String, Object>toMap("userLogin", userLogin, "partyIdFrom", partyId,
+ Map<String, Object> 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 relatedPartyIdList = (List) agentResult.get("relatedPartyIdList");
+ List<String> relatedPartyIdList =
UtilGenerics.cast(agentResult.get("relatedPartyIdList"));
EntityCondition barFindCond =
EntityCondition.makeCondition(UtilMisc.toList(
EntityCondition.makeCondition("partyId", EntityOperator.IN,
relatedPartyIdList),
@@ -84,9 +81,7 @@
if (billingAccountRoleList.size() > 0) {
BigDecimal totalAvailable = BigDecimal.ZERO;
- Iterator billingAcctIter = billingAccountRoleList.iterator();
- while (billingAcctIter.hasNext()) {
- GenericValue billingAccountRole = (GenericValue)
billingAcctIter.next();
+ for (GenericValue billingAccountRole : billingAccountRoleList) {
GenericValue billingAccountVO =
billingAccountRole.getRelatedOne("BillingAccount");
// skip accounts that have thruDate < nowTimestamp
@@ -96,7 +91,7 @@
if
(currencyUomId.equals(billingAccountVO.getString("accountCurrencyUomId"))) {
BigDecimal accountBalance =
BillingAccountWorker.getBillingAccountBalance(billingAccountVO);
- Map billingAccount = new HashMap(billingAccountVO);
+ Map<String, BigDecimal> billingAccount = new
HashMap<String,
BigDecimal>(UtilGenerics.<Map<String,BigDecimal>>cast(billingAccountVO));
BigDecimal accountLimit =
getAccountLimit(billingAccountVO);
billingAccount.put("accountBalance", accountBalance);
@@ -147,24 +142,22 @@
BigDecimal accountLimit = getAccountLimit(billingAccount);
balance = balance.add(accountLimit);
// pending (not cancelled, rejected, or received) order payments
- EntityConditionList whereConditions =
EntityCondition.makeCondition(UtilMisc.toList(
+ EntityConditionList<EntityExpr> 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 orderPaymentPreferenceSums =
delegator.findList("OrderPurchasePaymentSummary", whereConditions,
UtilMisc.toSet("maxAmount"), null, null, false);
- for (Iterator oppsi = orderPaymentPreferenceSums.iterator();
oppsi.hasNext();) {
- GenericValue orderPaymentPreferenceSum = (GenericValue)
oppsi.next();
+ List<GenericValue> orderPaymentPreferenceSums =
delegator.findList("OrderPurchasePaymentSummary", whereConditions,
UtilMisc.toSet("maxAmount"), null, null, false);
+ for (GenericValue orderPaymentPreferenceSum :
orderPaymentPreferenceSums) {
BigDecimal maxAmount =
orderPaymentPreferenceSum.getBigDecimal("maxAmount");
balance = maxAmount != null ? balance.subtract(maxAmount) :
balance;
}
- List paymentAppls = delegator.findByAnd("PaymentApplication",
UtilMisc.toMap("billingAccountId", billingAccountId));
+ List<GenericValue> paymentAppls =
delegator.findByAnd("PaymentApplication", UtilMisc.toMap("billingAccountId",
billingAccountId));
// TODO: cancelled payments?
- for (Iterator pAi = paymentAppls.iterator(); pAi.hasNext();) {
- GenericValue paymentAppl = (GenericValue) pAi.next();
+ for (GenericValue paymentAppl : paymentAppls) {
if (paymentAppl.getString("invoiceId") == null) {
BigDecimal amountApplied =
paymentAppl.getBigDecimal("amountApplied");
balance = balance.add(amountApplied);
@@ -183,10 +176,7 @@
// now the amounts of all the pending orders (not cancelled, rejected
or completed)
List orderHeaders = getBillingAccountOpenOrders(delegator,
billingAccountId);
- if (orderHeaders != null) {
- Iterator ohi = orderHeaders.iterator();
- while (ohi.hasNext()) {
- GenericValue orderHeader = (GenericValue) ohi.next();
+ for (GenericValue orderHeader : orderHeaders) {
OrderReadHelper orh = new OrderReadHelper(orderHeader);
balance = balance.add(orh.getOrderGrandTotal());
}
@@ -208,7 +198,7 @@
/**
* Returns list of orders which are currently open against a billing
account
*/
- public static List getBillingAccountOpenOrders(Delegator delegator, String
billingAccountId) throws GenericEntityException {
+ public static List<GenericValue> 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"),
@@ -253,9 +243,8 @@
BigDecimal balance = ZERO;
// search through all PaymentApplications and add the amount that was
applied to invoice and subtract the amount applied from payments
- List paymentAppls = delegator.findByAnd("PaymentApplication",
UtilMisc.toMap("billingAccountId", billingAccountId));
- for (Iterator pAi = paymentAppls.iterator(); pAi.hasNext();) {
- GenericValue paymentAppl = (GenericValue) pAi.next();
+ List<GenericValue> paymentAppls =
delegator.findByAnd("PaymentApplication", UtilMisc.toMap("billingAccountId",
billingAccountId));
+ for (GenericValue paymentAppl : paymentAppls) {
BigDecimal amountApplied =
paymentAppl.getBigDecimal("amountApplied");
GenericValue invoice = paymentAppl.getRelatedOne("Invoice");
if (invoice != null) {
@@ -285,10 +274,10 @@
return accountLimit.subtract(netBalance).setScale(decimals, rounding);
}
- public static Map calcBillingAccountBalance(DispatchContext dctx, Map
context) {
+ public static Map<String, Object>
calcBillingAccountBalance(DispatchContext dctx, Map<String, Object> context) {
Delegator delegator = dctx.getDelegator();
String billingAccountId = (String) context.get("billingAccountId");
- Map result = ServiceUtil.returnSuccess();
+ Map<String, Object> result = ServiceUtil.returnSuccess();
try {
GenericValue billingAccount =
delegator.findByPrimaryKey("BillingAccount", UtilMisc.toMap("billingAccountId",
billingAccountId));
@@ -309,9 +298,9 @@
}
}
- 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"));
+ 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"));
}
}
}
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=882217&r1=882216&r2=882217&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 17:44:00 2009
@@ -21,7 +21,6 @@
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;
@@ -733,9 +732,7 @@
// make a map of answer info
Map<String, Object> answerMap = new HashMap<String, Object>();
if (responseAnswers != null) {
- Iterator<GenericValue> rai = responseAnswers.iterator();
- while (rai.hasNext()) {
- GenericValue answer = rai.next();
+ for (GenericValue answer : responseAnswers) {
GenericValue question = null;
try {
question = answer.getRelatedOne("SurveyQuestion");
@@ -956,9 +953,7 @@
// make a map of answer info
Map<String, Object> answerMap = new HashMap<String, Object>();
if (responseAnswers != null) {
- Iterator<GenericValue> rai = responseAnswers.iterator();
- while (rai.hasNext()) {
- GenericValue answer = rai.next();
+ for (GenericValue answer : responseAnswers) {
GenericValue question = null;
try {
question = answer.getRelatedOne("SurveyQuestion");
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=882217&r1=882216&r2=882217&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 17:44:00 2009
@@ -21,7 +21,6 @@
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;
@@ -105,9 +104,7 @@
}
// add up amounts from adjustments (amount OR exemptAmount,
sourcePercentage)
- Iterator<GenericValue> taxAdustmentIter =
taxAdustmentList.iterator();
- while (taxAdustmentIter.hasNext()) {
- GenericValue taxAdjustment = taxAdustmentIter.next();
+ for (GenericValue taxAdjustment : taxAdustmentList) {
taxPercentage =
taxPercentage.add(taxAdjustment.getBigDecimal("sourcePercentage"));
BigDecimal adjAmount =
taxAdjustment.getBigDecimal("amount");
taxTotal = taxTotal.add(adjAmount);
@@ -273,9 +270,7 @@
EntityOperator.AND,
EntityCondition.makeCondition("taxAuthGeoId",
EntityOperator.EQUALS, "_NA_")));
- Iterator<GenericValue> taxAuthorityIter = taxAuthoritySet.iterator();
- while (taxAuthorityIter.hasNext()) {
- GenericValue taxAuthority = taxAuthorityIter.next();
+ for (GenericValue taxAuthority : taxAuthoritySet) {
EntityCondition taxAuthCond = EntityCondition.makeCondition(
EntityCondition.makeCondition("taxAuthPartyId",
EntityOperator.EQUALS, taxAuthority.getString("taxAuthPartyId")),
EntityOperator.AND,
@@ -292,9 +287,7 @@
Set<String> productCategoryIdSet = FastSet.newInstance();
List<GenericValue> pcmList =
delegator.findByAndCache("ProductCategoryMember", UtilMisc.toMap("productId",
product.get("productId")));
pcmList = EntityUtil.filterByDate(pcmList, true);
- Iterator<GenericValue> pcmIter = pcmList.iterator();
- while (pcmIter.hasNext()) {
- GenericValue pcm = pcmIter.next();
+ for (GenericValue pcm : pcmList) {
productCategoryIdSet.add((String)
pcm.get("productCategoryId"));
}
@@ -329,9 +322,7 @@
}
// find the right entry(s) based on purchase amount
- Iterator<GenericValue> flIt = filteredList.iterator();
- while (flIt.hasNext()) {
- GenericValue taxAuthorityRateProduct = flIt.next();
+ for(GenericValue taxAuthorityRateProduct : filteredList) {
BigDecimal taxRate =
taxAuthorityRateProduct.get("taxPercentage") != null ?
taxAuthorityRateProduct.getBigDecimal("taxPercentage") : ZERO_BASE;
BigDecimal taxable = ZERO_BASE;
@@ -384,9 +375,7 @@
Set<String> billToPartyIdSet = FastSet.newInstance();
billToPartyIdSet.add(billToPartyId);
List<GenericValue> partyRelationshipList =
EntityUtil.filterByDate(delegator.findByAndCache("PartyRelationship",
UtilMisc.toMap("partyIdTo", billToPartyId, "partyRelationshipTypeId",
"GROUP_ROLLUP")), true);
- Iterator<GenericValue> partyRelationshipIter =
partyRelationshipList.iterator();
- while (partyRelationshipIter.hasNext()) {
- GenericValue partyRelationship =
partyRelationshipIter.next();
+ for(GenericValue partyRelationship :
partyRelationshipList) {
billToPartyIdSet.add((String)
partyRelationship.get("partyIdFrom"));
}
handlePartyTaxExempt(adjValue, billToPartyIdSet,
taxAuthGeoId, taxAuthPartyId, taxAmount, nowTimestamp, delegator);
Modified:
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java?rev=882217&r1=882216&r2=882217&view=diff
==============================================================================
---
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java
(original)
+++
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java
Thu Nov 19 17:44:00 2009
@@ -19,7 +19,6 @@
package org.ofbiz.accounting.thirdparty.gosoftware;
import java.io.IOException;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -151,9 +150,7 @@
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
- Iterator<Map.Entry<String, String>> i = document.entrySet().iterator();
- while (i.hasNext()) {
- Map.Entry<String, String> entry = i.next();
+ for (Map.Entry<String, String> entry : document.entrySet()) {
String name = (String) entry.getKey();
String value = (String) entry.getValue();
buf.append(name);
Modified:
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java?rev=882217&r1=882216&r2=882217&view=diff
==============================================================================
---
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java
(original)
+++
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java
Thu Nov 19 17:44:00 2009
@@ -20,11 +20,11 @@
import java.math.BigDecimal;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
+
import javax.transaction.xa.XAException;
import org.ofbiz.base.util.Debug;
@@ -1094,9 +1094,7 @@
// make a map of answer info
Map<String, Object> answerMap = new HashMap<String, Object>();
if (responseAnswers != null) {
- Iterator<GenericValue> rai = responseAnswers.iterator();
- while (rai.hasNext()) {
- GenericValue answer = rai.next();
+ for(GenericValue answer : responseAnswers) {
GenericValue question = null;
try {
question = answer.getRelatedOne("SurveyQuestion");
Modified:
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java?rev=882217&r1=882216&r2=882217&view=diff
==============================================================================
---
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java
(original)
+++
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java
Thu Nov 19 17:44:00 2009
@@ -20,9 +20,10 @@
package org.ofbiz.accounting.util;
import java.math.BigDecimal;
-import java.util.Iterator;
import java.util.List;
+import javolution.util.FastList;
+
import org.ofbiz.accounting.AccountingException;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilMisc;
@@ -30,8 +31,6 @@
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
-import javolution.util.FastList;
-
public class UtilAccounting {
@@ -125,9 +124,7 @@
private static void getGlAccountClassChildren(GenericValue glAccountClass,
List<String> glAccountClassIds) throws GenericEntityException {
glAccountClassIds.add(glAccountClass.getString("glAccountClassId"));
List<GenericValue> glAccountClassChildren =
glAccountClass.getRelatedCache("ChildGlAccountClass");
- Iterator<GenericValue> glAccountClassChildrenIt =
glAccountClassChildren.iterator();
- while (glAccountClassChildrenIt.hasNext()) {
- GenericValue glAccountClassChild = glAccountClassChildrenIt.next();
+ for(GenericValue glAccountClassChild : glAccountClassChildren) {
getGlAccountClassChildren(glAccountClassChild, glAccountClassIds);
}
}