Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-6347

Two order payment preferences are added to order, when order of order total 0(zero) is placed with Billing Account

    Details

    • Sprint:
      Community Day 2 - 2015

      Description

      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.

      1. OFBIZ-6347.patch
        1 kB
        Mohammad Kathawala

        Activity

        Hide
        jacopoc Jacopo Cappellato added a comment -

        Thank you Mohammad Kathawala.
        Is this issue (duplicated OPP when billing account is selected) happening only with $0 orders or in general with all the orders? If it is happening only with $0 orders,it would be useful to figure out why the block of code you have removed only causes problems with $0 orders. Did you get a chance to explore this?

        Show
        jacopoc Jacopo Cappellato added a comment - Thank you Mohammad Kathawala . Is this issue (duplicated OPP when billing account is selected) happening only with $0 orders or in general with all the orders? If it is happening only with $0 orders,it would be useful to figure out why the block of code you have removed only causes problems with $0 orders. Did you get a chance to explore this?
        Hide
        Mohammad K Mohammad Kathawala added a comment -

        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.

        Show
        Mohammad K Mohammad Kathawala added a comment - 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.
        Hide
        arunpati Arun Patidar added a comment -

        Committed fix at in trunk at rev: 1686545
        in 14.12 at rev: 1686550
        and in 13.07 at rev: 1686552

        Thanks Mohammad Kathawala for the patch.

        Show
        arunpati Arun Patidar added a comment - Committed fix at in trunk at rev: 1686545 in 14.12 at rev: 1686550 and in 13.07 at rev: 1686552 Thanks Mohammad Kathawala for the patch.
        Hide
        jacques.le.roux Jacques Le Roux added a comment -

        Backported in R12.04 at r1693691

        Put versions changed in "Fix Version/s" field

        Show
        jacques.le.roux Jacques Le Roux added a comment - Backported in R12.04 at r1693691 Put versions changed in "Fix Version/s" field

          People

          • Assignee:
            arunpati Arun Patidar
            Reporter:
            Mohammad K Mohammad Kathawala
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development

                Agile