fix: null check budget, cegah duplikasi approval/vote, tambah related_type di votes

This commit is contained in:
2026-04-05 23:22:15 +07:00
parent 4106eae5cf
commit db7c19b249
5 changed files with 54 additions and 26 deletions
+8 -7
View File
@@ -41,13 +41,14 @@ class CashRecordObserver
// Threshold: > 2jt → buat voting + notif semua anggota
if ($record->amount > 2_000_000) {
Vote::create([
'title' => "Persetujuan Transaksi: {$record->description}",
'description' => "Transaksi senilai Rp " . number_format($record->amount, 0, ',', '.') . " memerlukan persetujuan voting.",
'type' => 'finance',
'related_id' => $record->id,
'status' => 'open',
'deadline' => now()->addDays(3),
'created_by' => Auth::id() ?? $record->created_by,
'title' => "Persetujuan Transaksi: {$record->description}",
'description' => "Transaksi senilai Rp " . number_format($record->amount, 0, ',', '.') . " memerlukan persetujuan voting.",
'type' => 'finance',
'related_id' => $record->id,
'related_type' => CashRecord::class,
'status' => 'open',
'deadline' => now()->addDays(3),
'created_by' => Auth::id() ?? $record->created_by,
]);
NotificationService::toRole('ketua',