Author: sichen
Date: Thu Nov 30 12:42:18 2006 New Revision: 481069 URL: http://svn.apache.org/viewvc?view=rev&rev=481069 Log: Use BillingAccountWorker.getAvailableToCapture when figuring out amount to use billing account for, plus fix all instances of BigDecimal ZERO declaration to use already declared ZERO Modified: incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java Modified: incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?view=diff&rev=481069&r1=481068&r2=481069 ============================================================================== --- incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java (original) +++ incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java Thu Nov 30 12:42:18 2006 @@ -2072,16 +2072,16 @@ } // avoid null pointer exceptions. - if (amountApplied == null) amountApplied = new BigDecimal("0"); + if (amountApplied == null) amountApplied = ZERO; // makes no sense to have an item numer without an invoice number if (invoiceId == null) invoiceItemSeqId = null; // retrieve all information and perform checking on the retrieved info..... // Payment..... - BigDecimal paymentApplyAvailable = new BigDecimal("0"); + BigDecimal paymentApplyAvailable = ZERO; // amount available on the payment reduced by the already applied amounts - BigDecimal amountAppliedMax = new BigDecimal("0"); + BigDecimal amountAppliedMax = ZERO; // the maximum that can be applied taking payment,invoice,invoiceitem,billing account in concideration // if maxApplied is missing, this value can be used GenericValue payment = null; @@ -2131,7 +2131,7 @@ } // the "TO" Payment..... - BigDecimal toPaymentApplyAvailable = new BigDecimal("0"); + BigDecimal toPaymentApplyAvailable = ZERO; GenericValue toPayment = null; if (toPaymentId != null && !toPaymentId.equals("")) { try { @@ -2183,7 +2183,7 @@ // billing account GenericValue billingAccount = null; - BigDecimal billingAccountApplyAvailable = new BigDecimal("0"); + BigDecimal billingAccountApplyAvailable = ZERO; if (billingAccountId != null && !billingAccountId.equals("")) { try { billingAccount = delegator.findByPrimaryKey("BillingAccount", UtilMisc.toMap("billingAccountId", billingAccountId)); @@ -2196,8 +2196,7 @@ // Get the available balance, which is how much can be used, rather than the regular balance, which is how much has already been charged try { - billingAccountApplyAvailable = BillingAccountWorker.getAccountLimit(billingAccount).add( - BillingAccountWorker.getBillingAccountAvailableBalance(billingAccount)).setScale(decimals,rounding); + billingAccountApplyAvailable = BillingAccountWorker.availableToCapture(billingAccount); } catch (GenericEntityException e) { errorMessageList.add(UtilProperties.getMessage(resource, "AccountingBillingAccountBalanceNotFound",UtilMisc.toMap("billingAccountId",billingAccountId), locale)); ServiceUtil.returnError(e.getMessage()); @@ -2236,9 +2235,9 @@ } // get the invoice (item) information - BigDecimal invoiceApplyAvailable = new BigDecimal("0"); + BigDecimal invoiceApplyAvailable = ZERO; // amount available on the invoice reduced by the already applied amounts - BigDecimal invoiceItemApplyAvailable = new BigDecimal("0"); + BigDecimal invoiceItemApplyAvailable = ZERO; // amount available on the invoiceItem reduced by the already applied amounts GenericValue invoice = null; GenericValue invoiceItem = null; @@ -2617,9 +2616,9 @@ } catch (GenericEntityException e) { ServiceUtil.returnError(e.getMessage()); } - BigDecimal tobeApplied = new BigDecimal("0"); + BigDecimal tobeApplied = ZERO; // item total amount - already applied (if any) - BigDecimal alreadyApplied = new BigDecimal("0"); + BigDecimal alreadyApplied = ZERO; if (paymentApplications != null && paymentApplications.size() > 0) { // application(s) found, add them all together Iterator p = paymentApplications.iterator(); @@ -2643,7 +2642,7 @@ paymentApplyAvailable = paymentApplyAvailable.subtract(tobeApplied); } else { tobeApplied = paymentApplyAvailable; - paymentApplyAvailable = new BigDecimal("0"); + paymentApplyAvailable = ZERO; } // create application payment record but check currency |
Free forum by Nabble | Edit this page |