Skip to content

Commit

Permalink
fix: do not cancel refused order when we cancel related tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Atala committed Feb 6, 2025
1 parent d5d3144 commit 725873e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Doctrine/EventSubscriber/TaskSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ private function handleStateChangesForTasks(EntitymanagerInterface $em, array $t
continue;
}

// if all tasks of a delivery are cancelled, cancel the linked order
$tasks = $delivery->getTasks();
$cancelOrder = true;
foreach ($tasks as $task) {
Expand All @@ -233,7 +234,8 @@ private function handleStateChangesForTasks(EntitymanagerInterface $em, array $t
}
}

if ($cancelOrder && $order->getState() !== OrderInterface::STATE_CANCELLED) {
// do not cancel order if order is "refused"
if ($cancelOrder && $order->getState() !== OrderInterface::STATE_CANCELLED && $order->getState() !== OrderInterface::STATE_REFUSED) {
$this->orderManager->cancel($order, 'All tasks were cancelled');
$em->flush();
}
Expand Down

0 comments on commit 725873e

Please sign in to comment.