Perbaikan Selisih Beta 1.0 dan Export
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Perhitungan\Remunerasi;
|
||||
|
||||
use App\Exports\ThrExport;
|
||||
use App\Exports\ThrSelisihExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Verifikator\Team;
|
||||
use App\Models\Verifikator\UnitKerja;
|
||||
@@ -106,6 +107,7 @@ class THRController extends Controller
|
||||
|
||||
$jenisPegawai = $request->jenis_pegawai ?? '';
|
||||
$tahun = $request->tahun ?? $tahunNow;
|
||||
$jenisSelisih = $request->jenis_selisih ?? '';
|
||||
|
||||
// Create cache key for selisih data
|
||||
$cacheKey = "thr_selisih_data_{$jenisPegawai}_{$tahun}_{$unit}";
|
||||
@@ -118,8 +120,16 @@ class THRController extends Controller
|
||||
});
|
||||
|
||||
// Filter data yang total_thr nya tidak nol
|
||||
$filteredData = collect($data)->filter(function ($item) {
|
||||
return ($item['total_thr'] ?? 0) > 0;
|
||||
$filteredData = collect($data)->filter(function ($item) use ($jenisSelisih) {
|
||||
if (($item['total_thr'] ?? 0) <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($jenisSelisih !== '' && $this->resolveJenisSelisih($item) !== $jenisSelisih) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
})->sortBy('nama')->values();
|
||||
|
||||
return DataTables::of($filteredData)
|
||||
@@ -136,20 +146,23 @@ class THRController extends Controller
|
||||
->editColumn('jenis_pegawai', function ($row) {
|
||||
return $row['jenis_pegawai'] == 'dosen' ? 'Dosen' : ($row['jenis_pegawai'] == 'tendik' ? 'Tendik' : '-');
|
||||
})
|
||||
->addColumn('jenis_selisih', function ($row) {
|
||||
return $this->jenisSelisihLabel($this->resolveJenisSelisih($row));
|
||||
})
|
||||
->addColumn('selisih_thr_formatted', function ($row) {
|
||||
$value = $row['selisih_total_thr'] ?? 0;
|
||||
$value = $row['selisih_thr'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
->addColumn('selisih_pajak_formatted', function ($row) {
|
||||
$totalThr = $row['selisih_total_thr'] ?? 0;
|
||||
$totalThrSetelahPajak = $row['selisih_total_thr_setelah_pajak'] ?? 0;
|
||||
$value = $totalThr - $totalThrSetelahPajak;
|
||||
$selisihBruto = $row['selisih_thr'] ?? 0;
|
||||
$selisihNetto = $row['selisih_thr_netto'] ?? 0;
|
||||
$value = $selisihBruto - $selisihNetto;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
->addColumn('selisih_total_formatted', function ($row) {
|
||||
$value = $row['selisih_total_thr_setelah_pajak'] ?? 0;
|
||||
$value = $row['selisih_thr_netto'] ?? 0;
|
||||
|
||||
return 'Rp. '.number_format($value, 2, ',', '.');
|
||||
})
|
||||
@@ -170,6 +183,36 @@ class THRController extends Controller
|
||||
->make();
|
||||
}
|
||||
|
||||
/**
|
||||
* API Dawai untuk THR tidak mengirim status selisih eksplisit (beda dengan P1 yang punya
|
||||
* status_selisih_harga_p1), jadi jenis selisih diturunkan dari tanda selisih bruto:
|
||||
* negatif = kekurangan (pegawai dibayar kurang), positif = kelebihan, nol/tidak ada = null.
|
||||
*/
|
||||
private function resolveJenisSelisih(array $item): ?string
|
||||
{
|
||||
$selisihBruto = $item['selisih_thr'] ?? 0;
|
||||
|
||||
// Kalau bruto tidak ada bedanya tapi netto ada (mis. karena golongan berubah sehingga
|
||||
// tarif pajak ikut berubah), pakai selisih netto supaya kasus selisih murni pajak tetap
|
||||
// kelihatan di kolom/filter Keterangan, bukan malah tampil '-'.
|
||||
$selisih = $selisihBruto != 0 ? $selisihBruto : ($item['selisih_thr_netto'] ?? 0);
|
||||
|
||||
return match (true) {
|
||||
$selisih < 0 => 'kekurangan',
|
||||
$selisih > 0 => 'kelebihan',
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
private function jenisSelisihLabel(?string $jenisSelisih): string
|
||||
{
|
||||
return match ($jenisSelisih) {
|
||||
'kekurangan' => 'Kekurangan',
|
||||
'kelebihan' => 'Kelebihan',
|
||||
default => '-',
|
||||
};
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$tahunNow = Carbon::now()->format('Y');
|
||||
@@ -256,7 +299,7 @@ class THRController extends Controller
|
||||
$filename = "THR_Selisih_{$tahun}{$unitName}.xlsx";
|
||||
|
||||
// Send original unit value to DAWAI API (99 for Universitas)
|
||||
return Excel::download(new ThrExport($jenisPegawai, $tahun, $unit, 'selisih'), $filename);
|
||||
return Excel::download(new ThrSelisihExport($jenisPegawai, $tahun, $unit), $filename);
|
||||
}
|
||||
|
||||
public function logs(Request $request)
|
||||
|
||||
Reference in New Issue
Block a user