64 lines
2.8 KiB
PHP
64 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Traits\PerhitunganKegiatan;
|
|
|
|
trait KalkulasiPoinSemesterAntaraTrait
|
|
{
|
|
protected function calculateSemesterAntaraPoin($kegiatans, $detail, &$totalPoin, $limitPoinRemun)
|
|
{
|
|
foreach (['semester_antara_homebase', 'semester_antara_luar_homebase'] as $type) {
|
|
foreach ($kegiatans[$detail->bulan][$type] as $semesterAntara) {
|
|
$poin = $this->calculatePoinRemunerasi($semesterAntara->poin_total, $totalPoin, $limitPoinRemun, $detail);
|
|
|
|
$totalPoin[$detail->bulan]['poin_remunerasi']['kegiatan'] += $poin;
|
|
$semesterAntara->poin_remunerasi = $poin;
|
|
$semesterAntara->nama_kegiatan = "Semester Antara: Mengajar $semesterAntara->nama_mk Kelas $semesterAntara->kelas";
|
|
}
|
|
}
|
|
}
|
|
|
|
protected function calculateSemesterAntaraP2($kegiatans, $detail, &$poinP1)
|
|
{
|
|
foreach (['semester_antara_luar_homebase', 'semester_antara_homebase'] as $type) {
|
|
foreach ($kegiatans[$detail->bulan][$type]->reverse() as $semesterAntara) {
|
|
$semesterAntara->poin_p2 = $semesterAntara->poin_remunerasi;
|
|
|
|
if ($poinP1[$detail->bulan] - $semesterAntara->poin_remunerasi > 0) {
|
|
$semesterAntara->poin_p2 = 0;
|
|
$poinP1[$detail->bulan] -= $semesterAntara->poin_remunerasi;
|
|
} else {
|
|
if ($poinP1[$detail->bulan] > 0) {
|
|
$semesterAntara->poin_p2 = $semesterAntara->poin_remunerasi - $poinP1[$detail->bulan];
|
|
$poinP1[$detail->bulan] -= $semesterAntara->poin_remunerasi;
|
|
$poinP1[$detail->bulan] = $poinP1[$detail->bulan] < 0 ? 0 : $poinP1[$detail->bulan];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected function processSemesterAntaraUnits($kegiatans, $detail, &$units)
|
|
{
|
|
foreach (['semester_antara_homebase', 'semester_antara_luar_homebase'] as $type) {
|
|
foreach ($kegiatans[$detail->bulan][$type] as $semesterAntara) {
|
|
$unit = $semesterAntara['id_unit_kerja'] - 1;
|
|
|
|
if ($detail->unit_pembayaran_id === 0 || $unit > 9 || $unit <= 0) {
|
|
$unit = 0;
|
|
}
|
|
|
|
if (!isset($units[$unit])) {
|
|
$units[$unit] = [
|
|
'total_poin_remunerasi' => 0,
|
|
'total_poin_p2' => 0,
|
|
'kegiatans' => [],
|
|
];
|
|
}
|
|
|
|
$units[$unit]['total_poin_remunerasi'] += $semesterAntara->poin_remunerasi;
|
|
$units[$unit]['total_poin_p2'] += $semesterAntara->poin_p2;
|
|
$units[$unit]['kegiatans'][] = $semesterAntara;
|
|
}
|
|
}
|
|
}
|
|
} |