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

@@ -191,6 +191,36 @@ public function show(int $id): Item
->findOrFail($id);
}
/**
* 재고 수정 (안전재고, 최대재고, 사용상태)
*/
public function updateStock(int $id, array $data): Item
{
$tenantId = $this->tenantId();
$item = Item::where('tenant_id', $tenantId)->findOrFail($id);
$stock = $item->stock;
if ($stock) {
if (isset($data['safety_stock'])) {
$stock->safety_stock = $data['safety_stock'];
}
if (isset($data['max_stock'])) {
$stock->max_stock = $data['max_stock'];
}
$stock->status = $stock->calculateStatus();
$stock->updated_by = $this->apiUserId();
$stock->save();
}
if (isset($data['is_active'])) {
$item->is_active = $data['is_active'];
$item->save();
}
return $item->load(['stock.lots' => fn ($q) => $q->orderBy('fifo_order')]);
}
/**
* 재고 조정 이력 조회
*/