Posted by
sichen on
Jul 22, 2006; 12:15am
URL: http://ofbiz.116.s1.nabble.com/svn-commit-r424489-in-incubator-ofbiz-trunk-applications-accounting-servicedef-services-billing-xml-a-tp208622.html
Author: sichen
Date: Fri Jul 21 16:15:19 2006
New Revision: 424489
URL:
http://svn.apache.org/viewvc?rev=424489&view=revLog:
Simplification of CheckOutHelper.availableAccountBalance to take advantage of BillingAccountWorker.getBillingAccountAvailableBalance(). This moves the concern of computing the available balance to the accounting component, where it should reside.
Modified:
incubator/ofbiz/trunk/applications/accounting/servicedef/services_billing.xml
incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java
incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
Modified: incubator/ofbiz/trunk/applications/accounting/servicedef/services_billing.xml
URL:
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/accounting/servicedef/services_billing.xml?rev=424489&r1=424488&r2=424489&view=diff==============================================================================
--- incubator/ofbiz/trunk/applications/accounting/servicedef/services_billing.xml (original)
+++ incubator/ofbiz/trunk/applications/accounting/servicedef/services_billing.xml Fri Jul 21 16:15:19 2006
@@ -98,6 +98,7 @@
<attribute name="billingAccountId" type="String" mode="IN" optional="false"/>
<attribute name="accountBalance" type="Double" mode="OUT" optional="false"/>
<attribute name="netAccountBalance" type="Double" mode="OUT" optional="false"/>
+ <attribute name="availableBalance" type="Double" mode="OUT" optional="false"/>
<attribute name="billingAccount" type="GenericValue" mode="OUT" optional="false"/>
</service>
</services>
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?rev=424489&r1=424488&r2=424489&view=diff==============================================================================
--- 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 Fri Jul 21 16:15:19 2006
@@ -211,10 +211,12 @@
GenericValue billingAccount = null;
Double accountBalance = null;
Double netAccountBalance = null;
+ Double availableBalance = null;
try {
billingAccount = delegator.findByPrimaryKey("BillingAccount", UtilMisc.toMap("billingAccountId", billingAccountId));
accountBalance = new Double((getBillingAccountBalance(delegator, billingAccountId)).doubleValue());
netAccountBalance = new Double((getBillingAccountNetBalance(delegator, billingAccountId)).doubleValue());
+ availableBalance = new Double(getBillingAccountAvailableBalance(billingAccount).doubleValue());
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError("Error getting billing account or calculating balance for billing account #" + billingAccountId);
@@ -227,6 +229,7 @@
Map result = ServiceUtil.returnSuccess();
result.put("accountBalance", accountBalance);
result.put("netAccountBalance", netAccountBalance);
+ result.put("availableBalance", availableBalance);
result.put("billingAccount", billingAccount);
return result;
}
Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
URL:
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=424489&r1=424488&r2=424489&view=diff==============================================================================
--- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java (original)
+++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java Fri Jul 21 16:15:19 2006
@@ -1451,30 +1451,18 @@
public double availableAccountBalance(String billingAccountId) {
GenericValue billingAccount = null;
- Double accountBalance = new Double(0.00);
- Double accountLimit = new Double(0.00);
+ Double availableBalance = new Double(0.00);
if (billingAccountId != null) {
try {
Map res = dispatcher.runSync("calcBillingAccountBalance", UtilMisc.toMap("billingAccountId", billingAccountId));
- billingAccount = (GenericValue) res.get("billingAccount");
- accountBalance = (Double) res.get("accountBalance");
+ availableBalance = (Double) res.get("availableBalance");
} catch (GenericServiceException e) {
Debug.logError(e, module);
}
- if (billingAccount != null) {
- accountLimit = billingAccount.getDouble("accountLimit");
- }
-
- if (accountLimit == null) {
- accountLimit = new Double(0.00);
- }
- if (accountBalance == null) {
- accountBalance = new Double(0.00);
- }
}
- return (accountLimit.doubleValue() - accountBalance.doubleValue());
+ return availableBalance.doubleValue();
}
public Map makeBillingAccountMap(List paymentPrefs) {