Author: jacopoc
Date: Thu May 24 09:26:42 2007 New Revision: 541349 URL: http://svn.apache.org/viewvc?view=rev&rev=541349 Log: Added code to always set the maxAmount in the OrderPaymentPreference. Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?view=diff&rev=541349&r1=541348&r2=541349 ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Thu May 24 09:26:42 2007 @@ -3385,14 +3385,17 @@ } /** make a list of all OrderPaymentPreferences and Billing info including all payment methods and types */ - public List makeAllOrderPaymentInfos() { + public List makeAllOrderPaymentInfos(LocalDispatcher dispatcher) { List allOpPrefs = new LinkedList(); - Iterator i = paymentInfo.iterator(); - while (i.hasNext()) { - CartPaymentInfo inf = (CartPaymentInfo) i.next(); - allOpPrefs.addAll(inf.makeOrderPaymentInfos(this.getDelegator())); - } + double remainingAmount = this.getGrandTotal() - this.getPaymentTotal(); if (getBillingAccountId() != null) { + double billingAccountAvailableAmount = billingAccountAvailableAmount = CheckOutHelper.availableAccountBalance(getBillingAccountId(), dispatcher); + if (remainingAmount < getBillingAccountAmount()) { + this.billingAccountAmt = remainingAmount; + } + if (billingAccountAvailableAmount < getBillingAccountAmount()) { + this.billingAccountAmt = billingAccountAvailableAmount; + } GenericValue opp = delegator.makeValue("OrderPaymentPreference", new HashMap()); opp.set("paymentMethodTypeId", "EXT_BILLACT"); opp.set("presentFlag", "N"); @@ -3400,6 +3403,19 @@ opp.set("maxAmount", new Double(getBillingAccountAmount())); opp.set("statusId", "PAYMENT_NOT_RECEIVED"); allOpPrefs.add(opp); + remainingAmount = remainingAmount - getBillingAccountAmount(); + if (remainingAmount < 0) { + remainingAmount = 0; + } + } + Iterator i = paymentInfo.iterator(); + while (i.hasNext()) { + CartPaymentInfo inf = (CartPaymentInfo) i.next(); + if (inf.amount == null) { + inf.amount = new Double(remainingAmount); + remainingAmount = 0; + } + allOpPrefs.addAll(inf.makeOrderPaymentInfos(this.getDelegator())); } return allOpPrefs; } @@ -3636,7 +3652,7 @@ result.put("orderItemAttributes", this.makeAllOrderItemAttributes()); result.put("orderContactMechs", this.makeAllOrderContactMechs()); result.put("orderItemContactMechs", this.makeAllOrderItemContactMechs()); - result.put("orderPaymentInfo", this.makeAllOrderPaymentInfos()); + result.put("orderPaymentInfo", this.makeAllOrderPaymentInfos(dispatcher)); result.put("orderItemShipGroupInfo", this.makeAllShipGroupInfos()); result.put("orderItemSurveyResponses", this.makeAllOrderItemSurveyResponses()); result.put("orderAdditionalPartyRoleMap", this.getAdditionalPartyRoleMap()); |
Free forum by Nabble | Edit this page |