From 536bcde8dae1a6be2ebec7dd64cc32dbc3e53870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Thu, 30 Mar 2023 11:06:47 +0200 Subject: [PATCH] OrderPolicy list post order-tunnel action where order mail_sent is true --- app/Policies/OrderPolicy.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Policies/OrderPolicy.php b/app/Policies/OrderPolicy.php index 99bbd9d..a6f988d 100644 --- a/app/Policies/OrderPolicy.php +++ b/app/Policies/OrderPolicy.php @@ -82,6 +82,8 @@ class OrderPolicy extends Policy { // phpcs:enable if ( + // ! Limit to only order where mail has been sent (order-tunnel has completed). + $order->mail_sent and $order->validation_status->equals(ValidationStatus::cancelled()) or $order->delivery_status->value >= DeliveryStatus::ready()->value ) { @@ -102,6 +104,8 @@ class OrderPolicy extends Policy { $transaction = $order->getTransactionUsedForPayment(); if ( + // ! Limit to only order where mail has been sent (order-tunnel has completed). + !$order->mail_sent or $order->validation_status->equals(ValidationStatus::cancelled()) or !$transaction ) { @@ -121,7 +125,11 @@ class OrderPolicy extends Policy */ public function changeDeliveryStatus(User $user, Order $order): Response { - if ($order->validation_status->equals(ValidationStatus::pending())) { + if ( + // ! Limit to only order where mail has been sent (order-tunnel has completed). + !$order->mail_sent or + $order->validation_status->equals(ValidationStatus::pending()) + ) { return Response::deny(); } // phpcs:enable @@ -141,6 +149,8 @@ class OrderPolicy extends Policy // phpcs:enable $transaction = $order->getTransactionUsedForPayment(); if ( + // ! Limit to only order where mail has been sent (order-tunnel has completed). + !$order->mail_sent or !$order->can_be_refund or !$transaction or $transaction->payment_mode->equals(PaymentModeEnum::inShop())