[jira] [Commented] (OFBIZ-6347) Two order payment preferences are added to order, when order of order total 0(zero) is placed with Billing Account

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-6347) Two order payment preferences are added to order, when order of order total 0(zero) is placed with Billing Account

Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-6347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14537165#comment-14537165 ]

Mohammad Kathawala commented on OFBIZ-6347:
-------------------------------------------

Jacopo, the issue happens specifically when the amount entered for billing account is 0.

It goes into this block, only when the 'billingAccountAmt' which is amount entered for billing account is 0 or less.
if (getBillingAccountId() != null && this.billingAccountAmt.compareTo(BigDecimal.ZERO) <= 0) {
            BigDecimal billingAccountAvailableAmount = CheckOutHelper.availableAccountBalance(getBillingAccountId(), dispatcher);
            if (this.billingAccountAmt.compareTo(BigDecimal.ZERO) == 0 && billingAccountAvailableAmount.compareTo(BigDecimal.ZERO) > 0) {
                this.billingAccountAmt = billingAccountAvailableAmount;
            }
            if (remainingAmount.compareTo(getBillingAccountAmount()) < 0) {
                this.billingAccountAmt = remainingAmount;
            }
            if (billingAccountAvailableAmount.compareTo(getBillingAccountAmount()) < 0) {
                this.billingAccountAmt = billingAccountAvailableAmount;
            }
            BigDecimal billingAccountAmountSelected = getBillingAccountAmount();
            GenericValue opp = delegator.makeValue("OrderPaymentPreference", new HashMap<String, Object>());
            opp.set("paymentMethodTypeId", "EXT_BILLACT");
            opp.set("presentFlag", "N");
            opp.set("overflowFlag", "N");
            opp.set("maxAmount", billingAccountAmountSelected);
            opp.set("statusId", "PAYMENT_NOT_RECEIVED");
            allOpPrefs.add(opp);
            remainingAmount = remainingAmount.subtract(billingAccountAmountSelected);
            if (remainingAmount.compareTo(BigDecimal.ZERO) < 0) {
                remainingAmount = BigDecimal.ZERO;
            }
        }


As far as I get, the code inside this block assigns the available billing account amount or remaining amount whichever is less to billing account amount and creates a payment preference with that amount.

Again outside this block, it runs a loop of all the Cart Payment Info and creates order payment preference for each.

> Two order payment preferences are added to order, when order of order total 0(zero) is placed with Billing Account
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-6347
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-6347
>             Project: OFBiz
>          Issue Type: Bug
>          Components: order
>    Affects Versions: Trunk, 14.12.01
>            Reporter: Mohammad Kathawala
>            Priority: Minor
>         Attachments: OFBIZ-6347.patch
>
>
> Scenario:
>       Place an order of order total zero(0) with Billing Account as payment option.
> Issue:
>       Order gets placed successfully, but order payment preference of billing account gets created twice.
> Steps to generate the issue:
> 1) Add promotions of Free Shipping and Free Tax from catalog for order
> 2) Go to order entry process and add customer
> 3) Add product to order and make its price 0.00 so that the cart total will be 0.00
> 4) Finalize order with Billing Account as Payment option and Create Order.
> Reason:
> The code written for creating order payment preferences in 'makeAllOrderPaymentInfos' of ShoppingCart.java is creating issue.
> There is no need to create the order payment preference after recalculating Billing account amount as it is done later in the CartPaymentInfo loop.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)