feat: [재고] 적정재고 관리 기능 추가 (max_stock + over 상태 + update API)
This commit is contained in:
@@ -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')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 재고 조정 이력 조회
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user