From 2d54c670de3b9735c77f364e2da7a91cd3311ab3 Mon Sep 17 00:00:00 2001 From: Ghassan Yusuf Date: Tue, 19 May 2026 13:25:29 +0300 Subject: [PATCH] fix: low stock alert only on out movements, fix date formatting in notifications --- app/Http/Controllers/Inventory/StockMovementController.php | 2 +- .../Production/ProductionOrderCompletedNotification.php | 2 +- .../Purchase/GoodsReceiptConfirmedNotification.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Inventory/StockMovementController.php b/app/Http/Controllers/Inventory/StockMovementController.php index f0c5293..22d0c2f 100644 --- a/app/Http/Controllers/Inventory/StockMovementController.php +++ b/app/Http/Controllers/Inventory/StockMovementController.php @@ -61,7 +61,7 @@ class StockMovementController extends Controller $stockLevel->refresh(); $item = Item::find($request->item_id); - if ($item && $item->minimum_stock_level && $stockLevel->quantity <= $item->minimum_stock_level) { + if ($request->type === 'out' && $item && $item->minimum_stock_level && $stockLevel->quantity <= $item->minimum_stock_level) { $storeManagers = \App\Models\User::role('Store Manager')->whereNotNull('whatsapp_number')->get(); \Illuminate\Support\Facades\Notification::send( $storeManagers, diff --git a/app/Notifications/Production/ProductionOrderCompletedNotification.php b/app/Notifications/Production/ProductionOrderCompletedNotification.php index a32a112..f7c2dcf 100644 --- a/app/Notifications/Production/ProductionOrderCompletedNotification.php +++ b/app/Notifications/Production/ProductionOrderCompletedNotification.php @@ -23,7 +23,7 @@ class ProductionOrderCompletedNotification extends Notification implements Shoul public function toUltraMessage(mixed $notifiable): UltraMessageMessage { return UltraMessageMessage::text( - "✅ *Production Complete*\n\nProduction Order *#{$this->order->order_number}* has been completed.\n\nProduct: {$this->order->product->item_name}\nQuantity: {$this->order->quantity_to_produce}\nCompleted: " . now()->format('d M Y') + "✅ *Production Complete*\n\nProduction Order *#{$this->order->order_number}* has been completed.\n\nProduct: {$this->order->product->item_name}\nQuantity: {$this->order->quantity_to_produce}\nCompleted: {$this->order->completion_date->format('d M Y')}" ); } } diff --git a/app/Notifications/Purchase/GoodsReceiptConfirmedNotification.php b/app/Notifications/Purchase/GoodsReceiptConfirmedNotification.php index 9bfd060..025b362 100644 --- a/app/Notifications/Purchase/GoodsReceiptConfirmedNotification.php +++ b/app/Notifications/Purchase/GoodsReceiptConfirmedNotification.php @@ -23,7 +23,7 @@ class GoodsReceiptConfirmedNotification extends Notification implements ShouldQu public function toUltraMessage(mixed $notifiable): UltraMessageMessage { return UltraMessageMessage::text( - "GRN *#{$this->grn->grn_number}* has been confirmed and goods received.\n\nPO Reference: {$this->grn->purchaseOrder->po_number}\nDate: {$this->grn->received_date}" + "GRN *#{$this->grn->grn_number}* has been confirmed and goods received.\n\nPO Reference: {$this->grn->purchaseOrder->po_number}\nDate: {$this->grn->received_date->format('d M Y')}" ); } }