Files
sam-api/app/Http/Requests/Pricing/PriceStoreRequest.php
hskwon 8d3ea4bb39 feat: 단가 관리 API 구현 및 Flow Tester 호환성 개선
- Price, PriceRevision 모델 추가 (PriceHistory 대체)
- PricingService: CRUD, 원가 조회, 확정 기능
- PricingController: statusCode 파라미터로 201 반환 지원
- NotFoundHttpException(404) 적용 (존재하지 않는 리소스)
- FormRequest 분리 (Store, Update, Index, Cost, ByItems)
- Swagger 문서 업데이트
- ApiResponse::handle()에 statusCode 옵션 추가
- prices/price_revisions 마이그레이션 및 데이터 이관
2025-12-08 19:03:50 +09:00

52 lines
1.5 KiB
PHP

<?php
namespace App\Http\Requests\Pricing;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class PriceStoreRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
// 품목 연결 (필수)
'item_type_code' => 'required|string|in:PRODUCT,MATERIAL',
'item_id' => 'required|integer',
'client_group_id' => 'nullable|integer',
// 원가 정보
'purchase_price' => 'nullable|numeric|min:0',
'processing_cost' => 'nullable|numeric|min:0',
'loss_rate' => 'nullable|numeric|min:0|max:100',
// 판매가 정보
'margin_rate' => 'nullable|numeric|min:0|max:100',
'sales_price' => 'nullable|numeric|min:0',
'rounding_rule' => ['nullable', Rule::in(['round', 'ceil', 'floor'])],
'rounding_unit' => ['nullable', Rule::in([1, 10, 100, 1000])],
// 메타 정보
'supplier' => 'nullable|string|max:255',
'effective_from' => 'required|date',
'effective_to' => 'nullable|date|after_or_equal:effective_from',
'note' => 'nullable|string|max:1000',
// 상태
'status' => ['nullable', Rule::in(['draft', 'active', 'inactive'])],
];
}
public function messages(): array
{
return [
'effective_to.after_or_equal' => __('error.pricing.effective_to_must_be_after_from'),
];
}
}