Perbaikan P1 Remunerasi #6
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Rekapitulasi;
|
||||
|
||||
use App\Models\Rekapitulasi\P1Selisih;
|
||||
use App\Models\Verifikator\Rekapitulasi;
|
||||
use App\Services\DawaiService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class RekapP1SelisihCommand extends Command
|
||||
{
|
||||
protected $signature = 'rekap:p1-selisih
|
||||
{--tahun= : Tahun rekap (default: tahun sekarang)}
|
||||
{--bulan= : Bulan rekap (default: bulan sekarang)}
|
||||
{--include-pppk-2025 : Sertakan PPPK 2025}';
|
||||
|
||||
protected $description = 'Menyimpan rekapitulasi selisih P1 ke schema rekapitulasi';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$tahun = (int) ($this->option('tahun') ?: Carbon::now()->year);
|
||||
$bulan = (int) ($this->option('bulan') ?: Carbon::now()->month);
|
||||
|
||||
if ($bulan < 1 || $bulan > 12) {
|
||||
$this->error('Bulan harus antara 1 dan 12.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$rekapitulasi = Rekapitulasi::where('tahun', $tahun)->get();
|
||||
$dawaiService = new DawaiService;
|
||||
$includePppk2025 = (bool) $this->option('include-pppk-2025');
|
||||
$bulanName = Carbon::create()->month($bulan)->locale('id')->isoFormat('MMMM');
|
||||
$jumlahDisimpan = 0;
|
||||
|
||||
foreach ($rekapitulasi as $unitKerja) {
|
||||
$idUnitPembayaran = $unitKerja->id_unit_kerja == 0 ? 99 : $unitKerja->id_unit_kerja;
|
||||
$response = $dawaiService->getDataP1SelisihResponse(null, $tahun, $bulan, $idUnitPembayaran);
|
||||
|
||||
foreach ($response['data'] ?? [] as $pegawai) {
|
||||
if (($pegawai['harga_p1'] ?? 0) <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$nip = preg_replace("/['\.\-]/", '', $pegawai['nip'] ?? '');
|
||||
if (! $nip || (! $includePppk2025 && str_contains($nip, '202521'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$selisihBruto = $pegawai['selisih_harga_p1'] ?? 0;
|
||||
$selisihNetto = $pegawai['selisih_harga_p1_setelah_pajak'] ?? 0;
|
||||
|
||||
P1Selisih::updateOrCreate(
|
||||
[
|
||||
'tahun' => $tahun,
|
||||
'bulan' => $bulan,
|
||||
'nip' => $nip,
|
||||
'id_unit_pembayaran' => $idUnitPembayaran,
|
||||
],
|
||||
[
|
||||
'nama' => $pegawai['nama_lengkap'] ?? '-',
|
||||
'jenis_pegawai' => isset($pegawai['jenis_pegawai']) ? ucfirst(strtolower($pegawai['jenis_pegawai'])) : null,
|
||||
'id_unit_kerja' => $pegawai['id_unit'] ?? $idUnitPembayaran,
|
||||
'nama_unit_kerja' => $pegawai['nama_unit'] ?? $unitKerja->unit_kerja_nama,
|
||||
'pangkat' => $pegawai['pangkat'] ?? null,
|
||||
'golongan' => $pegawai['golongan'] ?? null,
|
||||
'nama_jabatan_fungsional' => $pegawai['nama_jafung'] ?? null,
|
||||
'grade_jabatan_fungsional' => $pegawai['grade_jafung'] ?? null,
|
||||
'gaji_jabatan_fungsional' => $pegawai['harga_jafung'] ?? null,
|
||||
'nama_jabatan_tugas_tambahan' => ($pegawai['nama_jtt'] ?? null) === '-' ? null : ($pegawai['nama_jtt'] ?? null),
|
||||
'grade_jabatan_tugas_tambahan' => ($pegawai['grade_jtt'] ?? null) === '-' ? null : ($pegawai['grade_jtt'] ?? null),
|
||||
'gaji_jabatan_tugas_tambahan' => $pegawai['harga_jtt'] ?? null,
|
||||
'selisih_bruto' => $selisihBruto,
|
||||
'selisih_pajak' => $selisihBruto - $selisihNetto,
|
||||
'selisih_netto' => $selisihNetto,
|
||||
'keterangan' => $this->jenisSelisihLabel($pegawai).' '.$bulanName.' '.$tahun,
|
||||
'npwp' => preg_replace("/['\.\-]/", '', $pegawai['npwp'] ?? ''),
|
||||
'nomor_rekening' => preg_replace("/['\.\-]/", '', $pegawai['no_rekening'] ?? ''),
|
||||
]
|
||||
);
|
||||
|
||||
$jumlahDisimpan++;
|
||||
}
|
||||
|
||||
$this->info("Selesai: {$unitKerja->unit_kerja_nama}");
|
||||
}
|
||||
|
||||
$this->info("Rekapitulasi P1 Selisih berhasil disimpan ({$jumlahDisimpan} data).");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function jenisSelisihLabel(array $pegawai): string
|
||||
{
|
||||
$statusBruto = $pegawai['status_selisih_harga_p1'] ?? null;
|
||||
$statusNetto = $pegawai['status_selisih_harga_p1_setelah_pajak'] ?? null;
|
||||
$status = in_array($statusBruto, ['Kekurangan', 'Kelebihan'], true) ? $statusBruto : $statusNetto;
|
||||
|
||||
return in_array($status, ['Kekurangan', 'Kelebihan'], true) ? $status : '-';
|
||||
}
|
||||
}
|
||||
+81
-81
@@ -3,7 +3,7 @@
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Exports\Concerns\EnrichesJabatanData;
|
||||
use App\Services\DawaiService;
|
||||
use App\Models\Rekapitulasi\P1;
|
||||
use Carbon\Carbon;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
@@ -112,48 +112,41 @@ class P1MonthlySheet implements FromCollection, ShouldAutoSize, WithColumnFormat
|
||||
|
||||
private function buildCollection()
|
||||
{
|
||||
$dawaiService = new DawaiService;
|
||||
$data = $dawaiService->getDataP1($this->jenisPegawai, $this->tahun, $this->bulan, $this->unit);
|
||||
$filteredData = P1::query()
|
||||
->where('tahun', $this->tahun)
|
||||
->where('bulan', $this->bulan)
|
||||
->when($this->unit !== null && $this->unit !== '', function ($query) {
|
||||
$idUnitPembayaran = (int) $this->unit === 0 ? 99 : (int) $this->unit;
|
||||
$query->where('id_unit_pembayaran', $idUnitPembayaran);
|
||||
})
|
||||
->when($this->jenisPegawai !== '', function ($query) {
|
||||
$query->whereRaw('LOWER(jenis_pegawai) = ?', [strtolower($this->jenisPegawai)]);
|
||||
})
|
||||
->where('gaji_yang_dibayarkan', '>', 0)
|
||||
->get()
|
||||
->filter(fn (P1 $pegawai) => $this->includePppk2025 || ! str_contains($pegawai->nip ?? '', '202521'));
|
||||
|
||||
// Sertakan pegawai aktif (harga_p1 > 0) dan tubel/tubelmandiri (harga_p1 = 0)
|
||||
$filteredData = collect($data)->filter(function ($item) {
|
||||
if (! $this->includePppk2025 && str_contains($item['nip'] ?? '', '202521')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$isTubel = in_array($item['status'] ?? '', ['tubel', 'tubelmandiri']);
|
||||
|
||||
return (isset($item['harga_p1']) && $item['harga_p1'] > 0) || $isTubel;
|
||||
});
|
||||
|
||||
[$pegawaiData, $jabatanData, $riwayatJafungMap, $riwayatJttMap] = $this->buildJabatanContext($filteredData, $this->bulan);
|
||||
|
||||
// Gabungkan data dengan NPWP, nomor rekening, dan data jabatan
|
||||
$mappedData = $filteredData->map(function ($item) use ($pegawaiData, $jabatanData, $riwayatJafungMap, $riwayatJttMap) {
|
||||
$cleanNip = trim($item['nip'], "'"); // Remove single quotes from NIP for database lookup
|
||||
$pegawai = $pegawaiData->get($cleanNip);
|
||||
|
||||
[$pangkat, $golongan, $gradeJafung, $hargaJafung, $gradeJtt, $hargaJtt] = $this->resolveJabatanFields($item, $jabatanData, $riwayatJafungMap, $riwayatJttMap);
|
||||
$mappedData = $filteredData->map(function (P1 $pegawai) {
|
||||
|
||||
return (object) [
|
||||
'no' => 0, // Temporary, will be set after sorting
|
||||
'nip' => $item['nip'], // Keep original NIP with quotes
|
||||
'nama_lengkap' => $item['nama_lengkap'],
|
||||
'pangkat' => $pangkat,
|
||||
'golongan' => $golongan,
|
||||
'nama_jafung' => $item['nama_jafung'],
|
||||
'grade_jafung' => $gradeJafung,
|
||||
'harga_jafung' => $hargaJafung,
|
||||
'nama_jtt' => $item['nama_jtt'] ?: '-',
|
||||
'grade_jtt' => $gradeJtt,
|
||||
'harga_jtt' => $hargaJtt,
|
||||
'jenis_pegawai' => $item['jenis_pegawai'],
|
||||
'nama_unit' => $item['nama_unit'],
|
||||
'harga_p1' => $item['harga_p1'],
|
||||
'pajak_p1' => $item['pajak_p1'],
|
||||
'harga_p1_setelah_pajak' => $item['harga_p1_setelah_pajak'],
|
||||
'npwp' => $pegawai && $pegawai->npwp ? "'".str_replace(['-', '.'], '', $pegawai->npwp) : '',
|
||||
'nomor_rekening' => $pegawai && $pegawai->nomor_rekening ? "'".$pegawai->nomor_rekening : '',
|
||||
'nip' => "'".$pegawai->nip,
|
||||
'nama_lengkap' => $pegawai->nama,
|
||||
'pangkat' => $pegawai->pangkat,
|
||||
'golongan' => $pegawai->golongan,
|
||||
'nama_jafung' => $pegawai->nama_jabatan_fungsional,
|
||||
'grade_jafung' => $pegawai->grade_jabatan_fungsional,
|
||||
'harga_jafung' => $pegawai->gaji_jabatan_fungsional,
|
||||
'nama_jtt' => $pegawai->nama_jabatan_tugas_tambahan ?: '-',
|
||||
'grade_jtt' => $pegawai->grade_jabatan_tugas_tambahan,
|
||||
'harga_jtt' => $pegawai->gaji_jabatan_tugas_tambahan,
|
||||
'jenis_pegawai' => strtolower($pegawai->jenis_pegawai ?? ''),
|
||||
'nama_unit' => $pegawai->nama_unit_kerja,
|
||||
'harga_p1' => $pegawai->gaji_yang_dibayarkan,
|
||||
'pajak_p1' => $pegawai->pph21,
|
||||
'harga_p1_setelah_pajak' => $pegawai->gaji_bersih,
|
||||
'npwp' => $pegawai->npwp ? "'".str_replace(['-', '.'], '', $pegawai->npwp) : '',
|
||||
'nomor_rekening' => $pegawai->nomor_rekening ? "'".$pegawai->nomor_rekening : '',
|
||||
];
|
||||
});
|
||||
|
||||
@@ -167,34 +160,31 @@ class P1MonthlySheet implements FromCollection, ShouldAutoSize, WithColumnFormat
|
||||
return $item;
|
||||
});
|
||||
|
||||
// Add total row
|
||||
// Add summary rows
|
||||
if ($sortedData->count() > 0) {
|
||||
$totalHargaJafung = $sortedData->sum('harga_jafung');
|
||||
$totalHargaJtt = $sortedData->sum('harga_jtt');
|
||||
$totalP1 = $sortedData->sum('harga_p1');
|
||||
$totalPajak = $sortedData->sum('pajak_p1');
|
||||
$totalSetelahPajak = $sortedData->sum('harga_p1_setelah_pajak');
|
||||
$summaryValues = [
|
||||
'total_p1' => $sortedData->sum('harga_p1'),
|
||||
'total_p1_setelah_pajak' => $sortedData->sum('pajak_p1'),
|
||||
'total_p1_dibayarkan' => $sortedData->sum('harga_p1_setelah_pajak'),
|
||||
];
|
||||
|
||||
$sortedData->push((object) [
|
||||
'no' => '',
|
||||
'nip' => '',
|
||||
'nama_lengkap' => 'TOTAL',
|
||||
'pangkat' => '',
|
||||
'golongan' => '',
|
||||
'nama_jafung' => '',
|
||||
'grade_jafung' => '',
|
||||
'harga_jafung' => $totalHargaJafung,
|
||||
'nama_jtt' => '',
|
||||
'grade_jtt' => '',
|
||||
'harga_jtt' => $totalHargaJtt,
|
||||
'jenis_pegawai' => '',
|
||||
'nama_unit' => '',
|
||||
'harga_p1' => $totalP1,
|
||||
'pajak_p1' => $totalPajak,
|
||||
'harga_p1_setelah_pajak' => $totalSetelahPajak,
|
||||
'npwp' => '',
|
||||
'nomor_rekening' => '',
|
||||
]);
|
||||
for ($spacer = 0; $spacer < 3; $spacer++) {
|
||||
$sortedData->push((object) ['is_spacer' => true]);
|
||||
}
|
||||
|
||||
$summary = [
|
||||
'Total P1' => 'total_p1',
|
||||
'Total P1 Setelah Pajak' => 'total_p1_setelah_pajak',
|
||||
'Total P1 Dibayarkan' => 'total_p1_dibayarkan',
|
||||
];
|
||||
|
||||
foreach ($summary as $label => $key) {
|
||||
$sortedData->push((object) [
|
||||
'is_summary' => true,
|
||||
'nama_lengkap' => $label,
|
||||
'summary_value' => $summaryValues[$key],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $sortedData;
|
||||
@@ -226,6 +216,18 @@ class P1MonthlySheet implements FromCollection, ShouldAutoSize, WithColumnFormat
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
if ($row->is_spacer ?? false) {
|
||||
return array_fill(0, 18, '');
|
||||
}
|
||||
|
||||
if ($row->is_summary ?? false) {
|
||||
$summaryRow = array_fill(0, 18, '');
|
||||
$summaryRow[1] = $row->nama_lengkap.':';
|
||||
$summaryRow[2] = $row->summary_value;
|
||||
|
||||
return $summaryRow;
|
||||
}
|
||||
|
||||
return [
|
||||
$row->no,
|
||||
$row->nama_lengkap,
|
||||
@@ -266,9 +268,6 @@ class P1MonthlySheet implements FromCollection, ShouldAutoSize, WithColumnFormat
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$dataCount = $this->collection()->count();
|
||||
$totalRowNumber = $dataCount + 1; // +1 untuk header
|
||||
|
||||
$styles = [
|
||||
// Header row styling
|
||||
1 => [
|
||||
@@ -284,19 +283,20 @@ class P1MonthlySheet implements FromCollection, ShouldAutoSize, WithColumnFormat
|
||||
],
|
||||
];
|
||||
|
||||
// Total row styling jika ada data
|
||||
if ($dataCount > 1) { // > 1 karena ada row TOTAL
|
||||
$styles[$totalRowNumber] = [
|
||||
'font' => ['bold' => true, 'color' => ['rgb' => 'FFFFFF']],
|
||||
'fill' => [
|
||||
'fillType' => Fill::FILL_SOLID,
|
||||
'startColor' => ['rgb' => '70AD47'],
|
||||
],
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_RIGHT,
|
||||
'vertical' => Alignment::VERTICAL_CENTER,
|
||||
],
|
||||
];
|
||||
$dataCount = $this->collection()->count();
|
||||
if ($dataCount > 0) {
|
||||
$summaryStartRow = $dataCount - 1;
|
||||
$accountingFormat = '_("Rp"\ * #,##0.00_);_("Rp"\ * \-#,##0.00_);_("Rp"\ * "-"??_);_(@_)';
|
||||
|
||||
for ($rowNumber = $summaryStartRow; $rowNumber <= $summaryStartRow + 2; $rowNumber++) {
|
||||
$styles['B'.$rowNumber] = [
|
||||
'font' => ['bold' => true],
|
||||
];
|
||||
$styles['C'.$rowNumber] = [
|
||||
'font' => ['bold' => true],
|
||||
'numberFormat' => ['formatCode' => $accountingFormat],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $styles;
|
||||
|
||||
@@ -72,6 +72,8 @@ class P1SelisihMonthlySheet implements FromCollection, ShouldAutoSize, WithColum
|
||||
*/
|
||||
private $cachedCollection;
|
||||
|
||||
private array $totals = [];
|
||||
|
||||
protected $bulanNames = [
|
||||
1 => 'Januari',
|
||||
2 => 'Februari',
|
||||
@@ -112,7 +114,9 @@ class P1SelisihMonthlySheet implements FromCollection, ShouldAutoSize, WithColum
|
||||
|
||||
private function buildCollection()
|
||||
{
|
||||
$data = $this->fetchSelisihData();
|
||||
$response = $this->fetchSelisihResponse();
|
||||
$data = $response['data'] ?? [];
|
||||
$this->totals = $response;
|
||||
|
||||
// Sertakan semua pegawai dari endpoint selisih (Kekurangan, Kelebihan, maupun Tidak Ada selisih)
|
||||
$filteredData = collect($data)->filter(function ($item) {
|
||||
@@ -168,40 +172,37 @@ class P1SelisihMonthlySheet implements FromCollection, ShouldAutoSize, WithColum
|
||||
return $item;
|
||||
});
|
||||
|
||||
// Add total row
|
||||
if ($sortedData->count() > 0) {
|
||||
$totalHargaJafung = $sortedData->sum('harga_jafung');
|
||||
$totalHargaJtt = $sortedData->sum('harga_jtt');
|
||||
$totalSelisihBruto = $sortedData->sum('selisih_bruto');
|
||||
$totalSelisihPajak = $sortedData->sum('selisih_pajak');
|
||||
$totalSelisihNetto = $sortedData->sum('selisih_netto');
|
||||
for ($spacer = 0; $spacer < 3; $spacer++) {
|
||||
$sortedData->push((object) ['is_spacer' => true]);
|
||||
}
|
||||
|
||||
$sortedData->push((object) [
|
||||
'no' => '',
|
||||
'nip' => '',
|
||||
'nama_lengkap' => 'TOTAL',
|
||||
'pangkat' => '',
|
||||
'golongan' => '',
|
||||
'nama_jafung' => '',
|
||||
'grade_jafung' => '',
|
||||
'harga_jafung' => $totalHargaJafung,
|
||||
'nama_jtt' => '',
|
||||
'grade_jtt' => '',
|
||||
'harga_jtt' => $totalHargaJtt,
|
||||
'jenis_pegawai' => '',
|
||||
'selisih_bruto' => $totalSelisihBruto,
|
||||
'selisih_pajak' => $totalSelisihPajak,
|
||||
'selisih_netto' => $totalSelisihNetto,
|
||||
'keterangan' => '',
|
||||
'npwp' => '',
|
||||
'nomor_rekening' => '',
|
||||
'nama_unit' => '',
|
||||
]);
|
||||
$summary = [
|
||||
'Total Kelebihan P1' => 'total_kelebihan_p1',
|
||||
'Total Kelebihan P1 Setelah Pajak' => 'total_kelebihan_p1_setelah_pajak',
|
||||
'Total Kekurangan P1' => 'total_kekurangan_p1',
|
||||
'Total Kekurangan P1 Setelah Pajak' => 'total_kekurangan_p1_setelah_pajak',
|
||||
];
|
||||
|
||||
foreach ($summary as $label => $key) {
|
||||
$sortedData->push((object) [
|
||||
'is_summary' => true,
|
||||
'nama_lengkap' => $label,
|
||||
'summary_value' => $this->totals[$key] ?? 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $sortedData;
|
||||
}
|
||||
|
||||
private function fetchSelisihResponse(): array
|
||||
{
|
||||
$dawaiService = new DawaiService;
|
||||
|
||||
return $dawaiService->getDataP1SelisihResponse($this->jenisPegawai, $this->tahun, $this->bulan, $this->unit);
|
||||
}
|
||||
|
||||
private function fetchSelisihData(): array
|
||||
{
|
||||
$dawaiService = new DawaiService;
|
||||
@@ -266,6 +267,19 @@ class P1SelisihMonthlySheet implements FromCollection, ShouldAutoSize, WithColum
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
if ($row->is_spacer ?? false) {
|
||||
return array_fill(0, 19, '');
|
||||
}
|
||||
|
||||
if ($row->is_summary ?? false) {
|
||||
return [
|
||||
'',
|
||||
$row->nama_lengkap.':',
|
||||
$row->summary_value,
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
$row->no,
|
||||
$row->nama_lengkap,
|
||||
@@ -308,7 +322,8 @@ class P1SelisihMonthlySheet implements FromCollection, ShouldAutoSize, WithColum
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$dataCount = $this->collection()->count();
|
||||
$totalRowNumber = $dataCount + 1; // +1 untuk header
|
||||
$summaryStartRow = $dataCount - 2;
|
||||
$accountingFormat = '_("Rp"\ * #,##0.00_);_("Rp"\ * \-#,##0.00_);_("Rp"\ * "-"??_);_(@_)';
|
||||
|
||||
$styles = [
|
||||
// Header row styling
|
||||
@@ -325,19 +340,16 @@ class P1SelisihMonthlySheet implements FromCollection, ShouldAutoSize, WithColum
|
||||
],
|
||||
];
|
||||
|
||||
// Total row styling jika ada data
|
||||
if ($dataCount > 1) { // > 1 karena ada row TOTAL
|
||||
$styles[$totalRowNumber] = [
|
||||
'font' => ['bold' => true, 'color' => ['rgb' => 'FFFFFF']],
|
||||
'fill' => [
|
||||
'fillType' => Fill::FILL_SOLID,
|
||||
'startColor' => ['rgb' => '70AD47'],
|
||||
],
|
||||
'alignment' => [
|
||||
'horizontal' => Alignment::HORIZONTAL_RIGHT,
|
||||
'vertical' => Alignment::VERTICAL_CENTER,
|
||||
],
|
||||
];
|
||||
if ($dataCount > 0) {
|
||||
for ($rowNumber = $summaryStartRow; $rowNumber <= $summaryStartRow + 3; $rowNumber++) {
|
||||
$styles['B'.$rowNumber] = [
|
||||
'font' => ['bold' => true],
|
||||
];
|
||||
$styles['C'.$rowNumber] = [
|
||||
'font' => ['bold' => true],
|
||||
'numberFormat' => ['formatCode' => $accountingFormat],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $styles;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Perhitungan\Remunerasi;
|
||||
use App\Exports\P1Export;
|
||||
use App\Exports\P1SelisihExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Rekapitulasi\P1;
|
||||
use App\Models\Verifikator\Team;
|
||||
use App\Models\Verifikator\UnitKerja;
|
||||
use App\Services\DawaiService;
|
||||
@@ -55,12 +56,44 @@ class P1Controller extends Controller
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
$bulan = $request->bulan ?? $bulanNow;
|
||||
|
||||
$cacheKey = "p1_data_{$jenisPegawai}_{$tahun}_{$bulan}_{$unit}";
|
||||
$cacheKey = "p1_rekap_compare_v2_{$jenisPegawai}_{$tahun}_{$bulan}_{$unit}";
|
||||
|
||||
$data = Cache::remember($cacheKey, now()->addDay(), function () use ($jenisPegawai, $tahun, $bulan, $unit) {
|
||||
$dawaiService = new DawaiService;
|
||||
$apiData = collect((new DawaiService)->getDataP1($jenisPegawai, $tahun, $bulan, $unit))
|
||||
->keyBy(fn ($item) => preg_replace("/['\.\-]/", '', $item['nip'] ?? ''));
|
||||
|
||||
return $dawaiService->getDataP1($jenisPegawai, $tahun, $bulan, $unit);
|
||||
return P1::query()
|
||||
->where('tahun', $tahun)
|
||||
->where('bulan', $bulan)
|
||||
->when($unit !== null && $unit !== '', function ($query) use ($unit) {
|
||||
$idUnitPembayaran = (int) $unit === 0 ? 99 : (int) $unit;
|
||||
$query->where('id_unit_pembayaran', $idUnitPembayaran);
|
||||
})
|
||||
->when($jenisPegawai !== '', function ($query) use ($jenisPegawai) {
|
||||
$query->whereRaw('LOWER(jenis_pegawai) = ?', [strtolower($jenisPegawai)]);
|
||||
})
|
||||
->get()
|
||||
->map(function (P1 $pegawai) use ($apiData) {
|
||||
$apiPegawai = $apiData->get(preg_replace("/['\.\-]/", '', $pegawai->nip));
|
||||
$differs = fn ($dbValue, $apiValue) => $apiPegawai !== null
|
||||
&& abs((float) $dbValue - (float) $apiValue) >= 0.01;
|
||||
|
||||
return [
|
||||
'nama_lengkap' => $pegawai->nama,
|
||||
'nip' => $pegawai->nip,
|
||||
'jenis_pegawai' => strtolower($pegawai->jenis_pegawai ?? ''),
|
||||
'nama_unit' => $pegawai->nama_unit_kerja,
|
||||
'nama_jafung' => $pegawai->nama_jabatan_fungsional,
|
||||
'nama_jtt' => $pegawai->nama_jabatan_tugas_tambahan,
|
||||
'harga_p1' => $pegawai->gaji_yang_dibayarkan,
|
||||
'pajak_p1' => $pegawai->pph21,
|
||||
'harga_p1_setelah_pajak' => $pegawai->gaji_bersih,
|
||||
'harga_p1_diff' => $differs($pegawai->gaji_yang_dibayarkan, $apiPegawai['harga_p1'] ?? 0),
|
||||
'pajak_p1_diff' => $differs($pegawai->pph21, $apiPegawai['pajak_p1'] ?? 0),
|
||||
'harga_p1_setelah_pajak_diff' => $differs($pegawai->gaji_bersih, $apiPegawai['harga_p1_setelah_pajak'] ?? 0),
|
||||
];
|
||||
})
|
||||
->all();
|
||||
});
|
||||
|
||||
$includePppk2025 = $request->boolean('include_pppk_2025');
|
||||
@@ -174,6 +207,100 @@ class P1Controller extends Controller
|
||||
->make();
|
||||
}
|
||||
|
||||
public function dataPerbandingan(Request $request): JsonResponse
|
||||
{
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
if (! $team) {
|
||||
return DataTables::of(collect([]))->make();
|
||||
}
|
||||
|
||||
$unit = $team->unit_kerja_id;
|
||||
if (! isset($team->unit_kerja_id) || $team->unit_kerja_id === null || $team->unit_kerja_id === 0) {
|
||||
$unit = $request->input('unit');
|
||||
}
|
||||
$unit = $unit == 99 ? 0 : $unit;
|
||||
|
||||
$tahun = (int) ($request->input('tahun') ?: now()->year);
|
||||
$bulan = (int) ($request->input('bulan') ?: now()->month);
|
||||
$previousMonth = $bulan === 1 ? 12 : $bulan - 1;
|
||||
$previousYear = $bulan === 1 ? $tahun - 1 : $tahun;
|
||||
$jenisPegawai = $request->input('jenis_pegawai');
|
||||
$arah = $request->input('arah', '');
|
||||
$monthNames = [
|
||||
1 => 'Januari', 2 => 'Februari', 3 => 'Maret', 4 => 'April', 5 => 'Mei', 6 => 'Juni',
|
||||
7 => 'Juli', 8 => 'Agustus', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Desember',
|
||||
];
|
||||
|
||||
$baseQuery = function (int $queryYear, int $queryMonth) use ($unit, $jenisPegawai) {
|
||||
return P1::query()
|
||||
->where('tahun', $queryYear)
|
||||
->where('bulan', $queryMonth)
|
||||
->when($unit !== null && $unit !== '', fn ($query) => $query->where('id_unit_kerja', $unit))
|
||||
->when($jenisPegawai === 'dosen' || $jenisPegawai === 'tendik', fn ($query) => $query->whereRaw('LOWER(jenis_pegawai) = ?', [$jenisPegawai]))
|
||||
->get()
|
||||
->keyBy('nip');
|
||||
};
|
||||
|
||||
$current = $baseQuery($tahun, $bulan);
|
||||
$previous = $baseQuery($previousYear, $previousMonth);
|
||||
$nips = $current->keys()->merge($previous->keys())->unique();
|
||||
|
||||
$comparison = $nips->map(function ($nip) use ($current, $previous, $bulan, $previousMonth, $tahun, $previousYear, $monthNames) {
|
||||
$currentRow = $current->get($nip);
|
||||
$previousRow = $previous->get($nip);
|
||||
$currentBruto = (float) ($currentRow->gaji_yang_dibayarkan ?? 0);
|
||||
$previousBruto = (float) ($previousRow->gaji_yang_dibayarkan ?? 0);
|
||||
$currentPajak = (float) ($currentRow->pph21 ?? 0);
|
||||
$previousPajak = (float) ($previousRow->pph21 ?? 0);
|
||||
$currentNetto = (float) ($currentRow->gaji_bersih ?? 0);
|
||||
$previousNetto = (float) ($previousRow->gaji_bersih ?? 0);
|
||||
|
||||
$jenisPegawaiRow = strtolower((string) ($currentRow->jenis_pegawai ?? $previousRow->jenis_pegawai ?? ''));
|
||||
|
||||
return [
|
||||
'nama' => $currentRow->nama ?? $previousRow->nama ?? '-',
|
||||
'nip' => ltrim((string) $nip, "'"),
|
||||
'nama_unit_kerja' => $currentRow->nama_unit_kerja ?? $previousRow->nama_unit_kerja ?? '-',
|
||||
'jenis_pegawai' => $jenisPegawaiRow,
|
||||
'bulan' => $bulan,
|
||||
'bulan_lalu' => $previousMonth,
|
||||
'selisih_bruto' => $currentBruto - $previousBruto,
|
||||
'selisih_pajak' => $currentPajak - $previousPajak,
|
||||
'selisih_netto' => $currentNetto - $previousNetto,
|
||||
'detail' => json_encode([
|
||||
'bulan_lalu' => $monthNames[$previousMonth].' '.$previousYear,
|
||||
'bulan_terpilih' => $monthNames[$bulan].' '.$tahun,
|
||||
'bulan_lalu_bruto' => $previousBruto,
|
||||
'bulan_terpilih_bruto' => $currentBruto,
|
||||
'bulan_lalu_pajak' => $previousPajak,
|
||||
'bulan_terpilih_pajak' => $currentPajak,
|
||||
'bulan_lalu_netto' => $previousNetto,
|
||||
'bulan_terpilih_netto' => $currentNetto,
|
||||
'selisih_bruto' => $currentBruto - $previousBruto,
|
||||
'selisih_pajak' => $currentPajak - $previousPajak,
|
||||
'selisih_netto' => $currentNetto - $previousNetto,
|
||||
]),
|
||||
];
|
||||
})->filter(function ($row) use ($arah) {
|
||||
$values = [$row['selisih_bruto'], $row['selisih_pajak'], $row['selisih_netto']];
|
||||
|
||||
return match ($arah) {
|
||||
'diatas' => collect($values)->contains(fn ($value) => $value > 0),
|
||||
'dibawah' => collect($values)->contains(fn ($value) => $value < 0),
|
||||
default => collect($values)->contains(fn ($value) => $value != 0),
|
||||
};
|
||||
})->values();
|
||||
|
||||
return DataTables::of($comparison)
|
||||
->editColumn('jenis_pegawai', fn ($row) => $row['jenis_pegawai'] === 'dosen' ? 'Dosen' : ($row['jenis_pegawai'] === 'tendik' ? 'Tendik' : '-'))
|
||||
->editColumn('selisih_bruto', fn ($row) => 'Rp. '.number_format($row['selisih_bruto'], 2, ',', '.'))
|
||||
->editColumn('selisih_pajak', fn ($row) => 'Rp. '.number_format($row['selisih_pajak'], 2, ',', '.'))
|
||||
->editColumn('selisih_netto', fn ($row) => 'Rp. '.number_format($row['selisih_netto'], 2, ',', '.'))
|
||||
->rawColumns(['detail'])
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bangun rincian per riwayat pembayaran untuk modal Detail Selisih: tiap entri riwayat
|
||||
* (P1 yang pernah dibayarkan) dibandingkan dengan P1 saat ini (P1 yang seharusnya
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Rekapitulasi;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class P1Selisih extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'rekapitulasi.p1_selisih';
|
||||
|
||||
protected $fillable = [
|
||||
'tahun',
|
||||
'bulan',
|
||||
'nip',
|
||||
'nama',
|
||||
'jenis_pegawai',
|
||||
'id_unit_kerja',
|
||||
'nama_unit_kerja',
|
||||
'id_unit_pembayaran',
|
||||
'pangkat',
|
||||
'golongan',
|
||||
'nama_jabatan_fungsional',
|
||||
'grade_jabatan_fungsional',
|
||||
'gaji_jabatan_fungsional',
|
||||
'nama_jabatan_tugas_tambahan',
|
||||
'grade_jabatan_tugas_tambahan',
|
||||
'gaji_jabatan_tugas_tambahan',
|
||||
'selisih_bruto',
|
||||
'selisih_pajak',
|
||||
'selisih_netto',
|
||||
'keterangan',
|
||||
'npwp',
|
||||
'nomor_rekening',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'selisih_bruto' => 'decimal:2',
|
||||
'selisih_pajak' => 'decimal:2',
|
||||
'selisih_netto' => 'decimal:2',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -290,12 +290,19 @@ class DawaiService
|
||||
}
|
||||
|
||||
public function getDataP1(?string $jenisPegawai, int $tahun, int $bulan, ?int $unit)
|
||||
{
|
||||
$response = $this->getDataP1Response($jenisPegawai, $tahun, $bulan, $unit);
|
||||
|
||||
return $response['data'] ?? [];
|
||||
}
|
||||
|
||||
public function getDataP1Response(?string $jenisPegawai, int $tahun, int $bulan, ?int $unit): array
|
||||
{
|
||||
try {
|
||||
$response = $this->client->get("api/v1/psatu/$tahun/$bulan/?id_unit=$unit&jenis_pegawai=$jenisPegawai");
|
||||
$data = json_decode($response->getBody()->getContents(), true)['data'];
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
return $data;
|
||||
return is_array($data) ? $data : [];
|
||||
} catch (Throwable $th) {
|
||||
Log::error('DAWAI : '.$th->getMessage());
|
||||
throw new Error($th->getMessage(), 500);
|
||||
@@ -303,12 +310,19 @@ class DawaiService
|
||||
}
|
||||
|
||||
public function getDataP1Selisih(?string $jenisPegawai, int $tahun, int $bulan, ?int $unit)
|
||||
{
|
||||
$response = $this->getDataP1SelisihResponse($jenisPegawai, $tahun, $bulan, $unit);
|
||||
|
||||
return $response['data'] ?? [];
|
||||
}
|
||||
|
||||
public function getDataP1SelisihResponse(?string $jenisPegawai, int $tahun, int $bulan, ?int $unit): array
|
||||
{
|
||||
try {
|
||||
$response = $this->client->get("api/v1/psatu/$tahun/$bulan/?id_unit=$unit&jenis_pegawai=$jenisPegawai&selisih=true");
|
||||
$data = json_decode($response->getBody()->getContents(), true)['data'];
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
return $data;
|
||||
return is_array($data) ? $data : [];
|
||||
} catch (Throwable $th) {
|
||||
Log::error('DAWAI : '.$th->getMessage());
|
||||
throw new Error($th->getMessage(), 500);
|
||||
|
||||
@@ -11,9 +11,13 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::connection('pgsql')->table('rekapitulasi.p1', function (Blueprint $table) {
|
||||
$table->string('jenis_pegawai')->nullable()->after('nama');
|
||||
});
|
||||
$schema = Schema::connection('pgsql');
|
||||
|
||||
if (! $schema->hasColumn('rekapitulasi.p1', 'jenis_pegawai')) {
|
||||
$schema->table('rekapitulasi.p1', function (Blueprint $table) {
|
||||
$table->string('jenis_pegawai')->nullable()->after('nama');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,8 +25,12 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::connection('pgsql')->table('rekapitulasi.p1', function (Blueprint $table) {
|
||||
$table->dropColumn('jenis_pegawai');
|
||||
});
|
||||
$schema = Schema::connection('pgsql');
|
||||
|
||||
if ($schema->hasColumn('rekapitulasi.p1', 'jenis_pegawai')) {
|
||||
$schema->table('rekapitulasi.p1', function (Blueprint $table) {
|
||||
$table->dropColumn('jenis_pegawai');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('rekapitulasi.p1_selisih', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('tahun');
|
||||
$table->integer('bulan');
|
||||
$table->string('nip');
|
||||
$table->string('nama');
|
||||
$table->string('jenis_pegawai')->nullable();
|
||||
$table->integer('id_unit_kerja');
|
||||
$table->string('nama_unit_kerja');
|
||||
$table->integer('id_unit_pembayaran');
|
||||
$table->string('pangkat')->nullable();
|
||||
$table->string('golongan')->nullable();
|
||||
$table->string('nama_jabatan_fungsional')->nullable();
|
||||
$table->string('grade_jabatan_fungsional')->nullable();
|
||||
$table->decimal('gaji_jabatan_fungsional', 16, 2)->nullable();
|
||||
$table->string('nama_jabatan_tugas_tambahan')->nullable();
|
||||
$table->string('grade_jabatan_tugas_tambahan')->nullable();
|
||||
$table->decimal('gaji_jabatan_tugas_tambahan', 16, 2)->nullable();
|
||||
$table->decimal('selisih_bruto', 16, 2)->default(0);
|
||||
$table->decimal('selisih_pajak', 16, 2)->default(0);
|
||||
$table->decimal('selisih_netto', 16, 2)->default(0);
|
||||
$table->string('keterangan')->nullable();
|
||||
$table->string('npwp')->nullable();
|
||||
$table->string('nomor_rekening')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['tahun', 'bulan', 'nip', 'id_unit_pembayaran']);
|
||||
$table->index(['tahun', 'bulan', 'id_unit_pembayaran']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('rekapitulasi.p1_selisih');
|
||||
}
|
||||
};
|
||||
@@ -369,7 +369,7 @@
|
||||
</li>
|
||||
@endcanany
|
||||
|
||||
@canany(['Baca Presensi', 'Baca Presensi Honorer'])
|
||||
{{-- @canany(['Baca Presensi', 'Baca Presensi Honorer'])
|
||||
<li class="side-nav-item si-pengajuan-presensi">
|
||||
<a data-bs-toggle="collapse" href="#sidebarPengajuanPresensi" aria-expanded="false"
|
||||
aria-controls="sidebarPengajuanPresensi" class="side-nav-link ni-pengajuan-presensi">
|
||||
@@ -399,7 +399,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
@endcanany
|
||||
@endcanany --}}
|
||||
|
||||
{{-- @canany(['Baca Pengajuan Aktivitas'])
|
||||
<li class="side-nav-item si-pengajuan-aktivitas">
|
||||
|
||||
@@ -13,23 +13,27 @@
|
||||
}
|
||||
|
||||
#p1 tbody td.nama-col .text-truncate,
|
||||
#p1-selisih tbody td.nama-col .text-truncate {
|
||||
#p1-selisih tbody td.nama-col .text-truncate,
|
||||
#p1-perbandingan tbody td.nama-col .text-truncate {
|
||||
max-width: 220px;
|
||||
}
|
||||
|
||||
#p1 tbody td.nama-col > div,
|
||||
#p1-selisih tbody td.nama-col > div {
|
||||
#p1-selisih tbody td.nama-col > div,
|
||||
#p1-perbandingan tbody td.nama-col > div {
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
#p1 tbody td,
|
||||
#p1-selisih tbody td {
|
||||
#p1-selisih tbody td,
|
||||
#p1-perbandingan tbody td {
|
||||
padding-top: 0.5rem;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
#p1 tbody td.unit-col,
|
||||
#p1-selisih tbody td.unit-col {
|
||||
#p1-selisih tbody td.unit-col,
|
||||
#p1-perbandingan tbody td.unit-col {
|
||||
max-width: 160px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
@@ -40,10 +44,34 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#p1-perbandingan tbody tr {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#detailSelisihP1Modal .bg-tosca {
|
||||
background-color: #b2f2e5 !important;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#detailPerbandinganP1Modal #detail-perbandingan-bulan-lalu {
|
||||
background-color: var(--ct-danger) !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
#detailPerbandinganP1Modal #detail-perbandingan-bulan-terpilih {
|
||||
background-color: var(--ct-primary) !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
#detailPerbandinganP1Modal #detail-perbandingan-selisih {
|
||||
background-color: var(--ct-dark) !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
#p1 .nominal-diff {
|
||||
color: #7c3aed !important;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
@endsection
|
||||
|
||||
@@ -145,6 +173,10 @@
|
||||
<button class="nav-link rounded-0" id="selisih-tab" data-bs-toggle="tab"
|
||||
data-bs-target="#selisih-tab-pane" type="button" role="tab">Selisih</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link rounded-0" id="perbandingan-tab" data-bs-toggle="tab"
|
||||
data-bs-target="#perbandingan-tab-pane" type="button" role="tab">Perbandingan</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- Tab Content -->
|
||||
@@ -193,6 +225,31 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Perbandingan Tab -->
|
||||
<div class="tab-pane fade" id="perbandingan-tab-pane" role="tabpanel" tabindex="0">
|
||||
<div class="d-flex gap-2 mb-3">
|
||||
<select name="arah_perbandingan" id="arah_perbandingan" class="form-select select2"
|
||||
data-placeholder="Pilih Arah Selisih" style="max-width: 250px;">
|
||||
<option value="">Semua Perubahan</option>
|
||||
<option value="diatas">Di atas 0</option>
|
||||
<option value="dibawah">Di bawah 0</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered w-100 dt-styled" id="p1-perbandingan">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Pegawai</th>
|
||||
<th>Unit Kerja</th>
|
||||
<th class="text-center">Selisih Bruto</th>
|
||||
<th class="text-center">Selisih Pajak</th>
|
||||
<th class="text-center">Selisih Netto</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -227,39 +284,91 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="detailPerbandinganP1Modal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-primary text-white">
|
||||
<h5 class="modal-title">Detail Perbandingan P1</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<h6 class="fw-bold mb-2">Informasi Pegawai</h6>
|
||||
<table class="table table-sm table-bordered mb-3">
|
||||
<tbody>
|
||||
<tr><th width="35%">Nama</th><td id="detail-perbandingan-nama">-</td></tr>
|
||||
<tr><th>NIP</th><td id="detail-perbandingan-nip">-</td></tr>
|
||||
<tr><th>Unit Kerja</th><td id="detail-perbandingan-unit">-</td></tr>
|
||||
<tr><th>Jenis Pegawai</th><td id="detail-perbandingan-jenis">-</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h6 class="fw-bold mb-2">Perbandingan Pembayaran</h6>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-bordered mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Komponen</th>
|
||||
<th id="detail-perbandingan-bulan-lalu" class="bg-danger text-white">Bulan Lalu</th>
|
||||
<th id="detail-perbandingan-bulan-terpilih" class="bg-primary text-white">Bulan Ini</th>
|
||||
<th id="detail-perbandingan-selisih">Selisih</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><th>Bruto</th><td id="detail-perbandingan-lalu-bruto">-</td><td id="detail-perbandingan-terpilih-bruto">-</td><td id="detail-perbandingan-selisih-bruto">-</td></tr>
|
||||
<tr><th>Pajak</th><td id="detail-perbandingan-lalu-pajak">-</td><td id="detail-perbandingan-terpilih-pajak">-</td><td id="detail-perbandingan-selisih-pajak">-</td></tr>
|
||||
<tr><th>Netto</th><td id="detail-perbandingan-lalu-netto">-</td><td id="detail-perbandingan-terpilih-netto">-</td><td id="detail-perbandingan-selisih-netto">-</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
||||
@section('js')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var table, tableSelisih;
|
||||
var table, tableSelisih, tablePerbandingan;
|
||||
var hideUnitKerja = {{ ($team && isset($team->unit_kerja_id) && $team->unit_kerja_id >= 1 && $team->unit_kerja_id <= 9) ? 'true' : 'false' }};
|
||||
|
||||
// Tab Main aktif secara default, jadi sembunyikan tombol export Selisih di awal
|
||||
$('a.export-selisih').hide();
|
||||
|
||||
function renderRupiah(data) {
|
||||
function renderRupiah(data, differs) {
|
||||
var diffClass = differs ? ' nominal-diff' : '';
|
||||
if (!data) {
|
||||
return '<div class="d-flex justify-content-between gap-1 nominal-cell"><span>Rp.</span><span>0,00</span></div>';
|
||||
return '<div class="d-flex justify-content-between gap-1 nominal-cell' + diffClass + '"><span>Rp.</span><span>0,00</span></div>';
|
||||
}
|
||||
var parts = data.split(' ');
|
||||
var number = parts.slice(1).join(' ');
|
||||
return '<div class="d-flex justify-content-between gap-1 nominal-cell"><span>Rp.</span><span>' + number + '</span></div>';
|
||||
return '<div class="d-flex justify-content-between gap-1 nominal-cell' + diffClass + '"><span>Rp.</span><span>' + number + '</span></div>';
|
||||
}
|
||||
|
||||
function formatRupiahValue(value) {
|
||||
return 'Rp. ' + Number(value || 0).toLocaleString('id-ID', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2
|
||||
});
|
||||
}
|
||||
|
||||
function renderJenisPegawaiTag(jenis) {
|
||||
var config = {
|
||||
'Dosen': { color: 'var(--ct-primary)', rgb: 'var(--ct-primary-rgb)', icon: 'uil-user-graduate' },
|
||||
'Tendik': { color: '#fd7e14', rgb: '253, 126, 20', icon: 'uil-briefcase-alt' }
|
||||
'dosen': { color: 'var(--ct-primary)', rgb: 'var(--ct-primary-rgb)', icon: 'uil-user-graduate' },
|
||||
'tendik': { color: '#fd7e14', rgb: '253, 126, 20', icon: 'uil-briefcase-alt' }
|
||||
};
|
||||
var c = config[jenis];
|
||||
var normalizedJenis = (jenis || '').toString().toLowerCase();
|
||||
var c = config[normalizedJenis];
|
||||
if (!c) {
|
||||
return '';
|
||||
}
|
||||
return '<small class="d-inline-block fw-bold" style="padding: 1px 18px 1px 6px; color: ' +
|
||||
c.color + '; background: linear-gradient(to right, rgba(' + c.rgb + ', 0.25), rgba(' + c.rgb +
|
||||
', 0)); clip-path: polygon(0 0, 100% 0, calc(100% - 20px) 100%, 0 100%);"><i class="' + c.icon +
|
||||
'"></i> ' + jenis.toUpperCase() + '</small>';
|
||||
'"></i> ' + normalizedJenis.toUpperCase() + '</small>';
|
||||
}
|
||||
|
||||
function renderJenisSelisihBadge(jenis) {
|
||||
@@ -280,11 +389,13 @@
|
||||
|
||||
// Toggle export buttons berdasarkan tab aktif
|
||||
$('#p1Tabs button[data-bs-toggle="tab"]').on('shown.bs.tab', function(e) {
|
||||
var isMain = $(e.target).attr('id') === 'main-tab';
|
||||
var tabId = $(e.target).attr('id');
|
||||
var isMain = tabId === 'main-tab';
|
||||
$('a.export').toggle(isMain);
|
||||
$('a.export-selisih').toggle(!isMain);
|
||||
$('a.export-selisih').toggle(tabId === 'selisih-tab');
|
||||
if (isMain && table) { table.columns.adjust().draw(); }
|
||||
if (!isMain && tableSelisih) { tableSelisih.columns.adjust().draw(); }
|
||||
if (tabId === 'selisih-tab' && tableSelisih) { tableSelisih.columns.adjust().draw(); }
|
||||
if (tabId === 'perbandingan-tab' && tablePerbandingan) { tablePerbandingan.columns.adjust().draw(); }
|
||||
});
|
||||
|
||||
table = $('#p1').DataTable({
|
||||
@@ -327,23 +438,23 @@
|
||||
{ data: 'nama_jtt', name: 'nama_jtt', orderable: false, searchable: false, visible: false },
|
||||
{
|
||||
data: 'harga_p1', name: 'harga_p1', orderable: false, searchable: false, width: '11%',
|
||||
render: function(data, type) {
|
||||
render: function(data, type, row) {
|
||||
if (type !== 'display') { return data; }
|
||||
return renderRupiah(data);
|
||||
return renderRupiah(data, row.harga_p1_diff);
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'pajak_p1', name: 'pajak_p1', orderable: false, searchable: false, width: '11%',
|
||||
render: function(data, type) {
|
||||
render: function(data, type, row) {
|
||||
if (type !== 'display') { return data; }
|
||||
return renderRupiah(data);
|
||||
return renderRupiah(data, row.pajak_p1_diff);
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'harga_p1_setelah_pajak', name: 'harga_p1_setelah_pajak', orderable: false, searchable: false, width: '11%',
|
||||
render: function(data, type) {
|
||||
render: function(data, type, row) {
|
||||
if (type !== 'display') { return data; }
|
||||
return renderRupiah(data);
|
||||
return renderRupiah(data, row.harga_p1_setelah_pajak_diff);
|
||||
}
|
||||
},
|
||||
],
|
||||
@@ -355,6 +466,7 @@
|
||||
$('select#jenis_pegawai, select#unit_kerja, select#tahun, select#bulan, #include_pppk_2025').on('change', function() {
|
||||
table.ajax.reload();
|
||||
tableSelisih.ajax.reload();
|
||||
if (tablePerbandingan) { tablePerbandingan.ajax.reload(); }
|
||||
});
|
||||
|
||||
// Filter Jenis Selisih hanya berlaku untuk tabel Selisih
|
||||
@@ -362,6 +474,10 @@
|
||||
tableSelisih.ajax.reload();
|
||||
});
|
||||
|
||||
$('#arah_perbandingan').on('change', function() {
|
||||
tablePerbandingan.ajax.reload();
|
||||
});
|
||||
|
||||
$('a.export').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var button = $(this);
|
||||
@@ -491,6 +607,72 @@
|
||||
language: { processing: "<div class='spinner'></div> Sedang Memuat..." }
|
||||
});
|
||||
|
||||
tablePerbandingan = $('#p1-perbandingan').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
orderCellsTop: true,
|
||||
ajax: {
|
||||
url: "{{ route('remunerasi.p1.data-perbandingan') }}",
|
||||
data: function(d) {
|
||||
@if (!$team || !isset($team->unit_kerja_id) || $team->unit_kerja_id === null || $team->unit_kerja_id === 0)
|
||||
d.unit = $('select#unit_kerja').val();
|
||||
@endif
|
||||
d.jenis_pegawai = $('select#jenis_pegawai').val();
|
||||
d.tahun = $('select#tahun').val();
|
||||
d.bulan = $('select#bulan').val();
|
||||
d.arah = $('#arah_perbandingan').val();
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
data: 'nama', name: 'nama', className: 'nama-col', width: '25%',
|
||||
render: function(data, type, row) {
|
||||
if (type !== 'display') { return data; }
|
||||
return '<div>' +
|
||||
'<div class="fw-semibold text-truncate" title="' + (data || '-') + '">' + (data || '-') + '</div>' +
|
||||
'<div class="text-muted small font-monospace">' + (row.nip || '-') + '</div>' +
|
||||
'<div class="mt-1">' + renderJenisPegawaiTag(row.jenis_pegawai) + '</div>' +
|
||||
'</div>';
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'nama_unit_kerja', name: 'nama_unit_kerja', className: 'unit-col', visible: !hideUnitKerja,
|
||||
render: function(data, type) {
|
||||
if (type === 'display') { return '<span title="' + (data || '') + '">' + (data || '') + '</span>'; }
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ data: 'selisih_bruto', name: 'selisih_bruto', orderable: false, searchable: false, width: '14%', render: function(data) { return renderRupiah(data); } },
|
||||
{ data: 'selisih_pajak', name: 'selisih_pajak', orderable: false, searchable: false, width: '14%', render: function(data) { return renderRupiah(data); } },
|
||||
{ data: 'selisih_netto', name: 'selisih_netto', orderable: false, searchable: false, width: '14%', render: function(data) { return renderRupiah(data); } }
|
||||
],
|
||||
order: [[0, 'asc']],
|
||||
language: { processing: "<div class='spinner'></div> Sedang Memuat..." }
|
||||
});
|
||||
|
||||
$('#p1-perbandingan tbody').on('click', 'tr', function() {
|
||||
var row = tablePerbandingan.row($(this).closest('tr')).data();
|
||||
if (!row || !row.detail) { return; }
|
||||
|
||||
var detail = {};
|
||||
try { detail = JSON.parse(row.detail); } catch(e) { return; }
|
||||
|
||||
$('#detail-perbandingan-nama').text(row.nama || '-');
|
||||
$('#detail-perbandingan-nip').text(row.nip || '-');
|
||||
$('#detail-perbandingan-unit').text(row.nama_unit_kerja || '-');
|
||||
$('#detail-perbandingan-jenis').text(row.jenis_pegawai || '-');
|
||||
$('#detail-perbandingan-bulan-lalu').text(detail.bulan_lalu || 'Bulan Lalu');
|
||||
$('#detail-perbandingan-bulan-terpilih').text(detail.bulan_terpilih || 'Bulan Ini');
|
||||
|
||||
['bruto', 'pajak', 'netto'].forEach(function(field) {
|
||||
$('#detail-perbandingan-lalu-' + field).text(formatRupiahValue(detail['bulan_lalu_' + field]));
|
||||
$('#detail-perbandingan-terpilih-' + field).text(formatRupiahValue(detail['bulan_terpilih_' + field]));
|
||||
$('#detail-perbandingan-selisih-' + field).text(formatRupiahValue(detail['selisih_' + field]));
|
||||
});
|
||||
|
||||
new bootstrap.Modal(document.getElementById('detailPerbandinganP1Modal')).show();
|
||||
});
|
||||
|
||||
$('#p1-selisih tbody').on('click', 'tr', function() {
|
||||
var row = tableSelisih.row($(this).closest('tr')).data();
|
||||
if (!row) { return; }
|
||||
|
||||
@@ -15,6 +15,7 @@ Route::middleware('permission:Baca Pembayaran')->prefix('/remunerasi')->name('re
|
||||
Route::get('/', [P1Controller::class, 'index'])->name('index');
|
||||
Route::get('/data', [P1Controller::class, 'data'])->name('data');
|
||||
Route::get('/data-selisih', [P1Controller::class, 'dataSelisih'])->name('data-selisih');
|
||||
Route::get('/data-perbandingan', [P1Controller::class, 'dataPerbandingan'])->name('data-perbandingan');
|
||||
Route::get('/export', [P1Controller::class, 'export'])->name('export');
|
||||
Route::get('/export-selisih', [P1Controller::class, 'exportSelisih'])->name('export-selisih');
|
||||
Route::post('/logs', [P1Controller::class, 'logs'])->name('logs');
|
||||
|
||||
+2
@@ -10,6 +10,7 @@ return array(
|
||||
'App\\Console\\Commands\\Pegawai\\UpdateJabatanPegawaiCommand' => $baseDir . '/app/Console/Commands/Pegawai/UpdateJabatanPegawaiCommand.php',
|
||||
'App\\Console\\Commands\\Publikasi\\GetDataPublikasiCommand' => $baseDir . '/app/Console/Commands/Publikasi/GetDataPublikasiCommand.php',
|
||||
'App\\Console\\Commands\\Rekapitulasi\\RekapP1Command' => $baseDir . '/app/Console/Commands/Rekapitulasi/RekapP1Command.php',
|
||||
'App\\Console\\Commands\\Rekapitulasi\\RekapP1SelisihCommand' => $baseDir . '/app/Console/Commands/Rekapitulasi/RekapP1SelisihCommand.php',
|
||||
'App\\Console\\Commands\\Rekapitulasi\\RekapP2Command' => $baseDir . '/app/Console/Commands/Rekapitulasi/RekapP2Command.php',
|
||||
'App\\Console\\Commands\\Rekapitulasi\\RekapPublikasiCommand' => $baseDir . '/app/Console/Commands/Rekapitulasi/RekapPublikasiCommand.php',
|
||||
'App\\Console\\Commands\\Rekapitulasi\\RekapR13Command' => $baseDir . '/app/Console/Commands/Rekapitulasi/RekapR13Command.php',
|
||||
@@ -157,6 +158,7 @@ return array(
|
||||
'App\\Models\\DokSiremun\\Syarat' => $baseDir . '/app/Models/DokSiremun/Syarat.php',
|
||||
'App\\Models\\DokSiremun\\UnitKerja' => $baseDir . '/app/Models/DokSiremun/UnitKerja.php',
|
||||
'App\\Models\\Rekapitulasi\\P1' => $baseDir . '/app/Models/Rekapitulasi/P1.php',
|
||||
'App\\Models\\Rekapitulasi\\P1Selisih' => $baseDir . '/app/Models/Rekapitulasi/P1Selisih.php',
|
||||
'App\\Models\\Rekapitulasi\\R13' => $baseDir . '/app/Models/Rekapitulasi/R13.php',
|
||||
'App\\Models\\Rekapitulasi\\THR' => $baseDir . '/app/Models/Rekapitulasi/THR.php',
|
||||
'App\\Models\\Siska\\AnggotaSk' => $baseDir . '/app/Models/Siska/AnggotaSk.php',
|
||||
|
||||
Vendored
+2
@@ -666,6 +666,7 @@ class ComposerStaticInite35c9d807d4c3b727d8b29698aada6ae
|
||||
'App\\Console\\Commands\\Pegawai\\UpdateJabatanPegawaiCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Pegawai/UpdateJabatanPegawaiCommand.php',
|
||||
'App\\Console\\Commands\\Publikasi\\GetDataPublikasiCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Publikasi/GetDataPublikasiCommand.php',
|
||||
'App\\Console\\Commands\\Rekapitulasi\\RekapP1Command' => __DIR__ . '/../..' . '/app/Console/Commands/Rekapitulasi/RekapP1Command.php',
|
||||
'App\\Console\\Commands\\Rekapitulasi\\RekapP1SelisihCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Rekapitulasi/RekapP1SelisihCommand.php',
|
||||
'App\\Console\\Commands\\Rekapitulasi\\RekapP2Command' => __DIR__ . '/../..' . '/app/Console/Commands/Rekapitulasi/RekapP2Command.php',
|
||||
'App\\Console\\Commands\\Rekapitulasi\\RekapPublikasiCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Rekapitulasi/RekapPublikasiCommand.php',
|
||||
'App\\Console\\Commands\\Rekapitulasi\\RekapR13Command' => __DIR__ . '/../..' . '/app/Console/Commands/Rekapitulasi/RekapR13Command.php',
|
||||
@@ -813,6 +814,7 @@ class ComposerStaticInite35c9d807d4c3b727d8b29698aada6ae
|
||||
'App\\Models\\DokSiremun\\Syarat' => __DIR__ . '/../..' . '/app/Models/DokSiremun/Syarat.php',
|
||||
'App\\Models\\DokSiremun\\UnitKerja' => __DIR__ . '/../..' . '/app/Models/DokSiremun/UnitKerja.php',
|
||||
'App\\Models\\Rekapitulasi\\P1' => __DIR__ . '/../..' . '/app/Models/Rekapitulasi/P1.php',
|
||||
'App\\Models\\Rekapitulasi\\P1Selisih' => __DIR__ . '/../..' . '/app/Models/Rekapitulasi/P1Selisih.php',
|
||||
'App\\Models\\Rekapitulasi\\R13' => __DIR__ . '/../..' . '/app/Models/Rekapitulasi/R13.php',
|
||||
'App\\Models\\Rekapitulasi\\THR' => __DIR__ . '/../..' . '/app/Models/Rekapitulasi/THR.php',
|
||||
'App\\Models\\Siska\\AnggotaSk' => __DIR__ . '/../..' . '/app/Models/Siska/AnggotaSk.php',
|
||||
|
||||
Reference in New Issue
Block a user