Files
sam-api/app/Http/Requests/Quote/QuoteBomCalculateRequest.php
kent 660300cebf feat: BOM 기반 견적 계산 API 엔드포인트 추가
- QuoteBomCalculateRequest.php 생성 (BOM 계산용 FormRequest)
- QuoteCalculationService.calculateBom() 메서드 추가
- QuoteController.calculateBom() 액션 추가
- POST /api/v1/quotes/calculate/bom 라우트 등록
- Swagger 문서 업데이트 (스키마 + 엔드포인트)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-02 11:24:22 +09:00

91 lines
3.1 KiB
PHP

<?php
namespace App\Http\Requests\Quote;
use Illuminate\Foundation\Http\FormRequest;
/**
* BOM 기반 견적 산출 요청
*
* React 견적등록 화면에서 자동 견적 산출 시 사용됩니다.
* 완제품 코드와 입력 변수를 받아 BOM 기반으로 품목/단가/금액을 계산합니다.
*/
class QuoteBomCalculateRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
// 필수 입력
'finished_goods_code' => 'required|string|max:50',
'W0' => 'required|numeric|min:100|max:20000',
'H0' => 'required|numeric|min:100|max:20000',
// 선택 입력 (기본값 있음)
'QTY' => 'nullable|integer|min:1',
'PC' => 'nullable|string|in:SCREEN,STEEL',
'GT' => 'nullable|string|in:wall,ceiling,floor',
'MP' => 'nullable|string|in:single,three',
'CT' => 'nullable|string|in:basic,smart,premium',
'WS' => 'nullable|numeric|min:0|max:500',
'INSP' => 'nullable|numeric|min:0',
// 디버그 모드 (개발용)
'debug' => 'nullable|boolean',
];
}
public function attributes(): array
{
return [
'finished_goods_code' => __('validation.attributes.finished_goods_code'),
'W0' => __('validation.attributes.open_width'),
'H0' => __('validation.attributes.open_height'),
'QTY' => __('validation.attributes.quantity'),
'PC' => __('validation.attributes.product_category'),
'GT' => __('validation.attributes.guide_rail_type'),
'MP' => __('validation.attributes.motor_power'),
'CT' => __('validation.attributes.controller'),
'WS' => __('validation.attributes.wing_size'),
'INSP' => __('validation.attributes.inspection_fee'),
];
}
public function messages(): array
{
return [
'finished_goods_code.required' => __('error.finished_goods_code_required'),
'W0.required' => __('error.open_width_required'),
'W0.min' => __('error.open_width_min'),
'W0.max' => __('error.open_width_max'),
'H0.required' => __('error.open_height_required'),
'H0.min' => __('error.open_height_min'),
'H0.max' => __('error.open_height_max'),
];
}
/**
* 입력 변수 배열 반환 (FormulaEvaluatorService용)
*/
public function getInputVariables(): array
{
$validated = $this->validated();
return [
'W0' => (float) $validated['W0'],
'H0' => (float) $validated['H0'],
'QTY' => (int) ($validated['QTY'] ?? 1),
'PC' => $validated['PC'] ?? 'SCREEN',
'GT' => $validated['GT'] ?? 'wall',
'MP' => $validated['MP'] ?? 'single',
'CT' => $validated['CT'] ?? 'basic',
'WS' => (float) ($validated['WS'] ?? 50),
'INSP' => (float) ($validated['INSP'] ?? 50000),
];
}
}