feat(API): Service 로직 개선

- EstimateService, ItemService 기능 추가
- OrderService 공정 연동 개선
- SalaryService, ReceivablesService 수정
- HandoverReportService, SiteBriefingService 추가
- Pricing 서비스 추가

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-13 19:49:06 +09:00
parent ba5f402cd8
commit 8a5c7b5298
15 changed files with 723 additions and 25 deletions

View File

@@ -933,4 +933,42 @@ private function groupFilesByFieldKey(array $files): array
return $grouped;
}
/**
* 품목 통계 조회
*
* @param array $params 검색 파라미터 (item_type 또는 group_id, 없으면 전체)
* @return array{total: int, active: int}
*/
public function stats(array $params = []): array
{
$tenantId = $this->tenantId();
$itemType = $params['item_type'] ?? null;
$groupId = $params['group_id'] ?? null;
// 기본 쿼리 (items 테이블)
$baseQuery = Item::where('tenant_id', $tenantId);
// item_type 필터
if ($itemType) {
$itemTypes = $this->parseItemTypes($itemType);
if (! empty($itemTypes)) {
$baseQuery->whereIn('item_type', $itemTypes);
}
} elseif ($groupId) {
// group_id로 해당 그룹의 item_type 조회
$itemTypes = $this->getItemTypesByGroupId((int) $groupId);
if (! empty($itemTypes)) {
$baseQuery->whereIn('item_type', $itemTypes);
}
}
$total = (clone $baseQuery)->count();
$active = (clone $baseQuery)->where('is_active', true)->count();
return [
'total' => $total,
'active' => $active,
];
}
}