fix: update purchase notification logic and filter active raw materials in inventory alerts

This commit is contained in:
Yoga Pangestu 2026-06-14 15:43:33 +07:00
parent 6c8993c9a9
commit 198ec48ba1
2 changed files with 2 additions and 2 deletions

View File

@ -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',
);

View File

@ -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)