You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by sa...@apache.org on 2011/09/14 08:41:51 UTC
svn commit: r1170447 -
/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
Author: sascharodekamp
Date: Wed Sep 14 06:41:51 2011
New Revision: 1170447
URL: http://svn.apache.org/viewvc?rev=1170447&view=rev
Log:
UPDATE: Some inefficient Map iterations (https://issues.apache.org/jira/browse/OFBIZ-4405). A small changed patch from Dimitri Unruh which handles some inefficient Map iterations.
Modified:
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
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=1170447&r1=1170446&r2=1170447&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 Wed Sep 14 06:41:51 2011
@@ -713,8 +713,9 @@ public class InvoiceServices {
if (prorateTaxes == null) {
prorateTaxes = "Y";
}
- for (GenericValue adj : taxAdjustments.keySet()) {
- BigDecimal adjAlreadyInvoicedAmount = taxAdjustments.get(adj);
+ for (Map.Entry<GenericValue, BigDecimal> entry : taxAdjustments.entrySet()) {
+ GenericValue adj = entry.getKey();
+ BigDecimal adjAlreadyInvoicedAmount = entry.getValue();
BigDecimal adjAmount = null;
if ("N".equalsIgnoreCase(prorateTaxes)) {
@@ -1145,7 +1146,7 @@ public class InvoiceServices {
// The orders can now be placed in separate groups, each for
// 1. The group of orders for which payment is already captured. No grouping and action required.
// 2. The group of orders for which invoice is IN-Process status.
- Map<String, Object> ordersWithInProcessInvoice = FastMap.newInstance();
+ Map<String, GenericValue> ordersWithInProcessInvoice = FastMap.newInstance();
for (GenericValue itemIssuance : itemIssuances) {
String orderId = itemIssuance.getString("orderId");
@@ -1181,9 +1182,7 @@ public class InvoiceServices {
}
// For In-Process invoice, move the status to ready and capture the payment
- Set<String> invoicesInProcess = ordersWithInProcessInvoice.keySet();
- for (String orderId : invoicesInProcess) {
- GenericValue invoice = (GenericValue) ordersWithInProcessInvoice.get(orderId);
+ for (GenericValue invoice : ordersWithInProcessInvoice.values()) {
String invoiceId = invoice.getString("invoiceId");
Map<String, Object> setInvoiceStatusResult = FastMap.newInstance();
try {
@@ -1519,9 +1518,10 @@ public class InvoiceServices {
if (totalAdditionalShippingCharges.signum() == 1) {
// Add an OrderAdjustment to the order for each additional shipping charge
- for (GenericValue shipment : additionalShippingCharges.keySet()) {
+ for (Map.Entry<GenericValue, BigDecimal> entry : additionalShippingCharges.entrySet()) {
+ GenericValue shipment = entry.getKey();
+ BigDecimal additionalShippingCharge = entry.getValue();
String shipmentId = shipment.getString("shipmentId");
- BigDecimal additionalShippingCharge = additionalShippingCharges.get(shipment);
Map<String, Object> createOrderAdjustmentContext = FastMap.newInstance();
createOrderAdjustmentContext.put("orderId", orderId);
createOrderAdjustmentContext.put("orderAdjustmentTypeId", "SHIPPING_CHARGES");
@@ -1817,8 +1817,9 @@ public class InvoiceServices {
}
// loop through the returnId keys in the map and invoke the createInvoiceFromReturn service for each
- for (String returnId : itemsShippedGroupedByReturn.keySet()) {
- List<GenericValue> billItems = itemsShippedGroupedByReturn.get(returnId);
+ for (Map.Entry<String, List<GenericValue>> entry : itemsShippedGroupedByReturn.entrySet()) {
+ String returnId = entry.getKey();
+ List<GenericValue> billItems = entry.getValue();
if (Debug.verboseOn()) {
Debug.logVerbose("Creating invoice for return [" + returnId + "] with items: " + billItems.toString(), module);
}
@@ -2178,8 +2179,7 @@ public class InvoiceServices {
}
BigDecimal totalPayments = ZERO;
- for (String paymentId : payments.keySet()) {
- BigDecimal amount = payments.get(paymentId);
+ for (BigDecimal amount : payments.values()) {
if (amount == null) amount = ZERO;
totalPayments = totalPayments.add(amount).setScale(DECIMALS, ROUNDING);
}