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

@@ -5,6 +5,7 @@
use App\Models\Construction\Contract;
use App\Models\Production\WorkOrder;
use App\Models\Tenants\Leave;
use App\Models\Tenants\Schedule;
use Carbon\Carbon;
use Illuminate\Support\Collection;
@@ -15,6 +16,7 @@
* - 작업지시(WorkOrder): 생산 일정
* - 계약(Contract): 시공 일정
* - 휴가(Leave): 직원 휴가 일정
* - 일정(Schedule): 본사 공통 일정 + 테넌트 일정 (세금 신고, 공휴일 등)
*/
class CalendarService extends Service
{
@@ -56,6 +58,13 @@ public function getSchedules(
);
}
// 범용 일정 (본사 공통 + 테넌트 일정): 항상 포함 또는 'other' 필터 시
if ($type === null || $type === 'other') {
$schedules = $schedules->merge(
$this->getGeneralSchedules($tenantId, $startDate, $endDate)
);
}
// startDate 기준 정렬
$sortedSchedules = $schedules
->sortBy('startDate')
@@ -217,4 +226,38 @@ private function getLeaveSchedules(
];
});
}
/**
* 범용 일정 조회 (본사 공통 + 테넌트 일정)
*/
private function getGeneralSchedules(
int $tenantId,
string $startDate,
string $endDate
): Collection {
$schedules = Schedule::query()
->forTenant($tenantId)
->active()
->betweenDates($startDate, $endDate)
->with(['creator:id,name'])
->orderBy('start_date')
->limit(100)
->get();
return $schedules->map(function ($schedule) {
return [
'id' => 'schedule_'.$schedule->id,
'title' => $schedule->title,
'startDate' => $schedule->start_date?->format('Y-m-d'),
'endDate' => $schedule->end_date?->format('Y-m-d') ?? $schedule->start_date?->format('Y-m-d'),
'startTime' => $schedule->start_time,
'endTime' => $schedule->end_time,
'isAllDay' => $schedule->is_all_day,
'type' => 'other',
'department' => null,
'personName' => $schedule->creator?->name,
'color' => $schedule->color,
];
});
}
}