fix: refresh PDA task version after immediate pick

This commit is contained in:
2026-09-16 11:05:22 +08:00
parent d46a0ee6d2
commit 19334fc4a2
2 changed files with 16 additions and 2 deletions
+5 -1
View File
@@ -191,7 +191,11 @@ export function normalizePickingTask(task = {}) {
orderNo: task.orderNo ?? task.order?.orderNo ?? '',
inboundCode: task.inboundCode ?? task.inbound?.inboundCode ?? '',
warehouseName: task.warehouseName ?? task.warehouse?.name ?? '',
pickingVersion: task.pickingVersion ?? task.version ?? null,
// `version` is the canonical task version returned by the loading API.
// Prefer it over a previously normalized alias when merging a mutation
// response, otherwise the next immediate pallet action reuses a stale
// expectedTaskVersion and is rejected as a concurrent update.
pickingVersion: task.version ?? task.pickingVersion ?? null,
inboundVersion: task.inboundVersion ?? null
}
}
+11 -1
View File
@@ -62,7 +62,7 @@ test('C02 identifiers and separate picking/inbound versions are normalized expli
assert.match(source, /inboundId: row\.inboundId/)
assert.match(source, /inboundVersion: row\.inboundVersion/)
assert.match(source, /pickingVersion: row\.pickingVersion \?\? row\.loading\?\.pickingVersion/)
assert.match(source, /pickingVersion: task\.pickingVersion \?\? task\.version/)
assert.match(source, /pickingVersion: task\.version \?\? task\.pickingVersion/)
assert.match(page, /version: Number\(this\.pickingVersion\)/)
assert.match(page, /ITEM_STATUS, classifyScan, createItemStates, getPickSummary, isSealedPalletItem, submitStates/)
assert.match(page, /taskItemId: item\.id \?\? item\.itemId/)
@@ -100,6 +100,16 @@ test('picking page exposes five evidence slots, retry and remote completion stat
assert.match(page, /evidenceComplete/)
})
test('immediate task responses replace a stale normalized picking version', () => {
const normalizeSource = source.match(/export function normalizePickingTask\(task = \{\}\) \{[\s\S]*?\n\}/)?.[0]
assert.ok(normalizeSource)
const normalizePickingTask = new Function(`${normalizeSource.replace('export function', 'function')}; return normalizePickingTask`)()
const previous = normalizePickingTask({ id: 'task-1', version: 3 })
assert.equal(previous.pickingVersion, 3)
const mergedMutationResponse = normalizePickingTask({ ...previous, version: 4 })
assert.equal(mergedMutationResponse.pickingVersion, 4)
})
test('PDA evidence binding normalizes string ids from the task-scoped DTO', () => {
assert.match(page, /evidenceItems\(result\)[\s\S]*?id: String\(item\.evidenceId \?\? item\.id/)
assert.match(page, /fileId: String\(item\.fileId/)