feat: 견적 할인금액(discount_amount) 직접 입력 지원

- QuoteStoreRequest/UpdateRequest에 discount_amount 필드 추가
- QuoteService: 프론트엔드에서 계산한 할인금액 우선 사용, 없으면 비율로 계산

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-29 15:05:14 +09:00
parent f7ad9ae36e
commit 99a6c89d41
3 changed files with 10 additions and 2 deletions

View File

@@ -71,6 +71,7 @@ public function rules(): array
'labor_cost' => 'nullable|numeric|min:0',
'install_cost' => 'nullable|numeric|min:0',
'discount_rate' => 'nullable|numeric|min:0|max:100',
'discount_amount' => 'nullable|numeric|min:0',
'total_amount' => 'nullable|numeric|min:0',
// 기타 정보

View File

@@ -69,6 +69,7 @@ public function rules(): array
'labor_cost' => 'nullable|numeric|min:0',
'install_cost' => 'nullable|numeric|min:0',
'discount_rate' => 'nullable|numeric|min:0|max:100',
'discount_amount' => 'nullable|numeric|min:0',
'total_amount' => 'nullable|numeric|min:0',
// 기타 정보

View File

@@ -222,7 +222,10 @@ public function store(array $data): Quote
$installCost = (float) ($data['install_cost'] ?? 0);
$subtotal = $materialCost + $laborCost + $installCost;
$discountRate = (float) ($data['discount_rate'] ?? 0);
$discountAmount = $subtotal * ($discountRate / 100);
// 프론트엔드에서 직접 계산한 할인금액이 있으면 사용, 없으면 subtotal에서 계산
$discountAmount = isset($data['discount_amount'])
? (float) $data['discount_amount']
: $subtotal * ($discountRate / 100);
$totalAmount = $subtotal - $discountAmount;
// 견적 생성
@@ -318,7 +321,10 @@ public function update(int $id, array $data): Quote
$installCost = (float) ($data['install_cost'] ?? $quote->install_cost);
$subtotal = $materialCost + $laborCost + $installCost;
$discountRate = (float) ($data['discount_rate'] ?? $quote->discount_rate);
$discountAmount = $subtotal * ($discountRate / 100);
// 프론트엔드에서 직접 계산한 할인금액이 있으면 사용, 없으면 subtotal에서 계산
$discountAmount = isset($data['discount_amount'])
? (float) $data['discount_amount']
: $subtotal * ($discountRate / 100);
$totalAmount = $subtotal - $discountAmount;
// 업데이트