- Price, PriceRevision 모델 추가 (PriceHistory 대체) - PricingService: CRUD, 원가 조회, 확정 기능 - PricingController: statusCode 파라미터로 201 반환 지원 - NotFoundHttpException(404) 적용 (존재하지 않는 리소스) - FormRequest 분리 (Store, Update, Index, Cost, ByItems) - Swagger 문서 업데이트 - ApiResponse::handle()에 statusCode 옵션 추가 - prices/price_revisions 마이그레이션 및 데이터 이관
55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Pricing;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class PriceUpdateRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
// 품목 연결 (선택)
|
|
'item_type_code' => 'sometimes|string|in:PRODUCT,MATERIAL',
|
|
'item_id' => 'sometimes|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' => 'sometimes|date',
|
|
'effective_to' => 'nullable|date|after_or_equal:effective_from',
|
|
'note' => 'nullable|string|max:1000',
|
|
|
|
// 상태
|
|
'status' => ['nullable', Rule::in(['draft', 'active', 'inactive'])],
|
|
|
|
// 변경 사유 (리비전 기록용)
|
|
'change_reason' => 'nullable|string|max:500',
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'effective_to.after_or_equal' => __('error.pricing.effective_to_must_be_after_from'),
|
|
];
|
|
}
|
|
}
|