diff --git a/app/Http/Controllers/Api/Admin/HR/PayrollController.php b/app/Http/Controllers/Api/Admin/HR/PayrollController.php index 1d9dd834..b3724e2e 100644 --- a/app/Http/Controllers/Api/Admin/HR/PayrollController.php +++ b/app/Http/Controllers/Api/Admin/HR/PayrollController.php @@ -296,7 +296,7 @@ public function export(Request $request): StreamedResponse $file = fopen('php://output', 'w'); fwrite($file, "\xEF\xBB\xBF"); // UTF-8 BOM - fputcsv($file, ['사원명', '부서', '기본급', '고정연장근로수당', '상여금', '총지급액', '국민연금', '건강보험', '고용보험', '근로소득세', '지방소득세', '총공제액', '실수령액', '상태']); + fputcsv($file, ['사원명', '부서', '기본급', '고정연장근로수당', '상여금', '총지급액', '국민연금', '건강보험', '장기요양보험', '고용보험', '근로소득세', '지방소득세', '총공제액', '실수령액', '상태']); foreach ($payrolls as $payroll) { $profile = $payroll->user?->tenantProfiles?->first(); @@ -313,6 +313,7 @@ public function export(Request $request): StreamedResponse $payroll->gross_salary, $payroll->pension, $payroll->health_insurance, + $payroll->long_term_care, $payroll->employment_insurance, $payroll->income_tax, $payroll->resident_tax, diff --git a/app/Models/HR/Payroll.php b/app/Models/HR/Payroll.php index 8351587b..59f2445f 100644 --- a/app/Models/HR/Payroll.php +++ b/app/Models/HR/Payroll.php @@ -27,6 +27,7 @@ class Payroll extends Model 'income_tax', 'resident_tax', 'health_insurance', + 'long_term_care', 'pension', 'employment_insurance', 'deductions', @@ -55,6 +56,7 @@ class Payroll extends Model 'income_tax' => 'decimal:0', 'resident_tax' => 'decimal:0', 'health_insurance' => 'decimal:0', + 'long_term_care' => 'decimal:0', 'pension' => 'decimal:0', 'employment_insurance' => 'decimal:0', 'total_deductions' => 'decimal:0', diff --git a/app/Services/HR/PayrollService.php b/app/Services/HR/PayrollService.php index ef8ac6ec..c27d8476 100644 --- a/app/Services/HR/PayrollService.php +++ b/app/Services/HR/PayrollService.php @@ -170,6 +170,7 @@ public function storePayroll(array $data): Payroll 'income_tax' => $calculated['income_tax'], 'resident_tax' => $calculated['resident_tax'], 'health_insurance' => $calculated['health_insurance'], + 'long_term_care' => $calculated['long_term_care'], 'pension' => $calculated['pension'], 'employment_insurance' => $calculated['employment_insurance'], 'deductions' => $data['deductions'] ?? null, @@ -212,6 +213,7 @@ public function updatePayroll(int $id, array $data): ?Payroll 'income_tax' => $calculated['income_tax'], 'resident_tax' => $calculated['resident_tax'], 'health_insurance' => $calculated['health_insurance'], + 'long_term_care' => $calculated['long_term_care'], 'pension' => $calculated['pension'], 'employment_insurance' => $calculated['employment_insurance'], 'deductions' => array_key_exists('deductions', $data) ? $data['deductions'] : $payroll->deductions, @@ -350,6 +352,7 @@ public function bulkGenerate(int $year, int $month): array 'income_tax' => $calculated['income_tax'], 'resident_tax' => $calculated['resident_tax'], 'health_insurance' => $calculated['health_insurance'], + 'long_term_care' => $calculated['long_term_care'], 'pension' => $calculated['pension'], 'employment_insurance' => $calculated['employment_insurance'], 'deductions' => null, @@ -392,6 +395,7 @@ public function calculateAmounts(array $data, ?PayrollSetting $settings = null): // 4대보험 계산 $healthInsurance = $this->calculateHealthInsurance($grossSalary, $settings); + $longTermCare = $this->calculateLongTermCare($grossSalary, $settings); $pension = $this->calculatePension($grossSalary, $settings); $employmentInsurance = $this->calculateEmploymentInsurance($grossSalary, $settings); @@ -410,7 +414,7 @@ public function calculateAmounts(array $data, ?PayrollSetting $settings = null): } // 총 공제액 - $totalDeductions = $incomeTax + $residentTax + $healthInsurance + $pension + $employmentInsurance + $extraDeductions; + $totalDeductions = $incomeTax + $residentTax + $healthInsurance + $longTermCare + $pension + $employmentInsurance + $extraDeductions; // 실수령액 $netSalary = $grossSalary - $totalDeductions; @@ -420,6 +424,7 @@ public function calculateAmounts(array $data, ?PayrollSetting $settings = null): 'income_tax' => $incomeTax, 'resident_tax' => $residentTax, 'health_insurance' => $healthInsurance, + 'long_term_care' => $longTermCare, 'pension' => $pension, 'employment_insurance' => $employmentInsurance, 'total_deductions' => (int) $totalDeductions, @@ -457,10 +462,17 @@ public function calculateIncomeTax(float $grossSalary, int $dependents = 1): int */ private function calculateHealthInsurance(float $grossSalary, PayrollSetting $settings): int { - $healthInsurance = $grossSalary * ($settings->health_insurance_rate / 100); - $longTermCare = $healthInsurance * ($settings->long_term_care_rate / 100); + return (int) round($grossSalary * ($settings->health_insurance_rate / 100)); + } - return (int) round($healthInsurance + $longTermCare); + /** + * 장기요양보험료 계산 (건강보험료의 일정 비율) + */ + private function calculateLongTermCare(float $grossSalary, PayrollSetting $settings): int + { + $healthInsurance = $grossSalary * ($settings->health_insurance_rate / 100); + + return (int) round($healthInsurance * ($settings->long_term_care_rate / 100)); } /** diff --git a/resources/views/hr/payrolls/index.blade.php b/resources/views/hr/payrolls/index.blade.php index dc900dab..2a6e34d7 100644 --- a/resources/views/hr/payrolls/index.blade.php +++ b/resources/views/hr/payrolls/index.blade.php @@ -217,6 +217,7 @@ class="money-input w-full px-3 py-2 border border-gray-300 rounded-lg text-sm te