Author: lektran
Date: Sat Jul 7 00:09:56 2007
New Revision: 554149
URL: http://svn.apache.org/viewvc?view=rev&rev=554149
Log:
Applied fix from trunk for revision: 543964
Modified:
ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
Modified:
ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?view=diff&rev=554149&r1=554148&r2=554149
==============================================================================
---
ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
(original)
+++
ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
Sat Jul 7 00:09:56 2007
@@ -3327,33 +3327,36 @@
/** make a list of all OrderPaymentPreferences and Billing info including
all payment methods and types */
public List makeAllOrderPaymentInfos(LocalDispatcher dispatcher) {
List allOpPrefs = new LinkedList();
- double remainingAmount = this.getGrandTotal() - this.getPaymentTotal();
+ //double remainingAmount = this.getGrandTotal() -
this.getPaymentTotal();
+ BigDecimal remainingAmount = new BigDecimal(this.getGrandTotal() -
this.getPaymentTotal());
+ remainingAmount = remainingAmount.setScale(2,
BigDecimal.ROUND_HALF_UP);
if (getBillingAccountId() != null) {
- double billingAccountAvailableAmount =
billingAccountAvailableAmount =
CheckOutHelper.availableAccountBalance(getBillingAccountId(), dispatcher);
- if (remainingAmount < getBillingAccountAmount()) {
- this.billingAccountAmt = remainingAmount;
+ double billingAccountAvailableAmount =
CheckOutHelper.availableAccountBalance(getBillingAccountId(), dispatcher);
+ if (remainingAmount.doubleValue() < getBillingAccountAmount()) {
+ this.billingAccountAmt = remainingAmount.doubleValue();
}
if (billingAccountAvailableAmount < getBillingAccountAmount()) {
this.billingAccountAmt = billingAccountAvailableAmount;
}
+ BigDecimal billingAccountAmountSelected = new
BigDecimal(getBillingAccountAmount());
GenericValue opp = delegator.makeValue("OrderPaymentPreference",
new HashMap());
opp.set("paymentMethodTypeId", "EXT_BILLACT");
opp.set("presentFlag", "N");
opp.set("overflowFlag", "N");
- opp.set("maxAmount", new Double(getBillingAccountAmount()));
+ opp.set("maxAmount", new
Double(billingAccountAmountSelected.doubleValue()));
opp.set("statusId", "PAYMENT_NOT_RECEIVED");
allOpPrefs.add(opp);
- remainingAmount = remainingAmount - getBillingAccountAmount();
- if (remainingAmount < 0) {
- remainingAmount = 0;
+ remainingAmount =
remainingAmount.subtract(billingAccountAmountSelected);
+ if (remainingAmount.compareTo(BigDecimal.ZERO) < 0) {
+ remainingAmount = BigDecimal.ZERO;
}
}
Iterator i = paymentInfo.iterator();
while (i.hasNext()) {
CartPaymentInfo inf = (CartPaymentInfo) i.next();
if (inf.amount == null) {
- inf.amount = new Double(remainingAmount);
- remainingAmount = 0;
+ inf.amount = new Double(remainingAmount.doubleValue());
+ remainingAmount = BigDecimal.ZERO;
}
allOpPrefs.addAll(inf.makeOrderPaymentInfos(this.getDelegator()));
}