diff --git a/app/Services/StockService.php b/app/Services/StockService.php index d3ff99e6..5448a137 100644 --- a/app/Services/StockService.php +++ b/app/Services/StockService.php @@ -228,7 +228,12 @@ public function adjustments(int $stockId): array { $tenantId = $this->tenantId(); - $stock = Stock::where('tenant_id', $tenantId)->findOrFail($stockId); + // stockId 또는 item_id로 Stock 검색 + $stock = Stock::where('tenant_id', $tenantId)->find($stockId) + ?? Stock::where('tenant_id', $tenantId)->where('item_id', $stockId)->first(); + if (! $stock) { + throw new \Illuminate\Database\Eloquent\ModelNotFoundException; + } $transactions = StockTransaction::where('tenant_id', $tenantId) ->where('stock_id', $stock->id) @@ -256,7 +261,12 @@ public function createAdjustment(int $stockId, array $data): array $userId = $this->apiUserId(); return DB::transaction(function () use ($stockId, $data, $tenantId, $userId) { - $stock = Stock::where('tenant_id', $tenantId)->findOrFail($stockId); + // stockId 또는 item_id로 Stock 검색 (목록 API가 Item ID를 반환하므로) + $stock = Stock::where('tenant_id', $tenantId)->find($stockId) + ?? Stock::where('tenant_id', $tenantId)->where('item_id', $stockId)->first(); + if (! $stock) { + throw new \Illuminate\Database\Eloquent\ModelNotFoundException; + } $qty = (float) $data['quantity'];