feat: 급여 관리 API 구현 (Phase 2: 3.2)
- 마이그레이션: payrolls, payroll_settings 테이블 생성 - 모델: Payroll (상태관리 draft→confirmed→paid), PayrollSetting - 서비스: PayrollService (4대보험 계산, 급여명세서) - 컨트롤러: PayrollController + FormRequest 5개 - API 엔드포인트 13개: - 급여 CRUD + confirm/pay/payslip - 일괄 계산/확정 (calculate, bulk-confirm) - 설정 관리 (settings/payroll) - Swagger 문서: PayrollApi.php - i18n: error.php, message.php, validation.php 키 추가
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('payrolls', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->constrained()->onDelete('cascade')->comment('테넌트 ID');
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade')->comment('사용자 ID');
|
||||
$table->unsignedSmallInteger('pay_year')->comment('급여 연도');
|
||||
$table->unsignedTinyInteger('pay_month')->comment('급여 월 (1-12)');
|
||||
|
||||
// 지급 항목
|
||||
$table->decimal('base_salary', 15, 2)->default(0)->comment('기본급');
|
||||
$table->decimal('overtime_pay', 15, 2)->default(0)->comment('연장근로수당');
|
||||
$table->decimal('bonus', 15, 2)->default(0)->comment('상여금');
|
||||
$table->json('allowances')->nullable()->comment('수당 상세 [{name, amount}]');
|
||||
$table->decimal('gross_salary', 15, 2)->default(0)->comment('총지급액');
|
||||
|
||||
// 공제 항목
|
||||
$table->decimal('income_tax', 15, 2)->default(0)->comment('소득세');
|
||||
$table->decimal('resident_tax', 15, 2)->default(0)->comment('주민세');
|
||||
$table->decimal('health_insurance', 15, 2)->default(0)->comment('건강보험');
|
||||
$table->decimal('pension', 15, 2)->default(0)->comment('국민연금');
|
||||
$table->decimal('employment_insurance', 15, 2)->default(0)->comment('고용보험');
|
||||
$table->json('deductions')->nullable()->comment('공제 상세 [{name, amount}]');
|
||||
$table->decimal('total_deductions', 15, 2)->default(0)->comment('총공제액');
|
||||
|
||||
// 실수령액
|
||||
$table->decimal('net_salary', 15, 2)->default(0)->comment('실수령액');
|
||||
|
||||
// 상태 관리
|
||||
$table->string('status', 20)->default('draft')->comment('상태: draft/confirmed/paid');
|
||||
$table->timestamp('confirmed_at')->nullable()->comment('확정일시');
|
||||
$table->foreignId('confirmed_by')->nullable()->constrained('users')->nullOnDelete()->comment('확정자');
|
||||
$table->timestamp('paid_at')->nullable()->comment('지급일시');
|
||||
$table->foreignId('withdrawal_id')->nullable()->comment('출금 연결 ID');
|
||||
|
||||
// 비고
|
||||
$table->text('note')->nullable()->comment('비고');
|
||||
|
||||
// 감사 컬럼
|
||||
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete()->comment('생성자');
|
||||
$table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete()->comment('수정자');
|
||||
$table->foreignId('deleted_by')->nullable()->constrained('users')->nullOnDelete()->comment('삭제자');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
// 인덱스
|
||||
$table->unique(['tenant_id', 'user_id', 'pay_year', 'pay_month'], 'uk_tenant_user_month');
|
||||
$table->index(['tenant_id', 'pay_year', 'pay_month'], 'idx_tenant_month');
|
||||
$table->index(['tenant_id', 'status'], 'idx_tenant_status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('payrolls');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('payroll_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->unique()->constrained()->onDelete('cascade')->comment('테넌트 ID');
|
||||
|
||||
// 세율 설정 (%)
|
||||
$table->decimal('income_tax_rate', 5, 2)->default(0)->comment('소득세율 (%)');
|
||||
$table->decimal('resident_tax_rate', 5, 2)->default(10)->comment('주민세율 (소득세의 %)');
|
||||
|
||||
// 4대보험 요율 (%)
|
||||
$table->decimal('health_insurance_rate', 5, 3)->default(3.545)->comment('건강보험료율 (%)');
|
||||
$table->decimal('long_term_care_rate', 5, 3)->default(0.9082)->comment('장기요양보험료율 (건강보험의 %)');
|
||||
$table->decimal('pension_rate', 5, 3)->default(4.5)->comment('국민연금 요율 (%)');
|
||||
$table->decimal('employment_insurance_rate', 5, 3)->default(0.9)->comment('고용보험 요율 (%)');
|
||||
|
||||
// 기준금액
|
||||
$table->decimal('pension_max_salary', 15, 2)->default(5900000)->comment('국민연금 기준소득월액 상한');
|
||||
$table->decimal('pension_min_salary', 15, 2)->default(370000)->comment('국민연금 기준소득월액 하한');
|
||||
|
||||
// 기타 설정
|
||||
$table->unsignedTinyInteger('pay_day')->default(25)->comment('급여 지급일');
|
||||
$table->boolean('auto_calculate')->default(false)->comment('자동 계산 여부');
|
||||
|
||||
// 수당 설정
|
||||
$table->json('allowance_types')->nullable()->comment('수당 유형 [{code, name, is_taxable}]');
|
||||
|
||||
// 공제 설정
|
||||
$table->json('deduction_types')->nullable()->comment('공제 유형 [{code, name}]');
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('payroll_settings');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user