feat: 수주관리(Order Management) API Phase 1.1 구현
- OrderService 구현 (index, stats, show, store, update, destroy, updateStatus)
- OrderController 구현 (7개 API 엔드포인트)
- FormRequest 클래스 3개 생성 (Store, Update, UpdateStatus)
- 상태 전환 규칙 검증 (DRAFT → CONFIRMED → IN_PROGRESS → COMPLETED/CANCELLED)
- 수주번호 자동 생성 (ORD{YYYYMMDD}{0001} 형식)
- Swagger API 문서 작성 (OrderApi.php)
- i18n 메시지 키 추가 (ko/en)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
71
app/Http/Requests/Order/StoreOrderRequest.php
Normal file
71
app/Http/Requests/Order/StoreOrderRequest.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Order;
|
||||
|
||||
use App\Models\Orders\Order;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreOrderRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
// 기본 정보
|
||||
'quote_id' => 'nullable|integer|exists:quotes,id',
|
||||
'order_type_code' => ['nullable', Rule::in([Order::TYPE_ORDER, Order::TYPE_PURCHASE])],
|
||||
'status_code' => ['nullable', Rule::in([
|
||||
Order::STATUS_DRAFT,
|
||||
Order::STATUS_CONFIRMED,
|
||||
])],
|
||||
'category_code' => 'nullable|string|max:50',
|
||||
|
||||
// 거래처 정보
|
||||
'client_id' => 'nullable|integer|exists:clients,id',
|
||||
'client_name' => 'nullable|string|max:200',
|
||||
'client_contact' => 'nullable|string|max:100',
|
||||
'site_name' => 'nullable|string|max:200',
|
||||
|
||||
// 금액 정보
|
||||
'supply_amount' => 'nullable|numeric|min:0',
|
||||
'tax_amount' => 'nullable|numeric|min:0',
|
||||
'total_amount' => 'nullable|numeric|min:0',
|
||||
'discount_rate' => 'nullable|numeric|min:0|max:100',
|
||||
'discount_amount' => 'nullable|numeric|min:0',
|
||||
|
||||
// 배송/기타
|
||||
'delivery_date' => 'nullable|date',
|
||||
'delivery_method_code' => 'nullable|string|max:50',
|
||||
'received_at' => 'nullable|date',
|
||||
'memo' => 'nullable|string',
|
||||
'remarks' => 'nullable|string',
|
||||
'note' => 'nullable|string',
|
||||
|
||||
// 품목 배열
|
||||
'items' => 'nullable|array',
|
||||
'items.*.item_id' => 'nullable|integer|exists:items,id',
|
||||
'items.*.item_name' => 'required|string|max:200',
|
||||
'items.*.specification' => 'nullable|string|max:500',
|
||||
'items.*.quantity' => 'required|numeric|min:0',
|
||||
'items.*.unit' => 'nullable|string|max:20',
|
||||
'items.*.unit_price' => 'required|numeric|min:0',
|
||||
'items.*.supply_amount' => 'nullable|numeric|min:0',
|
||||
'items.*.tax_amount' => 'nullable|numeric|min:0',
|
||||
'items.*.total_amount' => 'nullable|numeric|min:0',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'items.*.item_name.required' => __('validation.required', ['attribute' => '품목명']),
|
||||
'items.*.quantity.required' => __('validation.required', ['attribute' => '수량']),
|
||||
'items.*.unit_price.required' => __('validation.required', ['attribute' => '단가']),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user