Skip to content

Commit 9e23a1e

Browse files
fix: handle division by zero in persen calculation for jenis belanja
1 parent d704c60 commit 9e23a1e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/Nova/Metrics/RealisasiPerJenisBelanja.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ public function __construct()
6161
$item->target = round(($total / 100) * $targetSerapan, 0);
6262
$item->realisasi = $item->realisasi ?? 0;
6363
$item->selisih = $item->realisasi - $item->target;
64-
$item->persen = round(($item->realisasi / $item->target) * 100, 2);
64+
$item->persen = ($item->target == 0)
65+
? 100
66+
: round(($item->realisasi / $item->target) * 100, 2);
6567
$item->jenis_belanja = Helper::JENIS_BELANJA[$item->jenis_belanja];
6668

6769
return $item;

0 commit comments

Comments
 (0)