Files
sam-api/app/Http/Requests/Pricing/PriceUpdateRequest.php

59 lines
1.8 KiB
PHP
Raw Normal View History

<?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',
Rule::exists('common_codes', 'code')->where('code_group', 'item_type'),
],
'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'),
];
}
}