feat: [재고] 적정재고 관리 기능 추가 (max_stock + over 상태 + update API)

This commit is contained in:
김보곤
2026-03-21 07:59:53 +09:00
parent 5860262d87
commit 244a1f7a24
5 changed files with 94 additions and 0 deletions

View File

@@ -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);
}
}
/**
* 재고 조정 이력 조회
*/