first commit

This commit is contained in:
Saufi
2026-06-24 20:32:14 +08:00
commit 10fb30ad69
201 changed files with 21356 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Services;
use App\Models\AppSetting;
use App\Models\ChecklistTemplate;
use App\Models\ReportingCycle;
use Illuminate\Support\Carbon;
class ReportingCycleService
{
/**
* Bina atribut kitaran daripada tahun pembaharuan.
* Peraturan perniagaan:
* - reporting_year = renewal_year - 2 (cth: pembaharuan 2028 => pelaporan 2026)
* - tempoh pelaporan: 1 Jan - 31 Dis tahun pelaporan
* - tarikh tutup lalai: hari/bulan yang dikonfigur JPP, tahun (renewal_year - 1)
*/
public function buildAttributes(int $renewalYear, ?string $cutOffDate = null): array
{
$reportingYear = ReportingCycle::reportingYearFor($renewalYear);
$cutOffDay = (int) AppSetting::get('default_cut_off_day', 1);
$cutOffMonth = (int) AppSetting::get('default_cut_off_month', 12);
// Pembaharuan dibuat sebelum/pada 1 Disember tahun sebelum pembaharuan.
$defaultCutOff = Carbon::create($renewalYear - 1, $cutOffMonth, $cutOffDay);
return [
'reporting_year' => $reportingYear,
'period_start' => Carbon::create($reportingYear, 1, 1),
'period_end' => Carbon::create($reportingYear, 12, 31),
'cut_off_date' => $cutOffDate ? Carbon::parse($cutOffDate) : $defaultCutOff,
'checklist_template_id' => ChecklistTemplate::activeTemplate()?->id,
];
}
}