Author: lektran
Date: Fri Aug 15 14:40:30 2008 New Revision: 686377 URL: http://svn.apache.org/viewvc?rev=686377&view=rev Log: Various clean ups, no functional changes Removed: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/order/billingAccountOrders.goovy Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.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=686377&r1=686376&r2=686377&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/GlEvents.java Fri Aug 15 14:40:30 2008 @@ -69,7 +69,7 @@ GenericValue acctgTransEntry; try { List acctgTransEntries = delegator.findByAnd("AcctgTransEntry", UtilMisc.toMap("acctgTransId", acctgTransId, "acctgTransEntrySeqId", acctgTransEntrySeqId)); - if (UtilValidate.isNotEmpty(acctgTransEntries)) { + 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(); @@ -112,7 +112,7 @@ GenericValue acctgTransEntry; try { List acctgTransEntries = delegator.findByAnd("AcctgTransEntry", UtilMisc.toMap("acctgTransId", acctgTransId, "acctgTransEntrySeqId", acctgTransEntrySeqId)); - if (UtilValidate.isNotEmpty(acctgTransEntries)) { + if (acctgTransEntries.size() > 0) { Iterator acctgTransEntryItr = acctgTransEntries.iterator(); while (acctgTransEntryItr.hasNext()) { acctgTransEntry = (GenericValue) acctgTransEntryItr.next(); 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=686377&r1=686376&r2=686377&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 Aug 15 14:40:30 2008 @@ -116,7 +116,7 @@ LocalDispatcher dispatcher = dctx.getDispatcher(); try { List orderItems = delegator.findByAnd("OrderItem", UtilMisc.toMap("orderId", (String) context.get("orderId"))); - if (orderItems != null && orderItems.size() > 0) { + if (orderItems.size() > 0) { context.put("billItems", orderItems); } // get the system userid and store in context otherwise the invoice add service does not work @@ -166,7 +166,7 @@ // get list of previous invoices for the order List billedItems = delegator.findByAnd("OrderItemBilling", UtilMisc.toMap("orderId", orderId)); - if (billedItems != null && billedItems.size() > 0) { + if (billedItems.size() > 0) { boolean nonDigitalInvoice = false; Iterator bii = billedItems.iterator(); while (bii.hasNext() && !nonDigitalInvoice) { @@ -766,33 +766,31 @@ // check for previous order payments List orderPaymentPrefs = delegator.findByAnd("OrderPaymentPreference", UtilMisc.toMap("orderId", orderId)); - if (orderPaymentPrefs != null) { - List currentPayments = new ArrayList(); - Iterator opi = orderPaymentPrefs.iterator(); - while (opi.hasNext()) { - GenericValue paymentPref = (GenericValue) opi.next(); - List payments = paymentPref.getRelated("Payment"); - currentPayments.addAll(payments); - } - if (currentPayments.size() > 0) { - // apply these payments to the invoice; only if they haven't already been applied - Iterator cpi = currentPayments.iterator(); - while (cpi.hasNext()) { - GenericValue payment = (GenericValue) cpi.next(); - List currentApplications = null; - currentApplications = payment.getRelated("PaymentApplication"); - if (currentApplications == null || currentApplications.size() == 0) { - // no applications; okay to apply - Map appl = new HashMap(); - appl.put("paymentId", payment.get("paymentId")); - appl.put("invoiceId", invoiceId); - appl.put("billingAccountId", billingAccountId); - appl.put("amountApplied", payment.get("amount")); - appl.put("userLogin", userLogin); - Map createPayApplResult = dispatcher.runSync("createPaymentApplication", appl); - if (ServiceUtil.isError(createPayApplResult)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource,"AccountingErrorCreatingInvoiceFromOrder",locale), null, null, createPayApplResult); - } + List currentPayments = FastList.newInstance(); + Iterator opi = orderPaymentPrefs.iterator(); + while (opi.hasNext()) { + GenericValue paymentPref = (GenericValue) opi.next(); + List payments = paymentPref.getRelated("Payment"); + currentPayments.addAll(payments); + } + if (currentPayments.size() > 0) { + // apply these payments to the invoice; only if they haven't already been applied + Iterator cpi = currentPayments.iterator(); + while (cpi.hasNext()) { + GenericValue payment = (GenericValue) cpi.next(); + List currentApplications = null; + currentApplications = payment.getRelated("PaymentApplication"); + if (currentApplications == null || currentApplications.size() == 0) { + // no applications; okay to apply + Map appl = new HashMap(); + appl.put("paymentId", payment.get("paymentId")); + appl.put("invoiceId", invoiceId); + appl.put("billingAccountId", billingAccountId); + appl.put("amountApplied", payment.get("amount")); + appl.put("userLogin", userLogin); + Map createPayApplResult = dispatcher.runSync("createPaymentApplication", appl); + if (ServiceUtil.isError(createPayApplResult)) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource,"AccountingErrorCreatingInvoiceFromOrder",locale), null, null, createPayApplResult); } } } @@ -959,7 +957,7 @@ // create the bill-from (or pay-to) contact mech as the primary PAYMENT_LOCATION of the party from the store List contactMechs = delegator.findByAnd("PartyContactMechPurpose", UtilMisc.toMap("partyId", partyIdBillTo, "contactMechPurposeTypeId", "BILLING_LOCATION")); - if ((contactMechs != null) && (contactMechs.size() > 0)) { + if (contactMechs.size() > 0) { GenericValue address = (GenericValue) contactMechs.get(0); GenericValue payToCm = delegator.makeValue("InvoiceContactMech", UtilMisc.toMap( "invoiceId", invoiceId, @@ -968,7 +966,7 @@ toStore.add(payToCm); } contactMechs = delegator.findByAnd("PartyContactMechPurpose", UtilMisc.toMap("partyId", partyIdBillFrom, "contactMechPurposeTypeId", "PAYMENT_LOCATION")); - if ((contactMechs != null) && (contactMechs.size() > 0)) { + if (contactMechs.size() > 0) { GenericValue address = (GenericValue) contactMechs.get(0); GenericValue payToCm = delegator.makeValue("InvoiceContactMech", UtilMisc.toMap( "invoiceId", invoiceId, @@ -1120,15 +1118,13 @@ if (purchaseShipmentFound) { items = delegator.findList("ShipmentReceipt", shipmentIdsCond, null, UtilMisc.toList("shipmentId"), null, false); // filter out items which have been received but are not actually owned by an internal organization, so they should not be on a purchase invoice - if (items != null) { - Iterator itemsIter = items.iterator(); - while (itemsIter.hasNext()) { - GenericValue item = (GenericValue) itemsIter.next(); - GenericValue inventoryItem = item.getRelatedOne("InventoryItem"); - GenericValue ownerPartyRole = delegator.findByPrimaryKeyCache("PartyRole", UtilMisc.toMap("partyId", inventoryItem.getString("ownerPartyId"), "roleTypeId", "INTERNAL_ORGANIZATIO")); - if (UtilValidate.isEmpty(ownerPartyRole)) { - items.remove(item); - } + Iterator itemsIter = items.iterator(); + while (itemsIter.hasNext()) { + GenericValue item = (GenericValue) itemsIter.next(); + GenericValue inventoryItem = item.getRelatedOne("InventoryItem"); + GenericValue ownerPartyRole = delegator.findByPrimaryKeyCache("PartyRole", UtilMisc.toMap("partyId", inventoryItem.getString("ownerPartyId"), "roleTypeId", "INTERNAL_ORGANIZATIO")); + if (UtilValidate.isEmpty(ownerPartyRole)) { + itemsIter.remove(); } } } else if (dropShipmentFound) { @@ -1138,7 +1134,7 @@ // Get the list of purchase order IDs related to the shipments List purchaseOrderIds = EntityUtil.getFieldListFromEntityList(shipments, "primaryOrderId", true); - if (createSalesInvoicesForDropShipments.booleanValue()) { + if (createSalesInvoicesForDropShipments) { // If a sales invoice is being created for a drop shipment, we have to reference the original sales order items // Get the list of the linked orderIds (original sales orders) @@ -1159,13 +1155,13 @@ Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } - if (items == null) { + if (items.size() == 0) { Debug.logInfo("No items issued for shipments", module); return ServiceUtil.returnSuccess(); } // group items by order - Map shippedOrderItems = new HashMap(); + Map shippedOrderItems = FastMap.newInstance(); Iterator itemsIter = items.iterator(); while (itemsIter.hasNext()) { GenericValue item = (GenericValue) itemsIter.next(); @@ -1199,7 +1195,7 @@ } // if none found, then okay to bill - if (itemBillings == null || itemBillings.size() == 0) { + if (itemBillings.size() == 0) { itemsByOrder.add(item); } @@ -1264,7 +1260,7 @@ // add up the already billed total - if (billed != null && billed.size() > 0) { + if (billed.size() > 0) { BigDecimal billedQuantity = ZERO; Iterator bi = billed.iterator(); while (bi.hasNext()) { @@ -1312,7 +1308,7 @@ if (dropShipmentFound) { List invoiceablePrimaryOrderIds = null; - if (createSalesInvoicesForDropShipments.booleanValue()) { + if (createSalesInvoicesForDropShipments) { // If a sales invoice is being created for the drop shipment, we need to reference back to the original purchase order IDs @@ -1340,7 +1336,7 @@ } } else { List invoiceableShipmentIds = EntityUtil.getFieldListFromEntityList(toBillItems, "shipmentId", true); - if (! UtilValidate.isEmpty(invoiceableShipmentIds)) { + if (UtilValidate.isNotEmpty(invoiceableShipmentIds)) { invoiceableShipments = delegator.findList("Shipment", EntityCondition.makeCondition("shipmentId", EntityOperator.IN, invoiceableShipmentIds), null, null, null, false); } } @@ -1351,9 +1347,9 @@ } // Total the additional shipping charges for the shipments - Map additionalShippingCharges = new HashMap(); + Map additionalShippingCharges = FastMap.newInstance(); BigDecimal totalAdditionalShippingCharges = ZERO; - if (! UtilValidate.isEmpty(invoiceableShipments)) { + if (UtilValidate.isNotEmpty(invoiceableShipments)) { Iterator isit = invoiceableShipments.iterator(); while(isit.hasNext()) { GenericValue shipment = (GenericValue) isit.next(); @@ -1453,7 +1449,7 @@ } // If part of the order was paid via credit card, try to charge it for the additional shipping - List orderPaymentPreferences = new ArrayList(); + List orderPaymentPreferences = null; try { orderPaymentPreferences = delegator.findByAnd("OrderPaymentPreference", UtilMisc.toMap("orderId", orderId, "paymentMethodTypeId", "CREDIT_CARD")); } catch( GenericEntityException e ) { @@ -1642,7 +1638,7 @@ billings = delegator.findByAnd("ReturnItemBilling", UtilMisc.toMap("returnId", returnId, "returnItemSeqId", returnItemSeqId)); } // if there are billings, we have already billed the item, so skip it - if (billings.size() > 0) continue; + if (billings != null && billings.size() > 0) continue; // get the List of items shipped to/from this returnId List billItems = (List) itemsShippedGroupedByReturn.get(returnId); @@ -1977,20 +1973,17 @@ List paymentAppl = null; try { paymentAppl = delegator.findByAnd("PaymentAndApplication", UtilMisc.toMap("invoiceId", invoiceId)); - if (paymentAppl != null) { - - // For each payment application, select only those that are RECEIVED or SENT based on whether the payment is a RECEIPT or DISBURSEMENT respectively - for (Iterator iter = paymentAppl.iterator(); iter.hasNext(); ) { - GenericValue payment = (GenericValue) iter.next(); - if ("PMNT_RECEIVED".equals(payment.get("statusId")) && UtilAccounting.isReceipt(payment)) { - continue; // keep - } - if ("PMNT_SENT".equals(payment.get("statusId")) && UtilAccounting.isDisbursement(payment)) { - continue; // keep - } - // all other cases, remove the payment applicaition - iter.remove(); + // For each payment application, select only those that are RECEIVED or SENT based on whether the payment is a RECEIPT or DISBURSEMENT respectively + for (Iterator iter = paymentAppl.iterator(); iter.hasNext(); ) { + GenericValue payment = (GenericValue) iter.next(); + if ("PMNT_RECEIVED".equals(payment.get("statusId")) && UtilAccounting.isReceipt(payment)) { + continue; // keep + } + if ("PMNT_SENT".equals(payment.get("statusId")) && UtilAccounting.isDisbursement(payment)) { + continue; // keep } + // all other cases, remove the payment applicaition + iter.remove(); } } catch (GenericEntityException e) { String errMsg = UtilProperties.getMessage(resource, "AccountingProblemGettingPaymentApplication",UtilMisc.toMap("invoiceId",invoiceId), locale); @@ -2802,9 +2795,9 @@ try { invoiceItems = delegator.findByAnd("InvoiceItem", UtilMisc.toMap("invoiceId", invoiceId)); } catch (GenericEntityException e) { - ServiceUtil.returnError(e.getMessage()); + return ServiceUtil.returnError(e.getMessage()); } - if (invoiceItems == null || invoiceItems.size() == 0) { + if (invoiceItems.size() == 0) { errorMessageList.add("No invoice items found for invoice " + invoiceId + " to match payment against...\n"); return ServiceUtil.returnError(errorMessageList); } else { // we found some invoice items, start processing.... @@ -2987,9 +2980,9 @@ "toPaymentId", paymentApplication.get("toPaymentId"), "taxAuthGeoId", paymentApplication.get("taxAuthGeoId"))); } catch (GenericEntityException e) { - ServiceUtil.returnError(e.getMessage()); + return ServiceUtil.returnError(e.getMessage()); } - if (checkAppls != null && checkAppls.size() > 0) { + if (checkAppls.size() > 0) { if (debug) Debug.logInfo(checkAppls.size() + " records already exist", module); // 1 record exists just update and if diffrent ID delete other record and add together. GenericValue checkAppl = (GenericValue) checkAppls.get(0); 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=686377&r1=686376&r2=686377&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 Fri Aug 15 14:40:30 2008 @@ -82,7 +82,7 @@ List<GenericValue> billingAccountRoleList = delegator.findList("BillingAccountRole", barFindCond, null, null, null, false); billingAccountRoleList = EntityUtil.filterByDate(billingAccountRoleList); - if (billingAccountRoleList != null && billingAccountRoleList.size() > 0) { + if (billingAccountRoleList.size() > 0) { double totalAvailable = 0.0; Iterator billingAcctIter = billingAccountRoleList.iterator(); while (billingAcctIter.hasNext()) { @@ -155,26 +155,22 @@ ), EntityOperator.AND); List orderPaymentPreferenceSums = delegator.findList("OrderPurchasePaymentSummary", whereConditions, UtilMisc.toSet("maxAmount"), null, null, false); - if (orderPaymentPreferenceSums != null) { - for (Iterator oppsi = orderPaymentPreferenceSums.iterator(); oppsi.hasNext(); ) { - GenericValue orderPaymentPreferenceSum = (GenericValue) oppsi.next(); - BigDecimal maxAmount = orderPaymentPreferenceSum.getBigDecimal("maxAmount"); - balance = maxAmount != null ? balance.subtract(maxAmount) : balance; - } + for (Iterator oppsi = orderPaymentPreferenceSums.iterator(); oppsi.hasNext(); ) { + GenericValue orderPaymentPreferenceSum = (GenericValue) oppsi.next(); + BigDecimal maxAmount = orderPaymentPreferenceSum.getBigDecimal("maxAmount"); + balance = maxAmount != null ? balance.subtract(maxAmount) : balance; } List paymentAppls = delegator.findByAnd("PaymentApplication", UtilMisc.toMap("billingAccountId", billingAccountId)); // TODO: cancelled payments? - if (paymentAppls != null) { - for (Iterator pAi = paymentAppls.iterator(); pAi.hasNext(); ) { - GenericValue paymentAppl = (GenericValue) pAi.next(); - if (paymentAppl.getString("invoiceId") == null) { - BigDecimal amountApplied = paymentAppl.getBigDecimal("amountApplied"); - balance = balance.add(amountApplied); - } + for (Iterator pAi = paymentAppls.iterator(); pAi.hasNext(); ) { + GenericValue paymentAppl = (GenericValue) pAi.next(); + if (paymentAppl.getString("invoiceId") == null) { + BigDecimal amountApplied = paymentAppl.getBigDecimal("amountApplied"); + balance = balance.add(amountApplied); } } - + balance = balance.setScale(decimals, rounding); return balance; /* @@ -258,19 +254,17 @@ // 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)); - if (paymentAppls != null) { - for (Iterator pAi = paymentAppls.iterator(); pAi.hasNext(); ) { - GenericValue paymentAppl = (GenericValue) pAi.next(); - BigDecimal amountApplied = paymentAppl.getBigDecimal("amountApplied"); - GenericValue invoice = paymentAppl.getRelatedOne("Invoice"); - if (invoice != null) { - // make sure the invoice has not been canceled and it is not a "Customer return invoice" - if (!"CUST_RTN_INVOICE".equals(invoice.getString("invoiceTypeId")) && !"INVOICE_CANCELLED".equals(invoice.getString("statusId"))) { - balance = balance.add(amountApplied); - } - } else { - balance = balance.subtract(amountApplied); + for (Iterator pAi = paymentAppls.iterator(); pAi.hasNext(); ) { + GenericValue paymentAppl = (GenericValue) pAi.next(); + BigDecimal amountApplied = paymentAppl.getBigDecimal("amountApplied"); + GenericValue invoice = paymentAppl.getRelatedOne("Invoice"); + if (invoice != null) { + // make sure the invoice has not been canceled and it is not a "Customer return invoice" + if (!"CUST_RTN_INVOICE".equals(invoice.getString("invoiceTypeId")) && !"INVOICE_CANCELLED".equals(invoice.getString("statusId"))) { + balance = balance.add(amountApplied); } + } else { + balance = balance.subtract(amountApplied); } } Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java?rev=686377&r1=686376&r2=686377&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java Fri Aug 15 14:40:30 2008 @@ -314,7 +314,7 @@ Map lookupMap = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_NOT_AUTH"); List orderList = UtilMisc.toList("maxAmount"); paymentPrefs = delegator.findByAnd("OrderPaymentPreference", lookupMap, orderList); - if(reAuth) { + if (reAuth) { lookupMap.put("orderId", orderId); lookupMap.put("statusId", "PAYMENT_AUTHORIZED"); paymentPrefs.addAll(delegator.findByAnd("OrderPaymentPreference", lookupMap, orderList)); @@ -340,7 +340,7 @@ // loop through and auth each order payment preference int finished = 0; int hadError = 0; - List messages = new ArrayList(); + List messages = FastList.newInstance(); Iterator payments = paymentPrefs.iterator(); while (payments.hasNext()) { GenericValue paymentPref = (GenericValue) payments.next(); @@ -700,7 +700,7 @@ } // return complete if no payment prefs were found - if (paymentPrefs == null || paymentPrefs.size() == 0) { + if (paymentPrefs.size() == 0) { Debug.logWarning("No OrderPaymentPreference records available for release", module); result.put("processResult", "COMPLETE"); result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); @@ -708,7 +708,7 @@ } // iterate over the prefs and release each one - List finished = new ArrayList(); + List finished = FastList.newInstance(); Iterator payments = paymentPrefs.iterator(); while (payments.hasNext()) { GenericValue paymentPref = (GenericValue) payments.next(); @@ -1365,7 +1365,7 @@ } // See if there's an orderPaymentPreference - there should be only one OPP for EXT_BILLACT per order List orderPaymentPreferences = delegator.findByAnd("OrderPaymentPreference", UtilMisc.toMap("orderId", orderId, "paymentMethodTypeId", "EXT_BILLACT")); - if (orderPaymentPreferences != null && orderPaymentPreferences.size() > 0) { + if (orderPaymentPreferences.size() > 0) { GenericValue orderPaymentPreference = EntityUtil.getFirst(orderPaymentPreferences); // Check the productStore setting to see if we need to do this explicitly @@ -2505,7 +2505,7 @@ EntityCondition.makeCondition(EntityCondition.makeCondition("needsNsfRetry", EntityOperator.EQUALS, "Y"), EntityOperator.AND, EntityCondition.makeCondition(ModelEntity.STAMP_FIELD, EntityOperator.LESS_THAN_EQUAL_TO, oneWeekAgo)), null, null, UtilMisc.toList("orderId"), null); - List processList = new ArrayList(); + List processList = FastList.newInstance(); if (eli != null) { Debug.logInfo("Processing failed order re-auth(s)", module); GenericValue value = null; Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java?rev=686377&r1=686376&r2=686377&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java Fri Aug 15 14:40:30 2008 @@ -28,6 +28,8 @@ import javax.servlet.ServletRequest; import javax.servlet.jsp.PageContext; +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.base.util.UtilMisc; @@ -64,25 +66,23 @@ List paymentMethods = delegator.findByAnd("PaymentMethod", UtilMisc.toMap("partyId", partyId)); if (!showOld) paymentMethods = EntityUtil.filterByDate(paymentMethods, true); - if (paymentMethods != null) { - Iterator pmIter = paymentMethods.iterator(); + Iterator pmIter = paymentMethods.iterator(); - while (pmIter.hasNext()) { - GenericValue paymentMethod = (GenericValue) pmIter.next(); - Map valueMap = new HashMap(); - - paymentMethodValueMaps.add(valueMap); - valueMap.put("paymentMethod", paymentMethod); - if ("CREDIT_CARD".equals(paymentMethod.getString("paymentMethodTypeId"))) { - GenericValue creditCard = paymentMethod.getRelatedOne("CreditCard"); - if (creditCard != null) valueMap.put("creditCard", creditCard); - } else if ("GIFT_CARD".equals(paymentMethod.getString("paymentMethodTypeId"))) { - GenericValue giftCard = paymentMethod.getRelatedOne("GiftCard"); - if (giftCard != null) valueMap.put("giftCard", giftCard); - } else if ("EFT_ACCOUNT".equals(paymentMethod.getString("paymentMethodTypeId"))) { - GenericValue eftAccount = paymentMethod.getRelatedOne("EftAccount"); - if (eftAccount != null) valueMap.put("eftAccount", eftAccount); - } + while (pmIter.hasNext()) { + GenericValue paymentMethod = (GenericValue) pmIter.next(); + Map valueMap = FastMap.newInstance(); + + paymentMethodValueMaps.add(valueMap); + valueMap.put("paymentMethod", paymentMethod); + if ("CREDIT_CARD".equals(paymentMethod.getString("paymentMethodTypeId"))) { + GenericValue creditCard = paymentMethod.getRelatedOne("CreditCard"); + if (creditCard != null) valueMap.put("creditCard", creditCard); + } else if ("GIFT_CARD".equals(paymentMethod.getString("paymentMethodTypeId"))) { + GenericValue giftCard = paymentMethod.getRelatedOne("GiftCard"); + if (giftCard != null) valueMap.put("giftCard", giftCard); + } else if ("EFT_ACCOUNT".equals(paymentMethod.getString("paymentMethodTypeId"))) { + GenericValue eftAccount = paymentMethod.getRelatedOne("EftAccount"); + if (eftAccount != null) valueMap.put("eftAccount", eftAccount); } } } catch (GenericEntityException e) { Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java?rev=686377&r1=686376&r2=686377&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java Fri Aug 15 14:40:30 2008 @@ -408,7 +408,7 @@ Debug.logError(e, "Cannot get payment preferences for order #" + orderId, module); return false; } - if (paymentPrefs != null && paymentPrefs.size() > 0) { + if (paymentPrefs.size() > 0) { Iterator <GenericValue> i = paymentPrefs.iterator(); while (i.hasNext()) { GenericValue pref = (GenericValue) i.next(); Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java?rev=686377&r1=686376&r2=686377&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java Fri Aug 15 14:40:30 2008 @@ -88,7 +88,7 @@ GenericValue contactAddress = null; try { List addresses = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "BILLING_LOCATION")); - if (addresses == null || addresses.size() == 0) + if (addresses.size() == 0) addresses = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "SHIPPING_LOCATION")); GenericValue contactMech = EntityUtil.getFirst(addresses); contactAddress = delegator.findByPrimaryKey("PostalAddress", UtilMisc.toMap("contactMechId", contactMech.getString("contactMechId"))); |
Free forum by Nabble | Edit this page |