Skip to content

BP-5091 No stockCompensation after order cancel #1407

@jeroenkosse

Description

@jeroenkosse

When a order is created and the payment is canceled the order state and status will be updated to Canceled. The stockCompensation is not handles correctly what leads to invalid stock values.

System information:

Magento Version: 2.4.7-p7
Buckaroo module version: v2.0.2/v2.0.3
Magento_Inventory Module disabled

In the DefaultProcessor \Buckaroo\Magento2\Model\Push\DefaultProcessor.php In the method processFailedPush On line 1132 there is the following orderRequestService: $this->orderRequestService->updateOrderStatus(Order::STATE_CANCELED, $newStatus, $description);. This service is handling the order cancel state and saves the order in this service.

After this Service is called there is a Call to cancel the order $this->order->cancel()->save(). In this call there is a registerCancellation that is handling the cancellation of the orderItems when the following check if true:

if ($this->canCancel() || $this->isPaymentReview() || $this->isFraudDetected())

Because the order is already canceled in the OrderRequestService the requirement is not valid and the stock item cancel method is never called and the stock is never returned to it's original value.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions