feat(API): Service 로직 개선
- EstimateService, ItemService 기능 추가 - OrderService 공정 연동 개선 - SalaryService, ReceivablesService 수정 - HandoverReportService, SiteBriefingService 추가 - Pricing 서비스 추가 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,6 @@ public function __construct(
|
||||
CalculationEngine $calculationEngine,
|
||||
PricingService $pricingService
|
||||
) {
|
||||
parent::__construct();
|
||||
$this->modelSetService = $modelSetService;
|
||||
$this->calculationEngine = $calculationEngine;
|
||||
$this->pricingService = $pricingService;
|
||||
@@ -362,6 +361,37 @@ protected function createEstimateItems(Estimate $estimate, array $bomItems, ?int
|
||||
return $totalAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 견적 통계 조회
|
||||
*/
|
||||
public function stats(): array
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$stats = Estimate::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->selectRaw("
|
||||
COUNT(*) as total,
|
||||
SUM(CASE WHEN status = 'DRAFT' THEN 1 ELSE 0 END) as draft,
|
||||
SUM(CASE WHEN status = 'SENT' THEN 1 ELSE 0 END) as sent,
|
||||
SUM(CASE WHEN status = 'APPROVED' THEN 1 ELSE 0 END) as approved,
|
||||
SUM(CASE WHEN status = 'REJECTED' THEN 1 ELSE 0 END) as rejected,
|
||||
SUM(CASE WHEN status = 'EXPIRED' THEN 1 ELSE 0 END) as expired,
|
||||
SUM(total_amount) as total_amount
|
||||
")
|
||||
->first();
|
||||
|
||||
return [
|
||||
'total' => (int) $stats->total,
|
||||
'draft' => (int) $stats->draft,
|
||||
'sent' => (int) $stats->sent,
|
||||
'approved' => (int) $stats->approved,
|
||||
'rejected' => (int) $stats->rejected,
|
||||
'expired' => (int) $stats->expired,
|
||||
'total_amount' => (float) ($stats->total_amount ?? 0),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 계산 결과 요약
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user