2026-08-27 16:17:11 +08:00
|
|
|
export const IMMUTABLE_TAILLEG_EVENT_FIXTURE = Object.freeze({
|
|
|
|
|
eventId: 'b569c7f6-3493-4a0f-a944-dd42698f183b',
|
|
|
|
|
status: 'PROCESSED',
|
|
|
|
|
payloadMutable: false,
|
|
|
|
|
reusableForAcceptance: false,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export const TAILLEG_ORDER_NUMBER = Object.freeze({
|
2026-10-21 07:53:31 +08:00
|
|
|
pattern: /^FL-WH-\d{8}-\d{6}$/,
|
|
|
|
|
timeZone: 'server-local',
|
2026-08-27 16:17:11 +08:00
|
|
|
sharedBy: 'containerNo',
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export function validOwnerSnapshots(orders, expectedCount = orders?.length) {
|
|
|
|
|
if (!Array.isArray(orders) || orders.length !== expectedCount || orders.length === 0) return false
|
|
|
|
|
const owners = new Set()
|
|
|
|
|
for (const order of orders) {
|
|
|
|
|
const customerId = String(order?.customerId ?? '').trim()
|
|
|
|
|
const customerName = String(order?.customerName ?? '').trim()
|
|
|
|
|
if (!customerId || !customerName) return false
|
|
|
|
|
owners.add(`${customerId}\u0000${customerName}`)
|
|
|
|
|
}
|
|
|
|
|
return owners.size === 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function validContainerOrderGroup(rows) {
|
|
|
|
|
if (!Array.isArray(rows) || rows.length === 0) return false
|
|
|
|
|
const containerNos = new Set(rows.map((row) => String(row?.containerNo ?? '').trim()))
|
|
|
|
|
const orderNos = new Set(rows.map((row) => String(row?.orderNo ?? '').trim()))
|
|
|
|
|
const sourceInboundIds = rows.map((row) => String(row?.sourceInboundId ?? '').trim())
|
|
|
|
|
return containerNos.size === 1 && !containerNos.has('')
|
|
|
|
|
&& orderNos.size === 1 && TAILLEG_ORDER_NUMBER.pattern.test([...orderNos][0])
|
|
|
|
|
&& sourceInboundIds.every(Boolean) && new Set(sourceInboundIds).size === rows.length
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function validEventReplay(before, after) {
|
|
|
|
|
return Number(before?.orderCount) === Number(after?.orderCount)
|
|
|
|
|
&& String(before?.orderNo ?? '') === String(after?.orderNo ?? '')
|
|
|
|
|
&& Number(before?.detailCount) === Number(after?.detailCount)
|
|
|
|
|
&& Number(before?.historyCount) === Number(after?.historyCount)
|
|
|
|
|
}
|