deploy: 2026-03-11 배포
- feat: QMS 감사 체크리스트 (AuditChecklist CRUD, 카테고리/항목/표준문서 모델, 마이그레이션) - feat: QMS LOT 감사 (QmsLotAudit 컨트롤러/서비스, 확인/문서상세 FormRequest) - fix: CalendarService, MemberService 수정 - chore: QualityDocumentLocation options 컬럼 추가, tenant_id 마이그레이션, 품질 더미데이터 시더
This commit is contained in:
@@ -4,9 +4,12 @@
|
||||
|
||||
use App\Models\Construction\Contract;
|
||||
use App\Models\Production\WorkOrder;
|
||||
use App\Models\Orders\Order;
|
||||
use App\Models\Tenants\Bill;
|
||||
use App\Models\Tenants\ExpectedExpense;
|
||||
use App\Models\Tenants\Leave;
|
||||
use App\Models\Tenants\Schedule;
|
||||
use App\Models\Tenants\Shipment;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@@ -26,7 +29,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|bill|null=전체)
|
||||
* @param string|null $type 일정 타입 필터 (schedule|order|construction|other|bill|expected_expense|delivery|shipment|null=전체)
|
||||
* @param string|null $departmentFilter 부서 필터 (all|department|personal)
|
||||
*/
|
||||
public function getSchedules(
|
||||
@@ -73,6 +76,27 @@ public function getSchedules(
|
||||
);
|
||||
}
|
||||
|
||||
// 매입 결제 예정일
|
||||
if ($type === null || $type === 'expected_expense') {
|
||||
$schedules = $schedules->merge(
|
||||
$this->getExpectedExpenseSchedules($tenantId, $startDate, $endDate)
|
||||
);
|
||||
}
|
||||
|
||||
// 수주 납기일
|
||||
if ($type === null || $type === 'delivery') {
|
||||
$schedules = $schedules->merge(
|
||||
$this->getDeliverySchedules($tenantId, $startDate, $endDate)
|
||||
);
|
||||
}
|
||||
|
||||
// 출고 예정일
|
||||
if ($type === null || $type === 'shipment') {
|
||||
$schedules = $schedules->merge(
|
||||
$this->getShipmentSchedules($tenantId, $startDate, $endDate)
|
||||
);
|
||||
}
|
||||
|
||||
// startDate 기준 정렬
|
||||
$sortedSchedules = $schedules
|
||||
->sortBy('startDate')
|
||||
@@ -382,4 +406,128 @@ private function getBillSchedules(
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 매입 결제 예정일 조회
|
||||
*/
|
||||
private function getExpectedExpenseSchedules(
|
||||
int $tenantId,
|
||||
string $startDate,
|
||||
string $endDate
|
||||
): Collection {
|
||||
$expenses = ExpectedExpense::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->whereNotNull('expected_payment_date')
|
||||
->where('expected_payment_date', '>=', $startDate)
|
||||
->where('expected_payment_date', '<=', $endDate)
|
||||
->where('payment_status', '!=', 'paid')
|
||||
->with(['client:id,name'])
|
||||
->orderBy('expected_payment_date')
|
||||
->limit(100)
|
||||
->get();
|
||||
|
||||
return $expenses->map(function ($expense) {
|
||||
$clientName = $expense->client?->name ?? $expense->client_name ?? '';
|
||||
|
||||
return [
|
||||
'id' => 'expense_'.$expense->id,
|
||||
'title' => '[결제] '.$clientName.' '.number_format($expense->amount).'원',
|
||||
'startDate' => $expense->expected_payment_date->format('Y-m-d'),
|
||||
'endDate' => $expense->expected_payment_date->format('Y-m-d'),
|
||||
'startTime' => null,
|
||||
'endTime' => null,
|
||||
'isAllDay' => true,
|
||||
'type' => 'expected_expense',
|
||||
'department' => null,
|
||||
'personName' => null,
|
||||
'color' => null,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 수주 납기일 조회
|
||||
*/
|
||||
private function getDeliverySchedules(
|
||||
int $tenantId,
|
||||
string $startDate,
|
||||
string $endDate
|
||||
): Collection {
|
||||
$activeStatuses = [
|
||||
'CONFIRMED',
|
||||
'IN_PROGRESS',
|
||||
'IN_PRODUCTION',
|
||||
'PRODUCED',
|
||||
'SHIPPING',
|
||||
];
|
||||
|
||||
$orders = Order::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->whereNotNull('delivery_date')
|
||||
->where('delivery_date', '>=', $startDate)
|
||||
->where('delivery_date', '<=', $endDate)
|
||||
->whereIn('status_code', $activeStatuses)
|
||||
->with(['client:id,name'])
|
||||
->orderBy('delivery_date')
|
||||
->limit(100)
|
||||
->get();
|
||||
|
||||
return $orders->map(function ($order) {
|
||||
$clientName = $order->client?->name ?? $order->client_name ?? '';
|
||||
$siteName = $order->site_name ?? $order->order_no;
|
||||
|
||||
return [
|
||||
'id' => 'delivery_'.$order->id,
|
||||
'title' => '[납기] '.$clientName.' '.$siteName,
|
||||
'startDate' => $order->delivery_date->format('Y-m-d'),
|
||||
'endDate' => $order->delivery_date->format('Y-m-d'),
|
||||
'startTime' => null,
|
||||
'endTime' => null,
|
||||
'isAllDay' => true,
|
||||
'type' => 'delivery',
|
||||
'department' => null,
|
||||
'personName' => null,
|
||||
'color' => null,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 출고 예정일 조회
|
||||
*/
|
||||
private function getShipmentSchedules(
|
||||
int $tenantId,
|
||||
string $startDate,
|
||||
string $endDate
|
||||
): Collection {
|
||||
$shipments = Shipment::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->whereNotNull('scheduled_date')
|
||||
->where('scheduled_date', '>=', $startDate)
|
||||
->where('scheduled_date', '<=', $endDate)
|
||||
->whereIn('status', ['scheduled', 'ready'])
|
||||
->with(['client:id,name', 'order:id,site_name'])
|
||||
->orderBy('scheduled_date')
|
||||
->limit(100)
|
||||
->get();
|
||||
|
||||
return $shipments->map(function ($shipment) {
|
||||
$clientName = $shipment->client?->name ?? $shipment->customer_name ?? '';
|
||||
$siteName = $shipment->site_name ?? $shipment->order?->site_name ?? $shipment->shipment_no;
|
||||
|
||||
return [
|
||||
'id' => 'shipment_'.$shipment->id,
|
||||
'title' => '[출고] '.$clientName.' '.$siteName,
|
||||
'startDate' => $shipment->scheduled_date->format('Y-m-d'),
|
||||
'endDate' => $shipment->scheduled_date->format('Y-m-d'),
|
||||
'startTime' => null,
|
||||
'endTime' => null,
|
||||
'isAllDay' => true,
|
||||
'type' => 'shipment',
|
||||
'department' => null,
|
||||
'personName' => null,
|
||||
'color' => null,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user