feat: Schedule 테이블 및 글로벌 일정 시스템 구현
- schedules 테이블 마이그레이션 추가 (tenant_id NULL 허용) - Schedule 모델 생성 (type/recurrence 상수, forTenant 스코프) - CalendarService에 getGeneralSchedules 메서드 추가 - StatusBoardService 하드코딩된 부가세 마감일 → Schedule 조회로 변경 - TaxScheduleSeeder 추가 (분기별 부가세 신고 마감일) - i18n tax_no_schedule 키 추가
This commit is contained in:
@@ -5,10 +5,10 @@
|
||||
use App\Models\BadDebts\BadDebt;
|
||||
use App\Models\Orders\Client;
|
||||
use App\Models\Orders\Order;
|
||||
use App\Models\Tenants\Approval;
|
||||
use App\Models\Tenants\ApprovalStep;
|
||||
use App\Models\Tenants\Leave;
|
||||
use App\Models\Tenants\Purchase;
|
||||
use App\Models\Tenants\Schedule;
|
||||
use App\Models\Tenants\Stock;
|
||||
use Carbon\Carbon;
|
||||
|
||||
@@ -50,7 +50,7 @@ private function getOrdersStatus(int $tenantId, Carbon $today): array
|
||||
$count = Order::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->whereDate('created_at', $today)
|
||||
->where('status_code', 'confirmed') // 확정된 수주만
|
||||
->where('status_code', Order::STATUS_CONFIRMED) // 확정된 수주만
|
||||
->count();
|
||||
|
||||
return [
|
||||
@@ -69,7 +69,7 @@ private function getBadDebtStatus(int $tenantId): array
|
||||
{
|
||||
$count = BadDebt::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('status', 'in_progress') // 추심 진행 중
|
||||
->where('status', BadDebt::STATUS_COLLECTING) // 추심 진행 중
|
||||
->count();
|
||||
|
||||
return [
|
||||
@@ -105,33 +105,32 @@ private function getSafetyStockStatus(int $tenantId): array
|
||||
|
||||
/**
|
||||
* 세금 신고 현황 (부가세 신고 D-day)
|
||||
*
|
||||
* Schedule 테이블에서 type='tax'인 가장 가까운 일정 조회
|
||||
* - 본사(tenant_id=NULL) 등록 글로벌 일정 + 테넌트 전용 일정 모두 포함
|
||||
*/
|
||||
private function getTaxDeadlineStatus(int $tenantId, Carbon $today): array
|
||||
{
|
||||
// 부가세 신고 마감일 계산 (분기별: 1/25, 4/25, 7/25, 10/25)
|
||||
$quarter = $today->quarter;
|
||||
$deadlineMonth = match ($quarter) {
|
||||
1 => 1, // 1분기 → 1월 25일
|
||||
2 => 4, // 2분기 → 4월 25일
|
||||
3 => 7, // 3분기 → 7월 25일
|
||||
4 => 10, // 4분기 → 10월 25일
|
||||
};
|
||||
// Schedule 테이블에서 가장 가까운 세금 신고 일정 조회
|
||||
$nextTaxSchedule = Schedule::query()
|
||||
->forTenant($tenantId)
|
||||
->active()
|
||||
->tax()
|
||||
->upcoming($today->format('Y-m-d'))
|
||||
->first();
|
||||
|
||||
$deadlineYear = $today->year;
|
||||
// 1분기 마감일이 지났으면 다음 분기 마감일
|
||||
if ($today->month > $deadlineMonth || ($today->month == $deadlineMonth && $today->day > 25)) {
|
||||
$deadlineMonth = match ($quarter) {
|
||||
1 => 4,
|
||||
2 => 7,
|
||||
3 => 10,
|
||||
4 => 1, // 다음 해
|
||||
};
|
||||
if ($deadlineMonth == 1) {
|
||||
$deadlineYear++;
|
||||
}
|
||||
if (! $nextTaxSchedule) {
|
||||
// 등록된 세금 일정이 없는 경우
|
||||
return [
|
||||
'id' => 'tax_deadline',
|
||||
'label' => __('message.status_board.tax_deadline'),
|
||||
'count' => __('message.status_board.tax_no_schedule'),
|
||||
'path' => '/accounting/tax',
|
||||
'isHighlighted' => false,
|
||||
];
|
||||
}
|
||||
|
||||
$deadline = Carbon::create($deadlineYear, $deadlineMonth, 25);
|
||||
$deadline = $nextTaxSchedule->start_date;
|
||||
$daysUntil = $today->diffInDays($deadline, false);
|
||||
|
||||
$countText = $daysUntil >= 0
|
||||
@@ -194,7 +193,7 @@ private function getPurchaseStatus(int $tenantId): array
|
||||
{
|
||||
$count = Purchase::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('status', 'pending') // 대기 중인 발주
|
||||
->where('status', 'draft') // 대기 중인 발주 (임시저장 상태)
|
||||
->count();
|
||||
|
||||
return [
|
||||
@@ -228,4 +227,4 @@ private function getApprovalStatus(int $tenantId, int $userId): array
|
||||
'isHighlighted' => $count > 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user