fix: [order] 견적→수주 변환 개소별 분리 구현
- CreateFromQuoteRequest 검증 규칙 추가 - Order 모델 견적 연동 관계 보강 - OrderService 변환 시 개소별 분리 로직
This commit is contained in:
@@ -340,4 +340,46 @@ public static function createFromQuote(Quote $quote, string $orderNo): self
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 견적의 개소(location) 단위로 수주 생성
|
||||
* 다중 개소 견적 → 개소별 독립 수주
|
||||
*/
|
||||
public static function createFromQuoteLocation(Quote $quote, string $orderNo, array $locItem, ?array $bomResult): self
|
||||
{
|
||||
$qty = (int) ($locItem['quantity'] ?? 1);
|
||||
$grandTotal = $bomResult['grand_total'] ?? 0;
|
||||
$supplyAmount = $grandTotal * $qty;
|
||||
$floor = $locItem['floor'] ?? '';
|
||||
$symbol = $locItem['code'] ?? '';
|
||||
$locLabel = trim("{$floor} {$symbol}") ?: '';
|
||||
$siteName = $quote->site_name;
|
||||
if ($locLabel) {
|
||||
$siteName = "{$siteName} [{$locLabel}]";
|
||||
}
|
||||
|
||||
return new self([
|
||||
'tenant_id' => $quote->tenant_id,
|
||||
'quote_id' => $quote->id,
|
||||
'order_no' => $orderNo,
|
||||
'order_type_code' => self::TYPE_ORDER,
|
||||
'status_code' => self::STATUS_DRAFT,
|
||||
'client_id' => $quote->client_id,
|
||||
'client_name' => $quote->client?->name,
|
||||
'client_contact' => $quote->contact,
|
||||
'site_name' => $siteName,
|
||||
'quantity' => $qty,
|
||||
'supply_amount' => $supplyAmount,
|
||||
'tax_amount' => round($supplyAmount * 0.1, 2),
|
||||
'total_amount' => round($supplyAmount * 1.1, 2),
|
||||
'delivery_date' => $quote->completion_date,
|
||||
'memo' => $quote->remarks,
|
||||
'options' => [
|
||||
'manager_name' => $quote->manager,
|
||||
'product_code' => $locItem['productCode'] ?? null,
|
||||
'location_floor' => $floor,
|
||||
'location_code' => $symbol,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user