From 6f0ad1cf2dcce9cf46e620121da1c1f7aadf6a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A0=EB=B3=91=EC=B2=A0?= Date: Tue, 10 Mar 2026 10:59:19 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[=EC=BA=98=EB=A6=B0=EB=8D=94]=20?= =?UTF-8?q?=EC=96=B4=EC=9D=8C=20=EB=A7=8C=EA=B8=B0=EC=9D=BC=20=EC=9D=BC?= =?UTF-8?q?=EC=A0=95=20=EC=97=B0=EB=8F=99=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Bill 모델 기반 만기일 일정 조회 (getBillSchedules) - type 필터에 'bill' 추가, null(전체)일 때도 포함 - 완료/부도 상태 제외, 만기일 기준 정렬 - 표시 형식: [만기] 거래처명 금액원 Co-Authored-By: Claude Opus 4.6 --- app/Services/CalendarService.php | 53 +++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/app/Services/CalendarService.php b/app/Services/CalendarService.php index bdd87ae..9d44415 100644 --- a/app/Services/CalendarService.php +++ b/app/Services/CalendarService.php @@ -4,6 +4,7 @@ use App\Models\Construction\Contract; use App\Models\Production\WorkOrder; +use App\Models\Tenants\Bill; use App\Models\Tenants\Leave; use App\Models\Tenants\Schedule; use Illuminate\Support\Collection; @@ -16,6 +17,7 @@ * - 계약(Contract): 시공 일정 * - 휴가(Leave): 직원 휴가 일정 * - 일정(Schedule): 본사 공통 일정 + 테넌트 일정 (세금 신고, 공휴일 등) + * - 어음(Bill): 어음 만기일 일정 */ class CalendarService extends Service { @@ -24,7 +26,7 @@ class CalendarService extends Service * * @param string $startDate 조회 시작일 (Y-m-d) * @param string $endDate 조회 종료일 (Y-m-d) - * @param string|null $type 일정 타입 필터 (schedule|order|construction|other|null=전체) + * @param string|null $type 일정 타입 필터 (schedule|order|construction|other|bill|null=전체) * @param string|null $departmentFilter 부서 필터 (all|department|personal) */ public function getSchedules( @@ -64,6 +66,13 @@ public function getSchedules( ); } + // 어음 만기일 + if ($type === null || $type === 'bill') { + $schedules = $schedules->merge( + $this->getBillSchedules($tenantId, $startDate, $endDate) + ); + } + // startDate 기준 정렬 $sortedSchedules = $schedules ->sortBy('startDate') @@ -331,4 +340,46 @@ private function getGeneralSchedules( ]; }); } + + /** + * 어음 만기일 일정 조회 + */ + private function getBillSchedules( + int $tenantId, + string $startDate, + string $endDate + ): Collection { + $excludedStatuses = [ + 'paymentComplete', + 'dishonored', + ]; + + $bills = Bill::query() + ->where('tenant_id', $tenantId) + ->whereNotNull('maturity_date') + ->where('maturity_date', '>=', $startDate) + ->where('maturity_date', '<=', $endDate) + ->whereNotIn('status', $excludedStatuses) + ->orderBy('maturity_date') + ->limit(100) + ->get(); + + return $bills->map(function ($bill) { + $clientName = $bill->display_client_name ?? $bill->client_name ?? ''; + + return [ + 'id' => 'bill_'.$bill->id, + 'title' => '[만기] '.$clientName.' '.number_format($bill->amount).'원', + 'startDate' => $bill->maturity_date->format('Y-m-d'), + 'endDate' => $bill->maturity_date->format('Y-m-d'), + 'startTime' => null, + 'endTime' => null, + 'isAllDay' => true, + 'type' => 'bill', + 'department' => null, + 'personName' => null, + 'color' => null, + ]; + }); + } }