Compare commits

...

1 Commits

Author SHA1 Message Date
Ariyutta 977e8d7de8 Perubahan NIP petik kolom NIP, NPWP, dan Nomor Rekening semua export excel 2026-09-21 12:41:30 +07:00
12 changed files with 220 additions and 44 deletions
@@ -0,0 +1,54 @@
<?php
namespace App\Exports\Concerns;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
use PhpOffice\PhpSpreadsheet\Cell\DataType;
use PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder;
/**
* Memaksa kolom tertentu (NIP, NPWP, Nomor Rekening, dll) disimpan sebagai
* string murni di level cell, sebagai pengganti trik prefix tanda petik (')
* yang dulu dipakai supaya Excel tidak mengubah nilainya jadi angka.
*
* Trik prefix ('123...) membuat tanda petik ikut tampil di beberapa
* aplikasi/versi Excel. Sedangkan hanya mengandalkan columnFormats('@') saja
* tidak cukup untuk NIP 18 digit, karena PhpSpreadsheet sudah membulatkannya
* jadi notasi ilmiah (presisi double ~15-17 digit) sebelum format diterapkan.
*/
trait ForcesTextColumns
{
/**
* Kolom yang HARUS selalu disimpan sebagai teks (mis. NPWP, Nomor Rekening).
*/
protected function alwaysTextColumns(): array
{
return [];
}
/**
* Kolom berisi NIP. Hanya dipaksa jadi teks kalau nilainya memang angka
* panjang (NIP asli), supaya baris Total/ringkasan yang kadang memakai
* kolom yang sama tetap dianggap angka oleh Excel.
*/
protected function nipColumns(): array
{
return [];
}
public function bindValue(Cell $cell, $value)
{
$column = $cell->getColumn();
$isNipValue = in_array($column, $this->nipColumns(), true)
&& is_string($value) && strlen($value) >= 15 && ctype_digit($value);
if (($isNipValue || in_array($column, $this->alwaysTextColumns(), true)) && $value !== '') {
$cell->setValueExplicit((string) $value, DataType::TYPE_STRING);
return true;
}
return (new DefaultValueBinder)->bindValue($cell, $value);
}
}
+11 -2
View File
@@ -2,6 +2,7 @@
namespace App\Exports; namespace App\Exports;
use App\Exports\Concerns\ForcesTextColumns;
use App\Models\Rekapitulasi\P1; use App\Models\Rekapitulasi\P1;
use App\Models\Rekapitulasi\R13; use App\Models\Rekapitulasi\R13;
use App\Models\Rekapitulasi\THR; use App\Models\Rekapitulasi\THR;
@@ -11,6 +12,7 @@ use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting; use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithMultipleSheets; use Maatwebsite\Excel\Concerns\WithMultipleSheets;
@@ -33,8 +35,15 @@ class DetailTotalRemunerasiExport implements WithMultipleSheets
} }
} }
class DetailTotalRemunerasiSheet implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithHeadings, WithMapping, WithStyles, WithTitle class DetailTotalRemunerasiSheet implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithCustomValueBinder, WithHeadings, WithMapping, WithStyles, WithTitle
{ {
use ForcesTextColumns;
protected function nipColumns(): array
{
return ['C'];
}
protected array $bulanNamas = [ protected array $bulanNamas = [
1 => 'Januari', 2 => 'Februari', 3 => 'Maret', 4 => 'April', 1 => 'Januari', 2 => 'Februari', 3 => 'Maret', 4 => 'April',
5 => 'Mei', 6 => 'Juni', 7 => 'Juli', 8 => 'Agustus', 5 => 'Mei', 6 => 'Juni', 7 => 'Juli', 8 => 'Agustus',
@@ -124,7 +133,7 @@ class DetailTotalRemunerasiSheet implements FromCollection, ShouldAutoSize, With
return [ return [
$row['no'], $row['no'],
$row['nama'], $row['nama'],
$row['nip'] !== '' ? "'".$row['nip'] : '', $row['nip'],
$row['pangkat'], $row['pangkat'],
$row['golongan'], $row['golongan'],
$row['jabatan_fungsional'], $row['jabatan_fungsional'],
+17 -5
View File
@@ -3,11 +3,13 @@
namespace App\Exports; namespace App\Exports;
use App\Exports\Concerns\EnrichesJabatanData; use App\Exports\Concerns\EnrichesJabatanData;
use App\Exports\Concerns\ForcesTextColumns;
use App\Models\Rekapitulasi\P1; use App\Models\Rekapitulasi\P1;
use Carbon\Carbon; use Carbon\Carbon;
use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting; use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithMultipleSheets; use Maatwebsite\Excel\Concerns\WithMultipleSheets;
@@ -52,9 +54,19 @@ class P1Export implements WithMultipleSheets
} }
} }
class P1MonthlySheet implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithHeadings, WithMapping, WithStyles, WithTitle class P1MonthlySheet implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithCustomValueBinder, WithHeadings, WithMapping, WithStyles, WithTitle
{ {
use EnrichesJabatanData; use EnrichesJabatanData, ForcesTextColumns;
protected function nipColumns(): array
{
return ['C'];
}
protected function alwaysTextColumns(): array
{
return ['P', 'Q'];
}
protected $jenisPegawai; protected $jenisPegawai;
@@ -130,7 +142,7 @@ class P1MonthlySheet implements FromCollection, ShouldAutoSize, WithColumnFormat
return (object) [ return (object) [
'no' => 0, // Temporary, will be set after sorting 'no' => 0, // Temporary, will be set after sorting
'nip' => "'".$pegawai->nip, 'nip' => $pegawai->nip,
'nama_lengkap' => $pegawai->nama, 'nama_lengkap' => $pegawai->nama,
'pangkat' => $pegawai->pangkat, 'pangkat' => $pegawai->pangkat,
'golongan' => $pegawai->golongan, 'golongan' => $pegawai->golongan,
@@ -145,8 +157,8 @@ class P1MonthlySheet implements FromCollection, ShouldAutoSize, WithColumnFormat
'harga_p1' => $pegawai->gaji_yang_dibayarkan, 'harga_p1' => $pegawai->gaji_yang_dibayarkan,
'pajak_p1' => $pegawai->pph21, 'pajak_p1' => $pegawai->pph21,
'harga_p1_setelah_pajak' => $pegawai->gaji_bersih, 'harga_p1_setelah_pajak' => $pegawai->gaji_bersih,
'npwp' => $pegawai->npwp ? "'".str_replace(['-', '.'], '', $pegawai->npwp) : '', 'npwp' => $pegawai->npwp ? str_replace(['-', '.'], '', $pegawai->npwp) : '',
'nomor_rekening' => $pegawai->nomor_rekening ? "'".$pegawai->nomor_rekening : '', 'nomor_rekening' => $pegawai->nomor_rekening ?: '',
]; ];
}); });
+18 -4
View File
@@ -2,11 +2,13 @@
namespace App\Exports; namespace App\Exports;
use App\Exports\Concerns\ForcesTextColumns;
use App\Models\Rekapitulasi\P1; use App\Models\Rekapitulasi\P1;
use Carbon\Carbon; use Carbon\Carbon;
use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting; use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithMultipleSheets; use Maatwebsite\Excel\Concerns\WithMultipleSheets;
@@ -50,8 +52,20 @@ class P1PerbandinganExport implements WithMultipleSheets
} }
} }
class P1PerbandinganMonthlySheet implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithHeadings, WithMapping, WithStyles, WithTitle class P1PerbandinganMonthlySheet implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithCustomValueBinder, WithHeadings, WithMapping, WithStyles, WithTitle
{ {
use ForcesTextColumns;
protected function nipColumns(): array
{
return ['C'];
}
protected function alwaysTextColumns(): array
{
return ['Q', 'R'];
}
protected $jenisPegawai; protected $jenisPegawai;
protected $tahun; protected $tahun;
@@ -153,7 +167,7 @@ class P1PerbandinganMonthlySheet implements FromCollection, ShouldAutoSize, With
return (object) [ return (object) [
'no' => 0, 'no' => 0,
'nip' => "'".$cleanNip, 'nip' => $cleanNip,
'nama_lengkap' => $acuan->nama ?? '-', 'nama_lengkap' => $acuan->nama ?? '-',
'pangkat' => $acuan->pangkat ?? '-', 'pangkat' => $acuan->pangkat ?? '-',
'golongan' => $acuan->golongan ?? '-', 'golongan' => $acuan->golongan ?? '-',
@@ -168,8 +182,8 @@ class P1PerbandinganMonthlySheet implements FromCollection, ShouldAutoSize, With
'selisih_pajak' => $selisihPajak, 'selisih_pajak' => $selisihPajak,
'selisih_netto' => $selisihNetto, 'selisih_netto' => $selisihNetto,
'keterangan' => $this->keteranganLabel($selisihNetto), 'keterangan' => $this->keteranganLabel($selisihNetto),
'npwp' => $acuan->npwp ? "'".str_replace(['-', '.'], '', $acuan->npwp) : '', 'npwp' => $acuan->npwp ? str_replace(['-', '.'], '', $acuan->npwp) : '',
'nomor_rekening' => $acuan->nomor_rekening ? "'".$acuan->nomor_rekening : '', 'nomor_rekening' => $acuan->nomor_rekening ? $acuan->nomor_rekening : '',
'nama_unit' => $acuan->nama_unit_kerja ?? '-', 'nama_unit' => $acuan->nama_unit_kerja ?? '-',
]; ];
})->filter(function ($row) { })->filter(function ($row) {
+17 -5
View File
@@ -3,11 +3,13 @@
namespace App\Exports; namespace App\Exports;
use App\Exports\Concerns\EnrichesJabatanData; use App\Exports\Concerns\EnrichesJabatanData;
use App\Exports\Concerns\ForcesTextColumns;
use App\Services\DawaiService; use App\Services\DawaiService;
use Carbon\Carbon; use Carbon\Carbon;
use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting; use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithMultipleSheets; use Maatwebsite\Excel\Concerns\WithMultipleSheets;
@@ -52,9 +54,19 @@ class P1SelisihExport implements WithMultipleSheets
} }
} }
class P1SelisihMonthlySheet implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithHeadings, WithMapping, WithStyles, WithTitle class P1SelisihMonthlySheet implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithCustomValueBinder, WithHeadings, WithMapping, WithStyles, WithTitle
{ {
use EnrichesJabatanData; use EnrichesJabatanData, ForcesTextColumns;
protected function nipColumns(): array
{
return ['C'];
}
protected function alwaysTextColumns(): array
{
return ['Q', 'R'];
}
protected $jenisPegawai; protected $jenisPegawai;
@@ -141,7 +153,7 @@ class P1SelisihMonthlySheet implements FromCollection, ShouldAutoSize, WithColum
return (object) [ return (object) [
'no' => 0, // Temporary, will be set after sorting 'no' => 0, // Temporary, will be set after sorting
'nip' => $item['nip'], // Keep original NIP with quotes 'nip' => $cleanNip,
'nama_lengkap' => $item['nama_lengkap'], 'nama_lengkap' => $item['nama_lengkap'],
'pangkat' => $pangkat, 'pangkat' => $pangkat,
'golongan' => $golongan, 'golongan' => $golongan,
@@ -156,8 +168,8 @@ class P1SelisihMonthlySheet implements FromCollection, ShouldAutoSize, WithColum
'selisih_pajak' => ($item['selisih_harga_p1'] ?? 0) - ($item['selisih_harga_p1_setelah_pajak'] ?? 0), 'selisih_pajak' => ($item['selisih_harga_p1'] ?? 0) - ($item['selisih_harga_p1_setelah_pajak'] ?? 0),
'selisih_netto' => $item['selisih_harga_p1_setelah_pajak'] ?? 0, 'selisih_netto' => $item['selisih_harga_p1_setelah_pajak'] ?? 0,
'keterangan' => $this->jenisSelisihLabel($item), 'keterangan' => $this->jenisSelisihLabel($item),
'npwp' => $pegawai && $pegawai->npwp ? "'".str_replace(['-', '.'], '', $pegawai->npwp) : '', 'npwp' => $pegawai && $pegawai->npwp ? str_replace(['-', '.'], '', $pegawai->npwp) : '',
'nomor_rekening' => $pegawai && $pegawai->nomor_rekening ? "'".$pegawai->nomor_rekening : '', 'nomor_rekening' => $pegawai && $pegawai->nomor_rekening ? $pegawai->nomor_rekening : '',
'nama_unit' => $item['nama_unit'], 'nama_unit' => $item['nama_unit'],
]; ];
}); });
+18 -4
View File
@@ -2,6 +2,7 @@
namespace App\Exports; namespace App\Exports;
use App\Exports\Concerns\ForcesTextColumns;
use App\Helpers\JenjangPendidikanHelper; use App\Helpers\JenjangPendidikanHelper;
use App\Models\Verifikator\JabatanFungsionalRiwayat; use App\Models\Verifikator\JabatanFungsionalRiwayat;
use App\Models\Verifikator\JabatanPegawai; use App\Models\Verifikator\JabatanPegawai;
@@ -11,6 +12,7 @@ use App\Models\Verifikator\View\Pegawai;
use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting; use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles; use Maatwebsite\Excel\Concerns\WithStyles;
@@ -19,10 +21,22 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Fill; use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class P2Export implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithHeadings, WithMapping, WithStyles, WithTitle class P2Export implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithCustomValueBinder, WithHeadings, WithMapping, WithStyles, WithTitle
{ {
use ForcesTextColumns;
private const FAKULTAS_IDS = [1, 2, 3, 4, 5, 6, 7, 8, 9]; private const FAKULTAS_IDS = [1, 2, 3, 4, 5, 6, 7, 8, 9];
protected function nipColumns(): array
{
return ['C'];
}
protected function alwaysTextColumns(): array
{
return ['P', 'Q'];
}
public function __construct( public function __construct(
private readonly ?int $periode, private readonly ?int $periode,
private readonly mixed $unitKerjaId, private readonly mixed $unitKerjaId,
@@ -153,7 +167,7 @@ class P2Export implements FromCollection, ShouldAutoSize, WithColumnFormatting,
return (object) [ return (object) [
'no' => $index + 1, 'no' => $index + 1,
'nama' => $row->nama, 'nama' => $row->nama,
'nip' => $row->nip ? "'".$cleanNip : '', 'nip' => $row->nip ? $cleanNip : '',
'pangkat' => $pangkat, 'pangkat' => $pangkat,
'golongan' => $golongan, 'golongan' => $golongan,
'nama_jafung' => $namaJafung, 'nama_jafung' => $namaJafung,
@@ -166,8 +180,8 @@ class P2Export implements FromCollection, ShouldAutoSize, WithColumnFormatting,
'total_p2_bruto' => $row->total_p2_bruto ?? 0, 'total_p2_bruto' => $row->total_p2_bruto ?? 0,
'total_p2_pajak' => $row->total_p2_pajak ?? 0, 'total_p2_pajak' => $row->total_p2_pajak ?? 0,
'total_p2_netto' => $row->total_p2_netto ?? 0, 'total_p2_netto' => $row->total_p2_netto ?? 0,
'npwp' => $pegawai && $pegawai->npwp ? "'".str_replace(['-', '.'], '', $pegawai->npwp) : '', 'npwp' => $pegawai && $pegawai->npwp ? str_replace(['-', '.'], '', $pegawai->npwp) : '',
'nomor_rekening' => $pegawai && $pegawai->nomor_rekening ? "'".$pegawai->nomor_rekening : '', 'nomor_rekening' => $pegawai && $pegawai->nomor_rekening ? $pegawai->nomor_rekening : '',
'nama_unit' => $row->nama_unit ?? '', 'nama_unit' => $row->nama_unit ?? '',
]; ];
}); });
+17 -5
View File
@@ -3,10 +3,12 @@
namespace App\Exports; namespace App\Exports;
use App\Exports\Concerns\EnrichesJabatanData; use App\Exports\Concerns\EnrichesJabatanData;
use App\Exports\Concerns\ForcesTextColumns;
use App\Services\DawaiService; use App\Services\DawaiService;
use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting; use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles; use Maatwebsite\Excel\Concerns\WithStyles;
@@ -14,9 +16,19 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Fill; use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class R13Export implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithHeadings, WithMapping, WithStyles class R13Export implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithCustomValueBinder, WithHeadings, WithMapping, WithStyles
{ {
use EnrichesJabatanData; use EnrichesJabatanData, ForcesTextColumns;
protected function nipColumns(): array
{
return ['C'];
}
protected function alwaysTextColumns(): array
{
return ['P', 'Q'];
}
protected $jenisPegawai; protected $jenisPegawai;
@@ -55,7 +67,7 @@ class R13Export implements FromCollection, ShouldAutoSize, WithColumnFormatting,
return (object) [ return (object) [
'no' => 0, // Temporary, will be set after sorting 'no' => 0, // Temporary, will be set after sorting
'nip' => $item['nip'] ? "'".trim($item['nip'], "'") : '', 'nip' => $item['nip'] ? trim($item['nip'], "'") : '',
'nama' => $item['nama'] ?? $item['nama_lengkap'] ?? '', 'nama' => $item['nama'] ?? $item['nama_lengkap'] ?? '',
'pangkat' => $pangkat, 'pangkat' => $pangkat,
'golongan' => $golongan, 'golongan' => $golongan,
@@ -69,8 +81,8 @@ class R13Export implements FromCollection, ShouldAutoSize, WithColumnFormatting,
'gaji_r13' => $totalR13, 'gaji_r13' => $totalR13,
'pajak_r13' => $totalR13 - $totalR13SetelahPajak, 'pajak_r13' => $totalR13 - $totalR13SetelahPajak,
'gaji_r13_bersih' => $totalR13SetelahPajak, 'gaji_r13_bersih' => $totalR13SetelahPajak,
'npwp' => $pegawai && $pegawai->npwp ? "'".str_replace(['-', '.'], '', $pegawai->npwp) : '', 'npwp' => $pegawai && $pegawai->npwp ? str_replace(['-', '.'], '', $pegawai->npwp) : '',
'nomor_rekening' => $pegawai && $pegawai->nomor_rekening ? "'".$pegawai->nomor_rekening : '', 'nomor_rekening' => $pegawai && $pegawai->nomor_rekening ? $pegawai->nomor_rekening : '',
'nama_unit' => $item['nama_unit'] ?? '', 'nama_unit' => $item['nama_unit'] ?? '',
]; ];
}); });
+17 -5
View File
@@ -3,10 +3,12 @@
namespace App\Exports; namespace App\Exports;
use App\Exports\Concerns\EnrichesJabatanData; use App\Exports\Concerns\EnrichesJabatanData;
use App\Exports\Concerns\ForcesTextColumns;
use App\Services\DawaiService; use App\Services\DawaiService;
use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting; use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles; use Maatwebsite\Excel\Concerns\WithStyles;
@@ -14,9 +16,19 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Fill; use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class R13SelisihExport implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithHeadings, WithMapping, WithStyles class R13SelisihExport implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithCustomValueBinder, WithHeadings, WithMapping, WithStyles
{ {
use EnrichesJabatanData; use EnrichesJabatanData, ForcesTextColumns;
protected function nipColumns(): array
{
return ['C'];
}
protected function alwaysTextColumns(): array
{
return ['P', 'Q'];
}
protected $jenisPegawai; protected $jenisPegawai;
@@ -54,7 +66,7 @@ class R13SelisihExport implements FromCollection, ShouldAutoSize, WithColumnForm
return (object) [ return (object) [
'no' => 0, // Temporary, will be set after sorting 'no' => 0, // Temporary, will be set after sorting
'nip' => $item['nip'] ? "'".trim($item['nip'], "'") : '', 'nip' => $item['nip'] ? trim($item['nip'], "'") : '',
'nama' => $item['nama'] ?? $item['nama_lengkap'] ?? '', 'nama' => $item['nama'] ?? $item['nama_lengkap'] ?? '',
'pangkat' => $pangkat, 'pangkat' => $pangkat,
'golongan' => $golongan, 'golongan' => $golongan,
@@ -69,8 +81,8 @@ class R13SelisihExport implements FromCollection, ShouldAutoSize, WithColumnForm
'selisih_pajak' => $selisihBruto - $selisihNetto, 'selisih_pajak' => $selisihBruto - $selisihNetto,
'selisih_netto' => $selisihNetto, 'selisih_netto' => $selisihNetto,
'keterangan' => $this->keteranganLabel($selisihBruto, $selisihNetto), 'keterangan' => $this->keteranganLabel($selisihBruto, $selisihNetto),
'npwp' => $pegawai && $pegawai->npwp ? "'".str_replace(['-', '.'], '', $pegawai->npwp) : '', 'npwp' => $pegawai && $pegawai->npwp ? str_replace(['-', '.'], '', $pegawai->npwp) : '',
'nomor_rekening' => $pegawai && $pegawai->nomor_rekening ? "'".$pegawai->nomor_rekening : '', 'nomor_rekening' => $pegawai && $pegawai->nomor_rekening ? $pegawai->nomor_rekening : '',
'nama_unit' => $item['nama_unit'] ?? '', 'nama_unit' => $item['nama_unit'] ?? '',
]; ];
}); });
+5 -1
View File
@@ -7,6 +7,7 @@ use App\Models\Verifikator\Periode;
use App\Models\Verifikator\Team; use App\Models\Verifikator\Team;
use App\Models\Verifikator\View\Pegawai; use App\Models\Verifikator\View\Pegawai;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use PhpOffice\PhpSpreadsheet\Cell\DataType;
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Style\Border;
@@ -56,6 +57,9 @@ class RasioPoinKegiatanExport
$sheet->setCellValue($cell, $header); $sheet->setCellValue($cell, $header);
} }
// Kolom NIP Anggota sebagai teks, supaya NIP panjang tidak dibulatkan jadi notasi ilmiah
$sheet->getStyle('E:E')->getNumberFormat()->setFormatCode('@');
// Style headers // Style headers
$headerRange = 'A1:N1'; $headerRange = 'A1:N1';
$sheet->getStyle($headerRange)->applyFromArray([ $sheet->getStyle($headerRange)->applyFromArray([
@@ -146,7 +150,7 @@ class RasioPoinKegiatanExport
} }
// Set data anggota // Set data anggota
$sheet->setCellValue('E' . $row, "'" . $item['nip_anggota']); // Add quote to NIP $sheet->setCellValueExplicit('E' . $row, (string) $item['nip_anggota'], DataType::TYPE_STRING);
$sheet->setCellValue('F' . $row, $item['nama_anggota']); $sheet->setCellValue('F' . $row, $item['nama_anggota']);
$sheet->setCellValue('G' . $row, $item['unit_kerja_anggota']); $sheet->setCellValue('G' . $row, $item['unit_kerja_anggota']);
$sheet->setCellValue('H' . $row, $item['posisi']); $sheet->setCellValue('H' . $row, $item['posisi']);
+12 -3
View File
@@ -2,6 +2,7 @@
namespace App\Exports; namespace App\Exports;
use App\Exports\Concerns\ForcesTextColumns;
use App\Helpers\JenjangPendidikanHelper; use App\Helpers\JenjangPendidikanHelper;
use App\Models\Verifikator\JabatanFungsionalRiwayat; use App\Models\Verifikator\JabatanFungsionalRiwayat;
use App\Models\Verifikator\JabatanPegawaiDetail; use App\Models\Verifikator\JabatanPegawaiDetail;
@@ -11,6 +12,7 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMultipleSheets; use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Maatwebsite\Excel\Concerns\WithColumnFormatting; use Maatwebsite\Excel\Concerns\WithColumnFormatting;
@@ -68,8 +70,15 @@ class SimulasiJabatanExport implements WithMultipleSheets
} }
} }
class SimulasiJabatanSheet implements FromCollection, WithHeadings, WithStyles, ShouldAutoSize, WithTitle, WithColumnFormatting class SimulasiJabatanSheet implements FromCollection, WithHeadings, WithStyles, ShouldAutoSize, WithTitle, WithColumnFormatting, WithCustomValueBinder
{ {
use ForcesTextColumns;
protected function nipColumns(): array
{
return ['B'];
}
public function __construct(private readonly string $sheetTitle, private readonly Collection $items) {} public function __construct(private readonly string $sheetTitle, private readonly Collection $items) {}
public static function rows(int $periode, ?int $bulan = null, int|string|null $unitKerjaId = null, ?string $jenis = null, bool $raw = false, bool $grade12 = false, bool $splitUnit = false, ?string $jenjangPendidikan = null): Collection public static function rows(int $periode, ?int $bulan = null, int|string|null $unitKerjaId = null, ?string $jenis = null, bool $raw = false, bool $grade12 = false, bool $splitUnit = false, ?string $jenjangPendidikan = null): Collection
@@ -276,7 +285,7 @@ class SimulasiJabatanSheet implements FromCollection, WithHeadings, WithStyles,
} }
} }
$out = ['nama_pegawai'=>$r->nama_pegawai,'nip'=>"'".$r->nip,'unit_kerja'=>$r->unit_kerja ?: 'Tanpa Unit Kerja','jenis_pegawai'=>strtoupper($r->jenis_pegawai),'poin_jf'=>round($jf,2),'nama_jf'=>$d?->fungsional?->nama ?? '-','grade_jf'=>$jfPrices->get(($d?->jabatan_fungsional_id).'-377')?->grade ?? '-','harga_jf_374'=>$jf374,'p2_jf_374'=>$p2jf374,'total_p2_jf_374'=>$p2jf374*$months,'harga_jf_377'=>$jf377,'p2_jf_377'=>$p2jf377,'total_p2_jf_377'=>$p2jf377*$months,'harga_jf_excel'=>$jfExcel,'p2_jf_excel'=>$p2jfExcel,'total_p2_jf_excel'=>$p2jfExcel*$months,'poin_jtt'=>round($jtt,2),'nama_jtt'=>$d?->tambahan?->nama ?? '-','grade_jtt'=>$jttPrices->get(($d?->jabatan_tambahan_id).'-377')?->grade ?? '-','harga_jtt_374'=>$jtt374,'p2_jtt_374'=>$p2jtt374,'total_p2_jtt_374'=>$p2jtt374*$months,'harga_jtt_377'=>$jtt377,'p2_jtt_377'=>$p2jtt377,'total_p2_jtt_377'=>$p2jtt377*$months,'harga_jtt_excel'=>$jttExcel,'p2_jtt_excel'=>$p2jttExcel,'total_p2_jtt_excel'=>$p2jttExcel*$months]; $out = ['nama_pegawai'=>$r->nama_pegawai,'nip'=>$r->nip,'unit_kerja'=>$r->unit_kerja ?: 'Tanpa Unit Kerja','jenis_pegawai'=>strtoupper($r->jenis_pegawai),'poin_jf'=>round($jf,2),'nama_jf'=>$d?->fungsional?->nama ?? '-','grade_jf'=>$jfPrices->get(($d?->jabatan_fungsional_id).'-377')?->grade ?? '-','harga_jf_374'=>$jf374,'p2_jf_374'=>$p2jf374,'total_p2_jf_374'=>$p2jf374*$months,'harga_jf_377'=>$jf377,'p2_jf_377'=>$p2jf377,'total_p2_jf_377'=>$p2jf377*$months,'harga_jf_excel'=>$jfExcel,'p2_jf_excel'=>$p2jfExcel,'total_p2_jf_excel'=>$p2jfExcel*$months,'poin_jtt'=>round($jtt,2),'nama_jtt'=>$d?->tambahan?->nama ?? '-','grade_jtt'=>$jttPrices->get(($d?->jabatan_tambahan_id).'-377')?->grade ?? '-','harga_jtt_374'=>$jtt374,'p2_jtt_374'=>$p2jtt374,'total_p2_jtt_374'=>$p2jtt374*$months,'harga_jtt_377'=>$jtt377,'p2_jtt_377'=>$p2jtt377,'total_p2_jtt_377'=>$p2jtt377*$months,'harga_jtt_excel'=>$jttExcel,'p2_jtt_excel'=>$p2jttExcel,'total_p2_jtt_excel'=>$p2jttExcel*$months];
// Field mentah hanya untuk konsumen non-Excel (mis. tabel Simulasi Jabatan). // Field mentah hanya untuk konsumen non-Excel (mis. tabel Simulasi Jabatan).
// Jangan sertakan pada sheet ekspor karena akan menambah kolom. // Jangan sertakan pada sheet ekspor karena akan menambah kolom.
if ($raw) { if ($raw) {
@@ -344,7 +353,7 @@ class SimulasiJabatanSheet implements FromCollection, WithHeadings, WithStyles,
public function headings(): array { return ['Nama Pegawai','NIP','Unit Kerja','Jenis Pegawai','Poin P2 JF','Nama JF','Grade JF','Harga JF (374)','P2 JF (374)','Total P2 JF (374)','Harga JF (377)','P2 JF (377)','Total P2 JF (377)','Harga JF (Excel)','P2 JF (Excel)','Total P2 JF (Excel)','Poin P2 JTT','Nama JTT','Grade JTT','Harga JTT (374)','P2 JTT (374)','Total P2 JTT (374)','Harga JTT (377)','P2 JTT (377)','Total P2 JTT (377)','Harga JTT (Excel)','P2 JTT (Excel)','Total P2 JTT (Excel)']; } public function headings(): array { return ['Nama Pegawai','NIP','Unit Kerja','Jenis Pegawai','Poin P2 JF','Nama JF','Grade JF','Harga JF (374)','P2 JF (374)','Total P2 JF (374)','Harga JF (377)','P2 JF (377)','Total P2 JF (377)','Harga JF (Excel)','P2 JF (Excel)','Total P2 JF (Excel)','Poin P2 JTT','Nama JTT','Grade JTT','Harga JTT (374)','P2 JTT (374)','Total P2 JTT (374)','Harga JTT (377)','P2 JTT (377)','Total P2 JTT (377)','Harga JTT (Excel)','P2 JTT (Excel)','Total P2 JTT (Excel)']; }
public function columnFormats(): array public function columnFormats(): array
{ {
return array_fill_keys(['H','I','J','K','L','M','N','O','P','T','U','V','W','X','Y','Z','AA','AB'], '_([$Rp-421]* #,##0.00_);_([$Rp-421]* (#,##0.00);_([$Rp-421]* "-"??_);_(@_)'); return ['B' => '@'] + array_fill_keys(['H','I','J','K','L','M','N','O','P','T','U','V','W','X','Y','Z','AA','AB'], '_([$Rp-421]* #,##0.00_);_([$Rp-421]* (#,##0.00);_([$Rp-421]* "-"??_);_(@_)');
} }
public function title(): string { return mb_substr(str_replace(['\\', '/', '*', '?', ':', '[', ']'], '-', $this->sheetTitle), 0, 31); } public function title(): string { return mb_substr(str_replace(['\\', '/', '*', '?', ':', '[', ']'], '-', $this->sheetTitle), 0, 31); }
public function styles(Worksheet $sheet) { return [1=>['font'=>['bold'=>true,'color'=>['rgb'=>'FFFFFF']], 'fill'=>['fillType'=>Fill::FILL_SOLID,'startColor'=>['rgb'=>'20C997']]], $sheet->getHighestRow()=>['font'=>['bold'=>true]]]; } public function styles(Worksheet $sheet) { return [1=>['font'=>['bold'=>true,'color'=>['rgb'=>'FFFFFF']], 'fill'=>['fillType'=>Fill::FILL_SOLID,'startColor'=>['rgb'=>'20C997']]], $sheet->getHighestRow()=>['font'=>['bold'=>true]]]; }
+17 -5
View File
@@ -3,10 +3,12 @@
namespace App\Exports; namespace App\Exports;
use App\Exports\Concerns\EnrichesJabatanData; use App\Exports\Concerns\EnrichesJabatanData;
use App\Exports\Concerns\ForcesTextColumns;
use App\Services\DawaiService; use App\Services\DawaiService;
use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting; use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles; use Maatwebsite\Excel\Concerns\WithStyles;
@@ -14,9 +16,19 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Fill; use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class ThrExport implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithHeadings, WithMapping, WithStyles class ThrExport implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithCustomValueBinder, WithHeadings, WithMapping, WithStyles
{ {
use EnrichesJabatanData; use EnrichesJabatanData, ForcesTextColumns;
protected function nipColumns(): array
{
return ['C'];
}
protected function alwaysTextColumns(): array
{
return ['P', 'Q'];
}
protected $jenisPegawai; protected $jenisPegawai;
@@ -55,7 +67,7 @@ class ThrExport implements FromCollection, ShouldAutoSize, WithColumnFormatting,
return (object) [ return (object) [
'no' => 0, // Temporary, will be set after sorting 'no' => 0, // Temporary, will be set after sorting
'nip' => $item['nip'] ? "'".trim($item['nip'], "'") : '', 'nip' => $item['nip'] ? trim($item['nip'], "'") : '',
'nama' => $item['nama'] ?? $item['nama_lengkap'] ?? '', 'nama' => $item['nama'] ?? $item['nama_lengkap'] ?? '',
'pangkat' => $pangkat, 'pangkat' => $pangkat,
'golongan' => $golongan, 'golongan' => $golongan,
@@ -70,8 +82,8 @@ class ThrExport implements FromCollection, ShouldAutoSize, WithColumnFormatting,
'gaji_thr' => $totalThr, 'gaji_thr' => $totalThr,
'pajak_thr' => $totalThr - $totalThrSetelahPajak, 'pajak_thr' => $totalThr - $totalThrSetelahPajak,
'gaji_thr_bersih' => $totalThrSetelahPajak, 'gaji_thr_bersih' => $totalThrSetelahPajak,
'npwp' => $pegawai && $pegawai->npwp ? "'".str_replace(['-', '.'], '', $pegawai->npwp) : '', 'npwp' => $pegawai && $pegawai->npwp ? str_replace(['-', '.'], '', $pegawai->npwp) : '',
'nomor_rekening' => $pegawai && $pegawai->nomor_rekening ? "'".$pegawai->nomor_rekening : '', 'nomor_rekening' => $pegawai && $pegawai->nomor_rekening ? $pegawai->nomor_rekening : '',
]; ];
}); });
+17 -5
View File
@@ -3,10 +3,12 @@
namespace App\Exports; namespace App\Exports;
use App\Exports\Concerns\EnrichesJabatanData; use App\Exports\Concerns\EnrichesJabatanData;
use App\Exports\Concerns\ForcesTextColumns;
use App\Services\DawaiService; use App\Services\DawaiService;
use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting; use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles; use Maatwebsite\Excel\Concerns\WithStyles;
@@ -14,9 +16,19 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Fill; use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class ThrSelisihExport implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithHeadings, WithMapping, WithStyles class ThrSelisihExport implements FromCollection, ShouldAutoSize, WithColumnFormatting, WithCustomValueBinder, WithHeadings, WithMapping, WithStyles
{ {
use EnrichesJabatanData; use EnrichesJabatanData, ForcesTextColumns;
protected function nipColumns(): array
{
return ['C'];
}
protected function alwaysTextColumns(): array
{
return ['P', 'Q'];
}
protected $jenisPegawai; protected $jenisPegawai;
@@ -54,7 +66,7 @@ class ThrSelisihExport implements FromCollection, ShouldAutoSize, WithColumnForm
return (object) [ return (object) [
'no' => 0, // Temporary, will be set after sorting 'no' => 0, // Temporary, will be set after sorting
'nip' => $item['nip'] ? "'".trim($item['nip'], "'") : '', 'nip' => $item['nip'] ? trim($item['nip'], "'") : '',
'nama' => $item['nama'] ?? $item['nama_lengkap'] ?? '', 'nama' => $item['nama'] ?? $item['nama_lengkap'] ?? '',
'pangkat' => $pangkat, 'pangkat' => $pangkat,
'golongan' => $golongan, 'golongan' => $golongan,
@@ -69,8 +81,8 @@ class ThrSelisihExport implements FromCollection, ShouldAutoSize, WithColumnForm
'selisih_pajak' => $selisihBruto - $selisihNetto, 'selisih_pajak' => $selisihBruto - $selisihNetto,
'selisih_netto' => $selisihNetto, 'selisih_netto' => $selisihNetto,
'keterangan' => $this->keteranganLabel($selisihBruto, $selisihNetto), 'keterangan' => $this->keteranganLabel($selisihBruto, $selisihNetto),
'npwp' => $pegawai && $pegawai->npwp ? "'".str_replace(['-', '.'], '', $pegawai->npwp) : '', 'npwp' => $pegawai && $pegawai->npwp ? str_replace(['-', '.'], '', $pegawai->npwp) : '',
'nomor_rekening' => $pegawai && $pegawai->nomor_rekening ? "'".$pegawai->nomor_rekening : '', 'nomor_rekening' => $pegawai && $pegawai->nomor_rekening ? $pegawai->nomor_rekening : '',
'nama_unit' => $item['nama_unit'] ?? '', 'nama_unit' => $item['nama_unit'] ?? '',
]; ];
}); });