You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by si...@apache.org on 2006/11/30 02:11:32 UTC
svn commit: r480798 - in
/incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting:
invoice/InvoiceServices.java payment/BillingAccountWorker.java
Author: sichen
Date: Wed Nov 29 17:11:32 2006
New Revision: 480798
URL: http://svn.apache.org/viewvc?view=rev&rev=480798
Log:
refactored a new method for BillingAccountWorker.getAccountLimit which can deal with cases when billing account's account limit is null but just returning a ZERO
Modified:
incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.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=480798&r1=480797&r2=480798
==============================================================================
--- 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 Wed Nov 29 17:11:32 2006
@@ -2196,7 +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 = billingAccount.getBigDecimal("accountLimit").add(
+ billingAccountApplyAvailable = BillingAccountWorker.getAccountLimit(billingAccount).add(
BillingAccountWorker.getBillingAccountAvailableBalance(billingAccount)).setScale(decimals,rounding);
} catch (GenericEntityException e) {
errorMessageList.add(UtilProperties.getMessage(resource, "AccountingBillingAccountBalanceNotFound",UtilMisc.toMap("billingAccountId",billingAccountId), locale));
Modified: incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java?view=diff&rev=480798&r1=480797&r2=480798
==============================================================================
--- incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java (original)
+++ incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java Wed Nov 29 17:11:32 2006
@@ -92,10 +92,7 @@
double accountBalance = (BillingAccountWorker.getBillingAccountBalance(billingAccountVO)).doubleValue();
Map billingAccount = new HashMap(billingAccountVO);
- double accountLimit = 0.0;
- if (billingAccountVO.getDouble("accountLimit") != null) {
- accountLimit = billingAccountVO.getDouble("accountLimit").doubleValue();
- }
+ double accountLimit = getAccountLimit(billingAccountVO).doubleValue();
billingAccount.put("accountBalance", new Double(accountBalance));
double accountAvailable = accountLimit - accountBalance;
@@ -107,6 +104,20 @@
billingAccountList.addAll(sortedAccounts.values());
}
return billingAccountList;
+ }
+
+ /**
+ * Returns the accountLimit of the BillingAccount or BigDecimal ZERO if it is null
+ * @param billingAccount
+ * @throws GenericEntityException
+ */
+ public static BigDecimal getAccountLimit(GenericValue billingAccount) throws GenericEntityException {
+ if (billingAccount.getBigDecimal("accountLimit") != null) {
+ return billingAccount.getBigDecimal("accountLimit");
+ } else {
+ Debug.logWarning("Billing Account [" + billingAccount.getString("billingAccountId") + "] does not have an account limit defined, assuming zero.", module);
+ return ZERO;
+ }
}
/**