Files
sam-api/database/migrations/2025_12_18_100001_create_payrolls_table.php
hskwon 7089dd1e46 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 키 추가
2025-12-18 10:56:16 +09:00

72 lines
3.4 KiB
PHP

<?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');
}
};