|
|
|
@@ -40,8 +40,11 @@ type SearchQuery = Partial< |
|
|
|
InventoryResult, |
|
|
|
| "id" |
|
|
|
| "qty" |
|
|
|
| "uomId" |
|
|
|
| "uomCode" |
|
|
|
| "uomUdfudesc" |
|
|
|
| "stockUomId" |
|
|
|
| "stockUomCode" |
|
|
|
| "germPerSmallestUnit" |
|
|
|
| "qtyPerSmallestUnit" |
|
|
|
| "itemSmallestUnit" |
|
|
|
@@ -71,7 +74,7 @@ const extractItemRecords = (res: unknown): ItemLookupRow[] => { |
|
|
|
return []; |
|
|
|
}; |
|
|
|
|
|
|
|
/** FP-MTMS Version Checklist | Functions Ref. No. 18 | v1.0.4 | 2026-09-10 */ |
|
|
|
/** FP-MTMS Version Checklist | Functions Ref. No. 18 | v1.0.5 | 2026-09-11 */ |
|
|
|
const InventorySearch: React.FC<Props> = ({ |
|
|
|
inventories, |
|
|
|
printerCombo, |
|
|
|
@@ -84,6 +87,11 @@ const InventorySearch: React.FC<Props> = ({ |
|
|
|
const canStockAdjust = hasAbility(abilities, AUTH.INVENTORY_ADJUST); |
|
|
|
const searchInFlightRef = useRef(false); |
|
|
|
|
|
|
|
const withUniqueInventoryRowId = useCallback((row: InventoryResult): InventoryResult => ({ |
|
|
|
...row, |
|
|
|
id: `${row.itemId}-${row.uomId ?? 0}-${row.id}`, |
|
|
|
}), []); |
|
|
|
|
|
|
|
const buildSyntheticInventory = useCallback((item: ItemLookupRow): InventoryResult => { |
|
|
|
const uom = item.uomDesc || item.uom || item.purchaseUnit || ''; |
|
|
|
return { |
|
|
|
@@ -134,7 +142,7 @@ const InventorySearch: React.FC<Props> = ({ |
|
|
|
const applyItemsAsSyntheticInventories = useCallback( |
|
|
|
(items: ItemLookupRow[]) => { |
|
|
|
if (!items.length) return false; |
|
|
|
const synthetics = items.map(buildSyntheticInventory); |
|
|
|
const synthetics = items.map(buildSyntheticInventory).map(withUniqueInventoryRowId); |
|
|
|
setFilteredInventories(synthetics); |
|
|
|
setInventoriesTotalCount(synthetics.length); |
|
|
|
setSelectedInventory(synthetics[0]); |
|
|
|
@@ -142,7 +150,7 @@ const InventorySearch: React.FC<Props> = ({ |
|
|
|
setInventoryLotLinesPagingController(() => defaultPagingController); |
|
|
|
return true; |
|
|
|
}, |
|
|
|
[buildSyntheticInventory], |
|
|
|
[buildSyntheticInventory, withUniqueInventoryRowId], |
|
|
|
); |
|
|
|
|
|
|
|
// Scan-mode UI (hardware QR scanner via QrCodeScannerProvider) |
|
|
|
@@ -253,23 +261,25 @@ const InventorySearch: React.FC<Props> = ({ |
|
|
|
const response = await fetchInventoriesLatest(params); |
|
|
|
|
|
|
|
if (response) { |
|
|
|
const records = (response.records ?? []).map(withUniqueInventoryRowId); |
|
|
|
setInventoriesTotalCount(response.total); |
|
|
|
switch (actionType) { |
|
|
|
case 'init': |
|
|
|
case 'reset': |
|
|
|
case 'search': |
|
|
|
setFilteredInventories(() => response.records); |
|
|
|
setFilteredInventories(() => records); |
|
|
|
break; |
|
|
|
case 'paging': |
|
|
|
setFilteredInventories((fi) => |
|
|
|
uniqBy([...fi, ...response.records], (row) => `${row.itemId}-${row.uomId ?? row.uomUdfudesc ?? ''}`), |
|
|
|
uniqBy([...fi, ...records], (row) => `${row.itemId}-${row.uomId ?? row.uomUdfudesc ?? ''}`), |
|
|
|
); |
|
|
|
} |
|
|
|
return { ...response, records }; |
|
|
|
} |
|
|
|
|
|
|
|
return response; |
|
|
|
}, |
|
|
|
[enableLocationFilter, location, withLocationParams], |
|
|
|
[enableLocationFilter, location, withLocationParams, withUniqueInventoryRowId], |
|
|
|
); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|