feat: [esign] 근로계약서 사원 불러오기 시 주소, 생년월일, 계약일 자동 반영

- 주민등록번호에서 출생년도/월/일 분리 (세기 자동 판별)
- 입사일 기반 계약일, 근로계약시작일, 연봉계약시작일 자동 반영
- 연봉계약종료일은 입사일 + 1년으로 계산
- 사원 주소, 계약자 이름 자동 매핑 추가
This commit is contained in:
김보곤
2026-03-11 16:18:37 +09:00
parent 3e8b730242
commit 4bb03fffcb
2 changed files with 66 additions and 12 deletions

View File

@@ -98,18 +98,35 @@ public function searchEmployees(Request $request): JsonResponse
$employees = $query->limit(20)->get();
$data = $employees->map(fn ($emp) => [
'id' => $emp->id,
'name' => $emp->user?->name,
'phone' => $emp->user?->phone,
'email' => $emp->user?->email,
'department' => $emp->department?->name,
'position' => $emp->position_label,
'job_title' => $emp->job_title_label,
'address' => $emp->address,
'hire_date' => $emp->hire_date,
'birth_year' => $emp->resident_number ? ('19'.substr($emp->resident_number, 0, 2)) : null,
]);
$data = $employees->map(function ($emp) {
$rn = $emp->resident_number;
$birthYear = null;
$birthMonth = null;
$birthDay = null;
if ($rn && strlen($rn) >= 7) {
$genderDigit = substr($rn, 6, 1);
$prefix = in_array($genderDigit, ['3', '4', '7', '8']) ? '20' : '19';
$birthYear = $prefix.substr($rn, 0, 2);
$birthMonth = substr($rn, 2, 2);
$birthDay = substr($rn, 4, 2);
}
return [
'id' => $emp->id,
'name' => $emp->user?->name,
'phone' => $emp->user?->phone,
'email' => $emp->user?->email,
'department' => $emp->department?->name,
'position' => $emp->position_label,
'job_title' => $emp->job_title_label,
'address' => $emp->address,
'hire_date' => $emp->hire_date,
'birth_year' => $birthYear,
'birth_month' => $birthMonth,
'birth_day' => $birthDay,
];
});
return response()->json(['success' => true, 'data' => $data]);
}