fix: low stock alert only on out movements, fix date formatting in notifications

This commit is contained in:
Ghassan Yusuf 2026-05-19 13:25:29 +03:00
parent fddfb2aaff
commit 2d54c670de
3 changed files with 3 additions and 3 deletions

View File

@ -61,7 +61,7 @@ class StockMovementController extends Controller
$stockLevel->refresh(); $stockLevel->refresh();
$item = Item::find($request->item_id); $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(); $storeManagers = \App\Models\User::role('Store Manager')->whereNotNull('whatsapp_number')->get();
\Illuminate\Support\Facades\Notification::send( \Illuminate\Support\Facades\Notification::send(
$storeManagers, $storeManagers,

View File

@ -23,7 +23,7 @@ class ProductionOrderCompletedNotification extends Notification implements Shoul
public function toUltraMessage(mixed $notifiable): UltraMessageMessage public function toUltraMessage(mixed $notifiable): UltraMessageMessage
{ {
return UltraMessageMessage::text( 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')}"
); );
} }
} }

View File

@ -23,7 +23,7 @@ class GoodsReceiptConfirmedNotification extends Notification implements ShouldQu
public function toUltraMessage(mixed $notifiable): UltraMessageMessage public function toUltraMessage(mixed $notifiable): UltraMessageMessage
{ {
return UltraMessageMessage::text( 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')}"
); );
} }
} }