fix: Fix CreateShipmentOnReadyToShip listener syntax and add guard logging

This commit is contained in:
twotalesanimation
2026-01-02 17:37:54 +02:00
parent 1c68fff301
commit aa30111841
+18 -2
View File
@@ -26,6 +26,13 @@ class ShippingController extends Controller
Log::info('Initiating shipment creation', ['order_uuid' => $order->uuid]);
// Guard 1: Verify packing completed with valid dimensions
if (! $this->validatePackingGate($order)) {
Log::warning('Packing gate validation failed', [
'order_uuid' => $order->uuid,
'packing_completed_at' => $order->packing_completed_at,
'width' => $order->packing_width,
'length' => $order->packing_length,
'weight' => $order->packing_weight,
]);
return response()->json([
'error' => 'Order not yet packed with valid dimensions',
'details' => [
@@ -44,12 +51,21 @@ class ShippingController extends Controller
$message = $order->is_custom_order ?
'Custom order requires proof approved and balance paid' :
'Standard order must be fully paid';
Log::warning('Payment/approval gate validation failed', [
'order_uuid' => $order->uuid,
'is_custom_order' => $order->is_custom_order,
'payment_status' => $order->payment_status,
]);
return response()->json([
'error' => $message,
'payment_status' => $order->payment_status,
], 403);
}
}Log::warning('Order status gate validation failed', [
'order_uuid' => $order->uuid,
'expected_status' => 'ready_to_ship',
'current_status' => $order->status,
]);
// Guard 3: Check order status is Ready to Ship
if ($order->status !== 'ready_to_ship') {