From 85efad22ca3a6dd1182d0a1970d3bcc9bceb0f33 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 17:41:15 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[=EC=9E=90=EC=9E=AC=ED=88=AC=EC=9E=85]?= =?UTF-8?q?=20physicalAvail=EC=9D=84=20SUM=EC=9C=BC=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=E2=80=94=20=EB=AA=A8=EB=93=A0=20=EA=B7=B8=EB=A3=B9?= =?UTF-8?q?=EC=9D=98=20=EA=B8=B0=ED=88=AC=EC=9E=85=20=ED=95=A9=EC=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - max() → SUM: 같은 LOT의 기투입(lotInputtedQty)을 모든 그룹에서 합산 - replace 모드에서 각 그룹의 기투입이 복원되므로 합산이 정확 - 예: 가용4 + 상부덮개기투입3 + 마구리기투입1 = 총8 (max는 7로 부정확) --- .../WorkerScreen/MaterialInputModal.tsx | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/components/production/WorkerScreen/MaterialInputModal.tsx b/src/components/production/WorkerScreen/MaterialInputModal.tsx index f5e85204..449ef9b0 100644 --- a/src/components/production/WorkerScreen/MaterialInputModal.tsx +++ b/src/components/production/WorkerScreen/MaterialInputModal.tsx @@ -203,15 +203,20 @@ export function MaterialInputModal({ const allocations = useMemo(() => { const result = new Map(); - // 물리 LOT별 최대 가용량 초기화 + // 물리 LOT별 실제 가용량: lotAvailableQty + SUM(모든 그룹의 lotInputtedQty) const physicalAvail = new Map(); + const lotBaseAvail = new Map(); for (const group of materialGroups) { for (const lot of group.lots) { if (!lot.stockLotId) continue; const itemInput = lot as unknown as MaterialForItemInput; - const totalAvail = lot.lotAvailableQty + (itemInput.lotInputtedQty ?? 0); - const current = physicalAvail.get(lot.stockLotId) ?? 0; - if (totalAvail > current) physicalAvail.set(lot.stockLotId, totalAvail); + const inputted = itemInput.lotInputtedQty ?? 0; + if (!lotBaseAvail.has(lot.stockLotId)) { + lotBaseAvail.set(lot.stockLotId, lot.lotAvailableQty); + physicalAvail.set(lot.stockLotId, lot.lotAvailableQty + inputted); + } else { + physicalAvail.set(lot.stockLotId, (physicalAvail.get(lot.stockLotId) ?? 0) + inputted); + } } } const physicalUsed = new Map(); @@ -301,19 +306,22 @@ export function MaterialInputModal({ const handleAutoFill = useCallback(() => { const newSelected = new Set(); const newAllocations = new Map(); - // 물리 LOT별 실제 가용량 추적 (lotAvailableQty 기준, 기투입분 포함 복원량으로 초기화) - const physicalAvail = new Map(); - // 1차: 물리 LOT별 최대 가용량 초기화 (lotAvailableQty + 전체 기투입량) + // 물리 LOT별 실제 가용량 계산: lotAvailableQty + SUM(모든 그룹의 lotInputtedQty) + // replace 모드에서 기투입분이 복원되므로 모든 그룹의 기투입을 합산 + const physicalAvail = new Map(); + const lotBaseAvail = new Map(); + for (const group of materialGroups) { for (const lot of group.lots) { if (!lot.stockLotId) continue; const itemInput = lot as unknown as MaterialForItemInput; - const totalAvail = lot.lotAvailableQty + (itemInput.lotInputtedQty ?? 0); - // 같은 stockLotId의 최대값 유지 (기투입이 가장 큰 값이 실제 원래 가용량) - const current = physicalAvail.get(lot.stockLotId) ?? 0; - if (totalAvail > current) { - physicalAvail.set(lot.stockLotId, totalAvail); + const inputted = itemInput.lotInputtedQty ?? 0; + if (!lotBaseAvail.has(lot.stockLotId)) { + lotBaseAvail.set(lot.stockLotId, lot.lotAvailableQty); + physicalAvail.set(lot.stockLotId, lot.lotAvailableQty + inputted); + } else { + physicalAvail.set(lot.stockLotId, (physicalAvail.get(lot.stockLotId) ?? 0) + inputted); } } }