Skip to content

[CE 2.1.0 rc3] - Cancel an order [configurable product] #5313

Closed
@mhabou

Description

@mhabou

Salamo Alaykom Magento team,

NB : All the products are configurable

The test products :

Product 1 :

Chaz Kangeroo Hoodie
SKU: MH01-XS-Black
Color: Black
Size: XS

Product 2 :

Chaz Kangeroo Hoodie
SKU: MH01-M-Orange
Color: Orange
Size: M

  • 1st issue -- Steps to reproduce

  1. Add the 2 configurable products above to the cart [product 1 qty 2 product 2 qty 3]
  2. Place the order
  3. Invoice & ship partially the order
  4. Cancel the order

Magento shows Cancel button after i canceled the order
When i click on Cancel again, it returns to the old state

See the video
https://youtu.be/hA7Ov6t3P-Q

Other issues :

  • Scenario 1 :

When i cancel the order --> no stock return of the item canceled

- Before the order
Product qty on stock
product 1 100
product 2 100
- Order then invoice, ship and cancel
Product qty_ordered qty_invoiced qty_shipped qty_canceled
product 1 2 1 2 0
product 2 3 2 0 1
- After the order

Actual result

Product qty on stock
product 1 98
product 2 97

Expected result

Product qty on stock
product 1 98
product 2 98
  • Scenario 2 :
- Before the order
Product qty on stock
product 1 100
product 2 100
- Order then invoice, ship and cancel
Product qty_ordered qty_invoiced qty_shipped qty_canceled
product 1 2 0 1 1
product 2 3 0 2 1
- After the order

Actual result

Product qty on stock
product 1 100
product 2 100

Expected Result

Product qty on stock
product 1 99
product 2 98
  • Scenario 3 :
- Before the order
Product qty on stock
product 1 100
product 2 100
- Order then invoice, ship and cancel
Product qty_ordered qty_invoiced qty_shipped qty_canceled
product 1 2 1 0 1
product 2 3 2 0 1
- After the order

Actual result

Product qty on stock
product 1 98
product 2 97

Expected Result

Product qty on stock
product 1 99
product 2 98
  • Scenario 4 :
- Before the order
Product qty on stock
product 1 100
product 2 100
- Order then invoice, ship, refund , cancel

Actual result

Product qty_ordered qty_invoiced qty_shipped qty_refunded qty_canceled
product 1 2 1 1 1 0
product 2 3 2 1 1 1

Expected Result

Product qty_ordered qty_invoiced qty_shipped qty_refunded qty_canceled
product 1 2 1 1 1 1
product 2 3 2 1 1 1

In the case of the " Product 1"
QtyToCancel = min(QtyToInvoice,QtyToShip)
QtyToCancel =min(1,0) = 0 ==> False

QtyToCancel must be 1 because QtyToShip must be 1 not 0
QtyToShip must be 1 because , qty_ordered=2 , qty_invoiced=1 ,qty_shipped=1 then i refunded 1 qty
So the remaining qty to invoice & to ship is 1

 public function getQtyToCancel()
    {

        $qtyToCancel = min($this->getQtyToInvoice(), $this->getQtyToShip());
        return max($qtyToCancel, 0);
    }
 public function getQtyToInvoice()
    {

        if ($this->isDummy()) {
            return 0;
        }

        $qty = $this->getQtyOrdered() - $this->getQtyInvoiced() - $this->getQtyCanceled();
        return max($qty, 0);
    }
 public function getQtyToShip()
    {
        if ($this->isDummy(true)) {
            return 0;
        }

        return $this->getSimpleQtyToShip();
    }
    public function getSimpleQtyToShip()
    {

        $qty = $this->getQtyOrdered() - $this->getQtyShipped() - $this->getQtyRefunded() - $this->getQtyCanceled();
        return max($qty, 0);
    }
- After the order

Actual result

Product qty on stock
product 1 98
product 2 97

Expected Result

Product qty on stock
product 1 99
product 2 98

I hope that everything is clear for you

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: SalesIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is not validGate 1 Failed. Automatic verification of issue format is failedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasebug reporttriage wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions