feat: Schedule 테이블 및 글로벌 일정 시스템 구현

- schedules 테이블 마이그레이션 추가 (tenant_id NULL 허용)
- Schedule 모델 생성 (type/recurrence 상수, forTenant 스코프)
- CalendarService에 getGeneralSchedules 메서드 추가
- StatusBoardService 하드코딩된 부가세 마감일 → Schedule 조회로 변경
- TaxScheduleSeeder 추가 (분기별 부가세 신고 마감일)
- i18n tax_no_schedule 키 추가
This commit is contained in:
2026-01-21 20:46:53 +09:00
parent e0dc8291fa
commit 289fd3744c
6 changed files with 445 additions and 29 deletions

View File

@@ -0,0 +1,50 @@
<?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('schedules', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tenant_id')->nullable()->comment('NULL이면 전체 테넌트 공통 (본사 등록)');
$table->string('title', 200)->comment('일정 제목');
$table->text('description')->nullable()->comment('일정 설명');
$table->date('start_date')->comment('시작일');
$table->date('end_date')->nullable()->comment('종료일 (NULL이면 당일)');
$table->time('start_time')->nullable()->comment('시작 시간');
$table->time('end_time')->nullable()->comment('종료 시간');
$table->boolean('is_all_day')->default(true)->comment('종일 여부');
$table->string('type', 50)->default('event')->comment('일정 유형: tax, holiday, event, notice, meeting, other');
$table->boolean('is_recurring')->default(false)->comment('반복 일정 여부');
$table->string('recurrence_rule', 50)->nullable()->comment('반복 규칙: yearly, quarterly, monthly, weekly');
$table->string('color', 20)->nullable()->comment('캘린더 표시 색상');
$table->boolean('is_active')->default(true)->comment('활성 여부');
$table->unsignedBigInteger('created_by')->nullable()->comment('생성자');
$table->unsignedBigInteger('updated_by')->nullable()->comment('수정자');
$table->unsignedBigInteger('deleted_by')->nullable()->comment('삭제자');
$table->timestamps();
$table->softDeletes();
// 인덱스
$table->index('tenant_id');
$table->index('type');
$table->index('start_date');
$table->index(['tenant_id', 'type', 'start_date']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('schedules');
}
};

View File

@@ -0,0 +1,89 @@
<?php
namespace Database\Seeders;
use App\Models\Tenants\Schedule;
use Illuminate\Database\Seeder;
/**
* 부가세 신고 마감일 시드
*
* 본사(HQ)에서 등록하는 글로벌 일정 (tenant_id = NULL)
* 모든 테넌트에서 조회 가능
*
* 분기별 마감일:
* - 1분기: 1월 25일 (전년도 4분기분)
* - 2분기: 4월 25일 (1분기분)
* - 3분기: 7월 25일 (2분기분)
* - 4분기: 10월 25일 (3분기분)
*/
class TaxScheduleSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$year = now()->year;
$taxDeadlines = [
[
'title' => "{$year}년 1분기 부가세 신고",
'description' => '전년도 4분기분 부가세 예정신고 마감일',
'start_date' => "{$year}-01-25",
'type' => Schedule::TYPE_TAX,
'is_recurring' => true,
'recurrence_rule' => Schedule::RECURRENCE_YEARLY,
'color' => '#EF4444', // red-500
],
[
'title' => "{$year}년 2분기 부가세 신고",
'description' => '1분기분 부가세 예정신고 마감일',
'start_date' => "{$year}-04-25",
'type' => Schedule::TYPE_TAX,
'is_recurring' => true,
'recurrence_rule' => Schedule::RECURRENCE_YEARLY,
'color' => '#EF4444', // red-500
],
[
'title' => "{$year}년 3분기 부가세 신고",
'description' => '2분기분 부가세 예정신고 마감일',
'start_date' => "{$year}-07-25",
'type' => Schedule::TYPE_TAX,
'is_recurring' => true,
'recurrence_rule' => Schedule::RECURRENCE_YEARLY,
'color' => '#EF4444', // red-500
],
[
'title' => "{$year}년 4분기 부가세 신고",
'description' => '3분기분 부가세 예정신고 마감일',
'start_date' => "{$year}-10-25",
'type' => Schedule::TYPE_TAX,
'is_recurring' => true,
'recurrence_rule' => Schedule::RECURRENCE_YEARLY,
'color' => '#EF4444', // red-500
],
];
foreach ($taxDeadlines as $deadline) {
Schedule::firstOrCreate(
[
'tenant_id' => null, // 글로벌 일정
'title' => $deadline['title'],
'start_date' => $deadline['start_date'],
],
[
'description' => $deadline['description'],
'type' => $deadline['type'],
'is_all_day' => true,
'is_recurring' => $deadline['is_recurring'],
'recurrence_rule' => $deadline['recurrence_rule'],
'color' => $deadline['color'],
'is_active' => true,
]
);
}
$this->command->info("부가세 신고 마감일 {$year}년 일정이 등록되었습니다.");
}
}