From 7a50300c45cdb71433d4a97db8eac5134d9ba88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Sun, 22 Mar 2026 19:09:44 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[=EC=9E=AC=EA=B3=A0=EC=A1=B0=EC=A0=95]?= =?UTF-8?q?=20Item=20ID=EB=A1=9C=EB=8F=84=20Stock=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EA=B0=80=EB=8A=A5=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 목록 API가 Item ID를 반환하므로, adjustments/createAdjustment에서 Stock ID 검색 실패 시 item_id로 재검색 - 404 "재고 정보를 찾을 수 없습니다" 오류 해결 --- app/Services/StockService.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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'];