Skip to content

Commit 2579330

Browse files
committed
Refactor MonitoringUpPerJenis to incorporate tanggal_nihil for GUP and TUP calculations
1 parent 738009e commit 2579330

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

app/Nova/Metrics/MonitoringUpPerJenis.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Nova\Metrics;
44

55
use App\Helpers\Helper;
6+
use App\Models\Dipa;
67
use Laravel\Nova\Nova;
78
use Laravelwebdev\Table\Table;
89
use Laravelwebdev\Table\Table\Cell;
@@ -12,6 +13,11 @@ class MonitoringUpPerJenis extends Table
1213
{
1314
public function __construct()
1415
{
16+
$tglNihil = optional(
17+
Dipa::cache()->get('all')
18+
->where('tahun', session('year'))
19+
->first()
20+
)->tanggal_nihil;
1521
$gup = null;
1622
$minGup = null;
1723
$tup = null;
@@ -50,12 +56,20 @@ public function __construct()
5056
$this->data([
5157
Row::make(
5258
Cell::make('GUP'),
53-
Cell::make($gup ? Helper::terbilangTanggal($gup['akhir']) : '-'),
59+
Cell::make(
60+
($gup && $tglNihil && $gup['akhir'] > $tglNihil)
61+
? Helper::terbilangTanggal($tglNihil)
62+
: ($gup ? Helper::terbilangTanggal($gup['akhir']) : '-')
63+
),
5464
Cell::make($minGup ? Helper::formatUang($minGup) : '-')->class('text-right')
5565
),
5666
Row::make(
5767
Cell::make('TUP'),
58-
Cell::make(($tup && $tup['akhir'] !== '-') ? Helper::terbilangTanggal($tup['akhir']) : ($tup['akhir'] ?? '-')),
68+
Cell::make(
69+
($tup && $tglNihil && $tup['akhir'] > $tglNihil)
70+
? Helper::terbilangTanggal($tglNihil)
71+
: ($tup && $tup['akhir'] !== '-' ? Helper::terbilangTanggal($tup['akhir']) : ($tup['akhir'] ?? '-'))
72+
),
5973
Cell::make($latestTup ? Helper::formatUang(optional($latestTup)->nilai) : '-')->class('text-right')
6074
),
6175
]

0 commit comments

Comments
 (0)