From 198ec48ba1d0a18076aaa15c4658e526bb52dcc3 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Sun, 14 Jun 2026 15:43:33 +0700 Subject: [PATCH] fix: update purchase notification logic and filter active raw materials in inventory alerts --- app/Services/Manage/PurchaseService.php | 3 +-- app/Services/Master/RawMaterialService.php | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Services/Manage/PurchaseService.php b/app/Services/Manage/PurchaseService.php index a0172a3..0f0d0c5 100644 --- a/app/Services/Manage/PurchaseService.php +++ b/app/Services/Manage/PurchaseService.php @@ -302,7 +302,6 @@ public function update(Purchase $purchase, array $validated): void public function delete(Purchase $purchase): void { $supplierName = $purchase->supplier->name; - $total = $purchase->total; DB::transaction(function () use ($purchase): void { $purchase->load('items'); @@ -318,7 +317,7 @@ public function delete(Purchase $purchase): void $this->pushNotificationService->sendToRoles( '🗑️ Belanja Dihapus', - "Pembelian dari supplier {$supplierName} senilai {$total_formatted} telah dihapus.", + "Pembelian dari supplier {$supplierName} senilai {$purchase->total_formatted} telah dihapus.", ['owner', 'developer'], '/admin/manage/purchases', ); diff --git a/app/Services/Master/RawMaterialService.php b/app/Services/Master/RawMaterialService.php index ca219dd..2a9d413 100644 --- a/app/Services/Master/RawMaterialService.php +++ b/app/Services/Master/RawMaterialService.php @@ -85,6 +85,7 @@ public function stockWarningGroups(): array private function inventoryAlertGroups(callable $filter): array { return RawMaterialPrice::query() + ->whereHas('rawMaterial', fn (Builder $query) => $query->where('is_active', true)) ->with(['rawMaterial', 'media']) ->get() ->filter($filter)