feat: [quote] 견적 API Phase 2-3 완료 (Service + Controller Layer)
Phase 2 - Service Layer:
- QuoteService: 견적 CRUD + 상태관리 (확정/전환)
- QuoteNumberService: 견적번호 채번 (KD-{PREFIX}-YYMMDD-SEQ)
- FormulaEvaluatorService: 수식 평가 엔진 (SUM, IF, ROUND 등)
- QuoteCalculationService: 자동산출 (스크린/철재 제품)
- QuoteDocumentService: PDF 생성 및 이메일/카카오 발송
Phase 3 - Controller Layer:
- QuoteController: 16개 엔드포인트
- FormRequest 7개: Index, Store, Update, BulkDelete, Calculate, SendEmail, SendKakao
- QuoteApi.php: Swagger 문서 (12개 스키마, 16개 엔드포인트)
- routes/api.php: 16개 라우트 등록
i18n 키 추가:
- error.php: quote_not_found, formula_* 등
- message.php: quote.* 성공 메시지
2025-12-04 22:03:40 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Quote;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
2025-12-20 22:28:38 +09:00
|
|
|
use Illuminate\Validation\Rule;
|
feat: [quote] 견적 API Phase 2-3 완료 (Service + Controller Layer)
Phase 2 - Service Layer:
- QuoteService: 견적 CRUD + 상태관리 (확정/전환)
- QuoteNumberService: 견적번호 채번 (KD-{PREFIX}-YYMMDD-SEQ)
- FormulaEvaluatorService: 수식 평가 엔진 (SUM, IF, ROUND 등)
- QuoteCalculationService: 자동산출 (스크린/철재 제품)
- QuoteDocumentService: PDF 생성 및 이메일/카카오 발송
Phase 3 - Controller Layer:
- QuoteController: 16개 엔드포인트
- FormRequest 7개: Index, Store, Update, BulkDelete, Calculate, SendEmail, SendKakao
- QuoteApi.php: Swagger 문서 (12개 스키마, 16개 엔드포인트)
- routes/api.php: 16개 라우트 등록
i18n 키 추가:
- error.php: quote_not_found, formula_* 등
- message.php: quote.* 성공 메시지
2025-12-04 22:03:40 +09:00
|
|
|
|
|
|
|
|
class QuoteUpdateRequest extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-06 20:57:51 +09:00
|
|
|
/**
|
|
|
|
|
* 프론트엔드 필드명을 백엔드 필드명으로 정규화
|
|
|
|
|
* manager_name → manager, manager_contact → contact
|
|
|
|
|
*/
|
|
|
|
|
protected function prepareForValidation(): void
|
|
|
|
|
{
|
|
|
|
|
$mappings = [
|
|
|
|
|
'manager_name' => 'manager',
|
|
|
|
|
'manager_contact' => 'contact',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
foreach ($mappings as $from => $to) {
|
|
|
|
|
if ($this->has($from) && ! $this->has($to)) {
|
|
|
|
|
$this->merge([$to => $this->input($from)]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
feat: [quote] 견적 API Phase 2-3 완료 (Service + Controller Layer)
Phase 2 - Service Layer:
- QuoteService: 견적 CRUD + 상태관리 (확정/전환)
- QuoteNumberService: 견적번호 채번 (KD-{PREFIX}-YYMMDD-SEQ)
- FormulaEvaluatorService: 수식 평가 엔진 (SUM, IF, ROUND 등)
- QuoteCalculationService: 자동산출 (스크린/철재 제품)
- QuoteDocumentService: PDF 생성 및 이메일/카카오 발송
Phase 3 - Controller Layer:
- QuoteController: 16개 엔드포인트
- FormRequest 7개: Index, Store, Update, BulkDelete, Calculate, SendEmail, SendKakao
- QuoteApi.php: Swagger 문서 (12개 스키마, 16개 엔드포인트)
- routes/api.php: 16개 라우트 등록
i18n 키 추가:
- error.php: quote_not_found, formula_* 등
- message.php: quote.* 성공 메시지
2025-12-04 22:03:40 +09:00
|
|
|
public function rules(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
// 기본 정보
|
|
|
|
|
'receipt_date' => 'nullable|date',
|
|
|
|
|
'author' => 'nullable|string|max:50',
|
|
|
|
|
|
|
|
|
|
// 발주처 정보
|
|
|
|
|
'client_id' => 'nullable|integer',
|
|
|
|
|
'client_name' => 'nullable|string|max:100',
|
|
|
|
|
'manager' => 'nullable|string|max:50',
|
|
|
|
|
'contact' => 'nullable|string|max:50',
|
|
|
|
|
|
|
|
|
|
// 현장 정보
|
|
|
|
|
'site_id' => 'nullable|integer',
|
|
|
|
|
'site_name' => 'nullable|string|max:100',
|
|
|
|
|
'site_code' => 'nullable|string|max:50',
|
|
|
|
|
|
|
|
|
|
// 제품 정보
|
2025-12-20 22:28:38 +09:00
|
|
|
'product_category' => [
|
|
|
|
|
'nullable',
|
|
|
|
|
Rule::exists('common_codes', 'code')->where('code_group', 'product_category'),
|
|
|
|
|
],
|
feat: [quote] 견적 API Phase 2-3 완료 (Service + Controller Layer)
Phase 2 - Service Layer:
- QuoteService: 견적 CRUD + 상태관리 (확정/전환)
- QuoteNumberService: 견적번호 채번 (KD-{PREFIX}-YYMMDD-SEQ)
- FormulaEvaluatorService: 수식 평가 엔진 (SUM, IF, ROUND 등)
- QuoteCalculationService: 자동산출 (스크린/철재 제품)
- QuoteDocumentService: PDF 생성 및 이메일/카카오 발송
Phase 3 - Controller Layer:
- QuoteController: 16개 엔드포인트
- FormRequest 7개: Index, Store, Update, BulkDelete, Calculate, SendEmail, SendKakao
- QuoteApi.php: Swagger 문서 (12개 스키마, 16개 엔드포인트)
- routes/api.php: 16개 라우트 등록
i18n 키 추가:
- error.php: quote_not_found, formula_* 등
- message.php: quote.* 성공 메시지
2025-12-04 22:03:40 +09:00
|
|
|
'product_id' => 'nullable|integer',
|
|
|
|
|
'product_code' => 'nullable|string|max:50',
|
|
|
|
|
'product_name' => 'nullable|string|max:100',
|
|
|
|
|
|
|
|
|
|
// 규격 정보
|
|
|
|
|
'open_size_width' => 'nullable|numeric|min:0',
|
|
|
|
|
'open_size_height' => 'nullable|numeric|min:0',
|
|
|
|
|
'quantity' => 'nullable|integer|min:1',
|
|
|
|
|
'unit_symbol' => 'nullable|string|max:10',
|
|
|
|
|
'floors' => 'nullable|string|max:50',
|
|
|
|
|
|
|
|
|
|
// 금액 정보
|
|
|
|
|
'material_cost' => 'nullable|numeric|min:0',
|
|
|
|
|
'labor_cost' => 'nullable|numeric|min:0',
|
|
|
|
|
'install_cost' => 'nullable|numeric|min:0',
|
|
|
|
|
'discount_rate' => 'nullable|numeric|min:0|max:100',
|
|
|
|
|
'total_amount' => 'nullable|numeric|min:0',
|
|
|
|
|
|
|
|
|
|
// 기타 정보
|
|
|
|
|
'completion_date' => 'nullable|date',
|
|
|
|
|
'remarks' => 'nullable|string|max:500',
|
|
|
|
|
'memo' => 'nullable|string',
|
|
|
|
|
'notes' => 'nullable|string',
|
|
|
|
|
|
|
|
|
|
// 자동산출 입력값
|
|
|
|
|
'calculation_inputs' => 'nullable|array',
|
|
|
|
|
'calculation_inputs.*' => 'nullable',
|
|
|
|
|
|
|
|
|
|
// 품목 배열 (전체 교체)
|
|
|
|
|
'items' => 'nullable|array',
|
|
|
|
|
'items.*.item_id' => 'nullable|integer',
|
|
|
|
|
'items.*.item_code' => 'nullable|string|max:50',
|
|
|
|
|
'items.*.item_name' => 'nullable|string|max:100',
|
|
|
|
|
'items.*.specification' => 'nullable|string|max:200',
|
|
|
|
|
'items.*.unit' => 'nullable|string|max:20',
|
|
|
|
|
'items.*.base_quantity' => 'nullable|numeric|min:0',
|
|
|
|
|
'items.*.calculated_quantity' => 'nullable|numeric|min:0',
|
|
|
|
|
'items.*.unit_price' => 'nullable|numeric|min:0',
|
|
|
|
|
'items.*.total_price' => 'nullable|numeric|min:0',
|
|
|
|
|
'items.*.formula' => 'nullable|string|max:500',
|
|
|
|
|
'items.*.formula_result' => 'nullable|string|max:200',
|
|
|
|
|
'items.*.formula_source' => 'nullable|string|max:100',
|
|
|
|
|
'items.*.formula_category' => 'nullable|string|max:50',
|
|
|
|
|
'items.*.data_source' => 'nullable|string|max:100',
|
|
|
|
|
'items.*.delivery_date' => 'nullable|date',
|
|
|
|
|
'items.*.note' => 'nullable|string|max:500',
|
|
|
|
|
'items.*.sort_order' => 'nullable|integer|min:0',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|