Penambahan Simulasi +12 Dosen Beta

This commit is contained in:
Ariyutta
2026-09-04 00:03:06 +07:00
parent 06623bff34
commit bff8a1c1b1
3 changed files with 128 additions and 17 deletions
+47 -3
View File
@@ -27,16 +27,20 @@ class SimulasiJabatanExport implements WithMultipleSheets
/** Nilai filter khusus "Universitas" = seluruh unit non-fakultas. */
public const UNIT_UNIVERSITAS = 99;
/** Poin Grade 14-17 statis untuk simulasi dosen bergrade < 14. */
public const GRADE_1417_POIN = 12;
public function __construct(
private readonly int $periode,
private readonly ?int $bulan = null,
private readonly ?string $jenis = null,
private readonly int|string|null $unitKerjaId = null,
private readonly bool $grade12 = false,
) {}
public function sheets(): array
{
$rows = SimulasiJabatanSheet::rows($this->periode, $this->bulan, $this->unitKerjaId, $this->jenis);
$rows = SimulasiJabatanSheet::rows($this->periode, $this->bulan, $this->unitKerjaId, $this->jenis, false, $this->grade12);
$sheets = [new SimulasiJabatanSheet('All', $rows)];
foreach ($rows->groupBy(fn ($row) => $row['unit_kerja'] ?: 'Tanpa Unit Kerja') as $unit => $unitRows) {
$sheets[] = new SimulasiJabatanSheet($unit, $unitRows->values());
@@ -49,7 +53,7 @@ class SimulasiJabatanSheet implements FromCollection, WithHeadings, WithStyles,
{
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): Collection
public static function rows(int $periode, ?int $bulan = null, int|string|null $unitKerjaId = null, ?string $jenis = null, bool $raw = false, bool $grade12 = false): Collection
{
$q = JabatanPegawaiDetailPoin::query()->select([
'verifikator.jabatan_pegawais.nip', 'verifikator.poin_per_bulans.jabatan_pegawai_detail_id',
@@ -130,7 +134,7 @@ class SimulasiJabatanSheet implements FromCollection, WithHeadings, WithStyles,
return collect($dp ?: [])->sum(fn ($u) => collect($u['adhoc_kegiatan'] ?? [])->sum('poin_p2'));
}));
return $source->map(function ($r) use ($excel, $details, $monthCounts, $jfPrices, $jttPrices, $remunSums, $adhocByNip, $raw) {
return $source->map(function ($r) use ($excel, $details, $monthCounts, $jfPrices, $jttPrices, $remunSums, $adhocByNip, $raw, $grade12) {
$d = $details->get($r->jabatan_pegawai_detail_id);
$price = function ($id, $model, $period) use ($jfPrices, $jttPrices) { return $id ? (float) (($model === JabatanFungsionalRiwayat::class ? $jfPrices : $jttPrices)->get($id.'-'.$period)?->harga ?? 0) : 0; };
$jf374=$price($d?->jabatan_fungsional_id, JabatanFungsionalRiwayat::class,374); $jf377=$price($d?->jabatan_fungsional_id,JabatanFungsionalRiwayat::class,377);
@@ -158,8 +162,17 @@ class SimulasiJabatanSheet implements FromCollection, WithHeadings, WithStyles,
$remun = $remunSums->get($d?->jabatan_pegawai_id);
$hasRemun = $remun && (float) $remun->p2_bruto_sum > 0;
$final374 = $final377 = $finalExcel = 0.0;
$final374g12 = $final377g12 = $finalExcelg12 = 0.0;
$adhocP2 = (float) ($adhocByNip[$r->nip] ?? 0) * 660000 / 6;
// Simulasi opsional: dosen yang TIDAK punya grade 14-17 pada jabatan
// fungsional MAUPUN jabatan tugas tambahan → tambahkan 12 poin (statis)
// ke total poin P2 sebelum dibagi JF/JTT, sama seperti pegawai grade 14-17.
$gradeJfVal = $jfPrices->get(($d?->jabatan_fungsional_id).'-377')?->grade ?? $jfPrices->get(($d?->jabatan_fungsional_id).'-374')?->grade;
$gradeJttVal = $jttPrices->get(($d?->jabatan_tambahan_id).'-377')?->grade ?? $jttPrices->get(($d?->jabatan_tambahan_id).'-374')?->grade;
$is1417 = fn ($g) => is_numeric($g) && (int) $g >= 14;
$eligibleGrade12 = ! $isTendik && ! $is1417($gradeJfVal) && ! $is1417($gradeJttVal);
if ($isTendik) {
// Tendik tidak memakai model pecah JF/JTT lama sama sekali.
$jf = $jtt = 0.0;
@@ -186,6 +199,20 @@ class SimulasiJabatanSheet implements FromCollection, WithHeadings, WithStyles,
$final374 = $adhocPortion377 + $jfPortion377 * $ratio($jf374, $jf377) + $jttPortion377 * $ratio($jtt374, $jtt377);
$finalExcel = $adhocPortion377 + $jfPortion377 * $ratio($jfExcel, $jf377) + $jttPortion377 * $ratio($jttExcel, $jtt377);
// Tambahan poin grade (opsional) — dihargai pada tarif dasar jabatan.
$jfPoinDelta = $jttPoinDelta = 0.0;
if ($eligibleGrade12) {
$poinP2NonAdhocSim = max(0.0, $poinP2 + SimulasiJabatanExport::GRADE_1417_POIN - $adhocPoin);
$jttPoinSim = $hasJtt ? ($isTendik ? $poinP2NonAdhocSim : min(28.0, $poinP2NonAdhocSim)) : 0.0;
$jfPoinSim = max(0.0, $poinP2NonAdhocSim - $jttPoinSim);
$jfPoinDelta = $jfPoinSim - $jfPoin;
$jttPoinDelta = $jttPoinSim - $jttPoin;
}
$incAt = fn ($hjf, $hjtt) => ($jfPoinDelta * $hjf + $jttPoinDelta * $hjtt) / 6 * $months;
$final377g12 = $final377 + $incAt($jf377, $jtt377);
$final374g12 = $final374 + $incAt($jf374, $jtt374);
$finalExcelg12 = $finalExcel + $incAt($jfExcel, $jttExcel);
// Kolom JF / JTT pada sheet Excel (porsi masing-masing).
$jf = $jfPoin;
$jtt = $jttPoin;
@@ -195,6 +222,18 @@ class SimulasiJabatanSheet implements FromCollection, WithHeadings, WithStyles,
$p2jtt374 = round($jttPortion377 * $ratio($jtt374, $jtt377) / $months, 2);
$p2jfExcel = round(($adhocPortion377 + $jfPortion377 * $ratio($jfExcel, $jf377)) / $months, 2);
$p2jttExcel= round($jttPortion377 * $ratio($jttExcel, $jtt377) / $months, 2);
// Bila simulasi grade aktif, terapkan tambahan poin ke kolom sheet Excel.
if ($grade12 && $eligibleGrade12) {
$jf = $jfPoin + $jfPoinDelta;
$jtt = $jttPoin + $jttPoinDelta;
$p2jf377 += round($jfPoinDelta * $jf377 / 6, 2);
$p2jtt377 += round($jttPoinDelta * $jtt377 / 6, 2);
$p2jf374 += round($jfPoinDelta * $jf374 / 6, 2);
$p2jtt374 += round($jttPoinDelta * $jtt374 / 6, 2);
$p2jfExcel += round($jfPoinDelta * $jfExcel / 6, 2);
$p2jttExcel+= round($jttPoinDelta * $jttExcel / 6, 2);
}
}
$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];
@@ -217,6 +256,11 @@ class SimulasiJabatanSheet implements FromCollection, WithHeadings, WithStyles,
$out['raw_p2_final_374'] = $final374;
$out['raw_p2_final_377'] = $final377;
$out['raw_p2_final_excel'] = $finalExcel;
// Varian simulasi "+12 poin grade" untuk dosen bergrade < 14.
$out['raw_grade12_eligible'] = $eligibleGrade12;
$out['raw_p2_final_374_g12'] = $final374g12;
$out['raw_p2_final_377_g12'] = $final377g12;
$out['raw_p2_final_excel_g12'] = $finalExcelg12;
}
return $out;
});