From 99a6c89d41e6f7d0687497cc343607b41ec33d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Thu, 29 Jan 2026 15:05:14 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B2=AC=EC=A0=81=20=ED=95=A0=EC=9D=B8?= =?UTF-8?q?=EA=B8=88=EC=95=A1(discount=5Famount)=20=EC=A7=81=EC=A0=91=20?= =?UTF-8?q?=EC=9E=85=EB=A0=A5=20=EC=A7=80=EC=9B=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - QuoteStoreRequest/UpdateRequest에 discount_amount 필드 추가 - QuoteService: 프론트엔드에서 계산한 할인금액 우선 사용, 없으면 비율로 계산 Co-Authored-By: Claude Opus 4.5 --- app/Http/Requests/Quote/QuoteStoreRequest.php | 1 + app/Http/Requests/Quote/QuoteUpdateRequest.php | 1 + app/Services/Quote/QuoteService.php | 10 ++++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/Quote/QuoteStoreRequest.php b/app/Http/Requests/Quote/QuoteStoreRequest.php index effb09f..c496c26 100644 --- a/app/Http/Requests/Quote/QuoteStoreRequest.php +++ b/app/Http/Requests/Quote/QuoteStoreRequest.php @@ -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', // 기타 정보 diff --git a/app/Http/Requests/Quote/QuoteUpdateRequest.php b/app/Http/Requests/Quote/QuoteUpdateRequest.php index a72bfc2..e9fd9f7 100644 --- a/app/Http/Requests/Quote/QuoteUpdateRequest.php +++ b/app/Http/Requests/Quote/QuoteUpdateRequest.php @@ -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', // 기타 정보 diff --git a/app/Services/Quote/QuoteService.php b/app/Services/Quote/QuoteService.php index 7e5a74a..be699c4 100644 --- a/app/Services/Quote/QuoteService.php +++ b/app/Services/Quote/QuoteService.php @@ -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; // 업데이트