feat: [payroll] 근로소득세 간이세액표 DB 테이블 및 시더 추가

- income_tax_brackets 테이블 마이그레이션 생성
- 2024년 국세청 간이세액표 데이터 시더 (7,117건)
- salary_from/salary_to(천원), family_count(1~11), tax_amount(원)
This commit is contained in:
김보곤
2026-02-27 13:58:39 +09:00
parent bbcb0205fe
commit 87a8930c00
3 changed files with 76 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('income_tax_brackets', function (Blueprint $table) {
$table->id();
$table->unsignedSmallInteger('tax_year')->comment('적용 연도 (예: 2024)');
$table->unsignedInteger('salary_from')->comment('구간 하한 (천원 단위)');
$table->unsignedInteger('salary_to')->comment('구간 상한 (천원 단위)');
$table->unsignedTinyInteger('family_count')->comment('공제대상가족수 (1~11)');
$table->unsignedInteger('tax_amount')->comment('세액 (원)');
$table->timestamps();
$table->index(['tax_year', 'salary_from', 'salary_to', 'family_count'], 'itb_lookup_idx');
});
}
public function down(): void
{
Schema::dropIfExists('income_tax_brackets');
}
};

View File

@@ -0,0 +1,47 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class IncomeTaxBracketSeeder extends Seeder
{
public function run(): void
{
$taxYear = 2024;
// 기존 해당 연도 데이터 삭제 후 재생성
DB::table('income_tax_brackets')->where('tax_year', $taxYear)->delete();
// JSON 데이터 로드 (format: [[salary_from, salary_to, [tax1..tax11]], ...])
$jsonPath = database_path('seeders/data/income_tax_2024.json');
$data = json_decode(file_get_contents($jsonPath), true);
$records = [];
$now = now();
foreach ($data as $row) {
[$salaryFrom, $salaryTo, $taxes] = $row;
for ($fc = 1; $fc <= 11; $fc++) {
$records[] = [
'tax_year' => $taxYear,
'salary_from' => $salaryFrom,
'salary_to' => $salaryTo,
'family_count' => $fc,
'tax_amount' => $taxes[$fc - 1],
'created_at' => $now,
'updated_at' => $now,
];
}
}
// 500건씩 청크 삽입
foreach (array_chunk($records, 500) as $chunk) {
DB::table('income_tax_brackets')->insert($chunk);
}
$this->command->info("Income tax brackets seeded: {$taxYear}".count($records).'건');
}
}

File diff suppressed because one or more lines are too long