fix: update purchase notification logic and filter active raw materials in inventory alerts
This commit is contained in:
parent
6c8993c9a9
commit
198ec48ba1
@ -302,7 +302,6 @@ public function update(Purchase $purchase, array $validated): void
|
|||||||
public function delete(Purchase $purchase): void
|
public function delete(Purchase $purchase): void
|
||||||
{
|
{
|
||||||
$supplierName = $purchase->supplier->name;
|
$supplierName = $purchase->supplier->name;
|
||||||
$total = $purchase->total;
|
|
||||||
|
|
||||||
DB::transaction(function () use ($purchase): void {
|
DB::transaction(function () use ($purchase): void {
|
||||||
$purchase->load('items');
|
$purchase->load('items');
|
||||||
@ -318,7 +317,7 @@ public function delete(Purchase $purchase): void
|
|||||||
|
|
||||||
$this->pushNotificationService->sendToRoles(
|
$this->pushNotificationService->sendToRoles(
|
||||||
'🗑️ Belanja Dihapus',
|
'🗑️ Belanja Dihapus',
|
||||||
"Pembelian dari supplier {$supplierName} senilai {$total_formatted} telah dihapus.",
|
"Pembelian dari supplier {$supplierName} senilai {$purchase->total_formatted} telah dihapus.",
|
||||||
['owner', 'developer'],
|
['owner', 'developer'],
|
||||||
'/admin/manage/purchases',
|
'/admin/manage/purchases',
|
||||||
);
|
);
|
||||||
|
|||||||
@ -85,6 +85,7 @@ public function stockWarningGroups(): array
|
|||||||
private function inventoryAlertGroups(callable $filter): array
|
private function inventoryAlertGroups(callable $filter): array
|
||||||
{
|
{
|
||||||
return RawMaterialPrice::query()
|
return RawMaterialPrice::query()
|
||||||
|
->whereHas('rawMaterial', fn (Builder $query) => $query->where('is_active', true))
|
||||||
->with(['rawMaterial', 'media'])
|
->with(['rawMaterial', 'media'])
|
||||||
->get()
|
->get()
|
||||||
->filter($filter)
|
->filter($filter)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user