2026-08-24 19:29:41 +08:00
|
|
|
export const RECEIVING_PHOTO_ROLES = ['LICENSE_PLATE', 'CONTAINER_SEAL', 'DOOR_OPEN']
|
|
|
|
|
|
|
|
|
|
const number = (value) => Math.max(0, Number(value || 0))
|
|
|
|
|
|
|
|
|
|
export function normalizeReceivingInbound(value = {}) {
|
|
|
|
|
return {
|
|
|
|
|
...value,
|
|
|
|
|
plannedPalletCount: number(value.plannedPalletCount),
|
|
|
|
|
totalPackages: number(value.totalPackages),
|
|
|
|
|
receivedPackages: number(value.receivedPackages),
|
|
|
|
|
pendingPackages: number(value.pendingPackages)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function normalizeReceivingCandidate(value = {}) {
|
|
|
|
|
return {
|
|
|
|
|
...value,
|
|
|
|
|
destinationCodes: Array.isArray(value.destinationCodes) ? value.destinationCodes.filter(Boolean) : [],
|
|
|
|
|
plannedPalletCount: number(value.plannedPalletCount),
|
|
|
|
|
totalPackages: number(value.totalPackages),
|
|
|
|
|
receivedPackages: number(value.receivedPackages),
|
|
|
|
|
currentAccount: value.currentAccount === true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function normalizeReceivingSession(value) {
|
|
|
|
|
if (!value) return null
|
2026-08-26 15:24:51 +08:00
|
|
|
const photos = Array.isArray(value.photos)
|
|
|
|
|
? value.photos.map((photo) => ({ ...photo, fileId: String(photo.fileId) }))
|
|
|
|
|
: []
|
2026-08-24 19:29:41 +08:00
|
|
|
return {
|
|
|
|
|
...value,
|
2026-08-26 15:59:08 +08:00
|
|
|
photos: RECEIVING_PHOTO_ROLES.map((role) => photos.find((photo) => photo?.role === role && photo?.fileId)).filter(Boolean),
|
2026-08-24 19:29:41 +08:00
|
|
|
totalPackages: number(value.totalPackages),
|
|
|
|
|
receivedPackages: number(value.receivedPackages),
|
|
|
|
|
pendingPackages: number(value.pendingPackages),
|
|
|
|
|
inbounds: Array.isArray(value.inbounds) ? value.inbounds.map(normalizeReceivingInbound) : []
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function isNoCurrentReceiving(error) {
|
|
|
|
|
return ['404', 'A0404', 'B0404'].includes(String(error?.code || ''))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function isReceivingConflict(error) {
|
|
|
|
|
return ['409', 'A0409', 'B0409'].includes(String(error?.code || ''))
|
|
|
|
|
}
|