feat: [재고] 적정재고 관리 기능 추가 (max_stock + over 상태 + update API)
This commit is contained in:
@@ -73,6 +73,32 @@ public function statsByItemType(): JsonResponse
|
||||
return ApiResponse::success($stats, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 재고 수정 (안전재고, 최대재고, 사용상태)
|
||||
*/
|
||||
public function update(int $id, Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$data = $request->validate([
|
||||
'safety_stock' => 'nullable|numeric|min:0',
|
||||
'max_stock' => 'nullable|numeric|min:0',
|
||||
'is_active' => 'nullable|boolean',
|
||||
]);
|
||||
|
||||
// 최대재고가 설정된 경우 안전재고 이상이어야 함
|
||||
if (isset($data['max_stock']) && $data['max_stock'] > 0
|
||||
&& isset($data['safety_stock']) && $data['safety_stock'] > $data['max_stock']) {
|
||||
return ApiResponse::error('최대재고는 안전재고 이상이어야 합니다.', 422);
|
||||
}
|
||||
|
||||
$stock = $this->service->updateStock($id, $data);
|
||||
|
||||
return ApiResponse::success($stock, __('message.updated'));
|
||||
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
|
||||
return ApiResponse::error(__('error.stock.not_found'), 404);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 재고 조정 이력 조회
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user