feat: 견적 참조 데이터 API, 수주 전환 로직 개선, 검사기준서 필드 통합
- 견적 참조 데이터(현장명, 부호) 조회 API 추가 (GET /quotes/reference-data) - 수주 전환 시 floor_code/symbol_code를 quoteItem.note에서 파싱하도록 변경 - 수주 전환 시 note에 formula_category 저장 - 검사기준서 프리셋: standard + standard_criteria → text_with_criteria로 통합 - tolerance 컬럼 width 조정 (120px → 85px) - LOGICAL_RELATIONSHIPS.md 문서 갱신 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -470,39 +470,24 @@ public function createFromQuote(int $quoteId, array $data = [])
|
||||
|
||||
$order->save();
|
||||
|
||||
// calculation_inputs에서 제품-부품 매핑 정보 추출
|
||||
$calculationInputs = $quote->calculation_inputs ?? [];
|
||||
$calcInputItems = $calculationInputs['items'] ?? [];
|
||||
|
||||
// 견적 품목을 수주 품목으로 변환
|
||||
foreach ($quote->items as $index => $quoteItem) {
|
||||
// calculation_inputs.items에서 해당 품목의 floor/code 정보 찾기
|
||||
// 1. item_index로 매칭 시도
|
||||
// 2. 없으면 배열 인덱스로 fallback
|
||||
// floor_code/symbol_code 추출:
|
||||
// 1순위: quoteItem->note에서 파싱 (형식: "4F DS-01" → floor=4F, symbol=DS-01)
|
||||
// 2순위: NULL
|
||||
$floorCode = null;
|
||||
$symbolCode = null;
|
||||
|
||||
$itemIndex = $quoteItem->item_index ?? null;
|
||||
if ($itemIndex !== null) {
|
||||
// item_index로 매칭
|
||||
foreach ($calcInputItems as $calcItem) {
|
||||
if (($calcItem['index'] ?? null) === $itemIndex) {
|
||||
$floorCode = $calcItem['floor'] ?? null;
|
||||
$symbolCode = $calcItem['code'] ?? null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// item_index로 못 찾으면 배열 인덱스로 fallback
|
||||
if ($floorCode === null && $symbolCode === null && isset($calcInputItems[$index])) {
|
||||
$floorCode = $calcInputItems[$index]['floor'] ?? null;
|
||||
$symbolCode = $calcInputItems[$index]['code'] ?? null;
|
||||
$note = trim($quoteItem->note ?? '');
|
||||
if ($note !== '') {
|
||||
$parts = preg_split('/\s+/', $note, 2);
|
||||
$floorCode = $parts[0] ?? null;
|
||||
$symbolCode = $parts[1] ?? null;
|
||||
}
|
||||
|
||||
$order->items()->create([
|
||||
'tenant_id' => $tenantId,
|
||||
'serial_no' => $index + 1, // 1부터 시작하는 순번
|
||||
'serial_no' => $index + 1,
|
||||
'item_id' => $quoteItem->item_id,
|
||||
'item_code' => $quoteItem->item_code,
|
||||
'item_name' => $quoteItem->item_name,
|
||||
@@ -515,6 +500,7 @@ public function createFromQuote(int $quoteId, array $data = [])
|
||||
'supply_amount' => $quoteItem->total_price,
|
||||
'tax_amount' => round($quoteItem->total_price * 0.1, 2),
|
||||
'total_amount' => round($quoteItem->total_price * 1.1, 2),
|
||||
'note' => $quoteItem->formula_category,
|
||||
'sort_order' => $index,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user