feat(lpj-print-out): perbaiki format currency dan parsing data NPW

- Standarisasi format currency menggunakan number_format() di seluruh print-out
- Hapus penggunaan formatRupiah() yang tidak konsisten
- Bersihkan data currency dengan str_replace() sebelum diproses
- Tangani karakter Rp, titik, dan koma agar parsing aman
- Perbaiki perhitungan total NPW dari data numerik murni
- Tambahkan null safety dengan default nilai 0
- Cegah error parsing akibat string currency
- Pastikan tampilan angka konsisten (contoh: 1.500.000)
This commit is contained in:
Daeng Deni Mardaeni
2025-12-15 11:13:37 +07:00
parent 1c5b48ff1b
commit e8a735e977
2 changed files with 7 additions and 11 deletions

View File

@@ -582,16 +582,14 @@
</td>
<td width="5%" style="padding: 3px; text-align: center;">X</td>
<td width="25%" style="padding: 3px; text-align:right">
{{ formatRupiah($npw['nilai_1'] ?? 0, 0, false) ?? '' }}
</td>
<td width="5" style="padding: 3px; text-align: center;">
=
{{ number_format((float) str_replace(['Rp', '.', ','], '', $npw['nilai_1'] ?? 0), 0, ',', '.') }}
</td>
<td width="5" style="padding: 3px; text-align: center;">=</td>
<td width="25%" style="padding: 3px; text-align: left; text-align: right;">
{{ formatRupiah($npw['nilai_2'] ?? 0, 0, false) ?? '' }}
{{ number_format((float) str_replace(['Rp', '.', ','], '', $npw['nilai_2'] ?? 0), 0, ',', '.') }}
</td>
</tr>
@php $totalNilaiPasarWajar += str_replace(['Rp', '.'], '', $npw['nilai_2']); @endphp
@php $totalNilaiPasarWajar += str_replace(['Rp', '.', ','], '', $npw['nilai_2'] ?? 0); @endphp
@endforeach
@endif
<tr>

View File

@@ -370,7 +370,6 @@
@endif
@endforeach
@endif
@if (isset($lpjData['npw_tambahan']))
@foreach ($lpjData['npw_tambahan'] as $npw)
<tr>
@@ -382,15 +381,14 @@
</td>
<td width="5%" style="padding: 3px; text-align: center;">X</td>
<td width="25%" style="padding: 3px; text-align:right">
{{ number_format($npw['nilai_1'], 0, ',', '.') ?? '' }}
{{ number_format((float) str_replace(['Rp', '.', ','], '', $npw['nilai_1'] ?? 0), 0, ',', '.') }}
</td>
<td width="5" style="padding: 3px; text-align: center;">=</td>
<td width="25%" style="padding: 3px; text-align: left; text-align: right;">
{{ number_format($npw['nilai_2'], 0, ',', '.') ?? '' }}
{{ number_format((float) str_replace(['Rp', '.', ','], '', $npw['nilai_2'] ?? 0), 0, ',', '.') }}
</td>
</tr>
@php $totalNilaiPasarWajar += $npw['nilai_2']; @endphp
@php $totalNilaiPasarWajar += str_replace(['Rp', '.', ','], '', $npw['nilai_2'] ?? 0); @endphp
@endforeach
@endif