diff --git a/src/components/InventorySearch/LotLabelPrintModal.tsx b/src/components/InventorySearch/LotLabelPrintModal.tsx index 1a7c530..20f5026 100644 --- a/src/components/InventorySearch/LotLabelPrintModal.tsx +++ b/src/components/InventorySearch/LotLabelPrintModal.tsx @@ -291,16 +291,20 @@ const LotLabelPrintModal: React.FC = ({ const list = (analysis.sameItemLots ?? []).filter( (x) => Number(x.availableQty) > 0 && !!String(x.lotNo || "").trim(), ); - const scannedLot = analysis.scanned?.inventoryLotLineId + const scannedLotLineId = analysis.scanned?.inventoryLotLineId; + const scannedRow = scannedLotLineId + ? list.find((x) => x.inventoryLotLineId === scannedLotLineId) + : undefined; + const scannedLot = scannedLotLineId ? { lotNo: analysis.scanned.lotNo, - inventoryLotLineId: analysis.scanned.inventoryLotLineId, - availableQty: (list.find( - (x) => x.inventoryLotLineId === analysis.scanned.inventoryLotLineId, - )?.availableQty ?? 0) as number, - uom: (list.find( - (x) => x.inventoryLotLineId === analysis.scanned.inventoryLotLineId, - )?.uom ?? "") as string, + inventoryLotLineId: scannedLotLineId, + availableQty: (scannedRow?.availableQty ?? 0) as number, + uom: (scannedRow?.uom ?? "") as string, + warehouseCode: + analysis.scanned.warehouseCode ?? scannedRow?.warehouseCode, + warehouseName: + analysis.scanned.warehouseName ?? scannedRow?.warehouseName, _scanned: true as const, } : null; @@ -308,7 +312,7 @@ const LotLabelPrintModal: React.FC = ({ const merged = [ ...(scannedLot ? [scannedLot] : []), ...list - .filter((x) => x.inventoryLotLineId !== scannedLot?.inventoryLotLineId) + .filter((x) => x.inventoryLotLineId !== scannedLotLineId) .map((x) => ({ ...x, _scanned: false as const })), ];