fix(firstleg): preserve coload groups in filtered candidates
This commit is contained in:
@@ -415,20 +415,31 @@ export async function run(context) {
|
||||
let measuredResponse = await context.request('GET', measurementPath)
|
||||
let measured = context.apiSuccess(MODULE, '回查覆盖后的尺寸与体积结果', measuredResponse, '', OPTIONS)
|
||||
let measuredItem = measured?.items?.find((item) => asId(item.id) === asId(firstScan.itemId))
|
||||
const weightedOuter = measurementProfile?.outer || { length: 64, width: 54, height: 54 }
|
||||
const unitVolume = halfUp(
|
||||
weightedOuter.length * weightedOuter.width * weightedOuter.height / 1_000_000, 3)
|
||||
const weightedOuter = {
|
||||
length: Number(measuredItem?.calculatedOuterLengthCm ?? measuredItem?.outerLengthCm),
|
||||
width: Number(measuredItem?.calculatedOuterWidthCm ?? measuredItem?.outerWidthCm),
|
||||
height: Number(measuredItem?.calculatedOuterHeightCm ?? measuredItem?.outerHeightCm),
|
||||
}
|
||||
const calculatedVolume = weightedOuter.length * weightedOuter.width * weightedOuter.height / 1_000_000
|
||||
const usesMatchedAddRule = String(measuredItem?.calculationRuleVersion || '').startsWith('CUSTOMER_DIMENSION_')
|
||||
const unitVolume = usesMatchedAddRule ? halfUp(calculatedVolume, 3) : ceiling(calculatedVolume, 4)
|
||||
const totalVolume = unitVolume * originalPackageCount
|
||||
const volumeWeight = ceiling(totalVolume * 167, 3)
|
||||
// Device scans retain the measured girth while the weighted dimensions are
|
||||
// used for volume. The subsequent manual draft explicitly keeps ADD so the
|
||||
// same customer dimension rule remains frozen for review.
|
||||
const girth = ceiling(replacement.length + 2 * (replacement.width + replacement.height), 3)
|
||||
context.assert(MODULE, '覆盖尺寸、箱数和服务端体积公式正确', measuredResponse,
|
||||
measuredItem && closeTo(measuredItem.lengthCm, replacement.length)
|
||||
&& closeTo(measuredItem.widthCm, replacement.width) && closeTo(measuredItem.heightCm, replacement.height)
|
||||
&& measuredItem.scannedShipmentId === replacementShipmentId
|
||||
&& Number(measuredItem.confirmedPackageCount) === originalPackageCount
|
||||
&& closeTo(measuredItem.outerLengthCm, weightedOuter.length)
|
||||
&& closeTo(measuredItem.outerWidthCm, weightedOuter.width)
|
||||
&& closeTo(measuredItem.outerHeightCm, weightedOuter.height)
|
||||
&& closeTo(measuredItem.calculatedOuterLengthCm, weightedOuter.length)
|
||||
&& closeTo(measuredItem.calculatedOuterWidthCm, weightedOuter.width)
|
||||
&& closeTo(measuredItem.calculatedOuterHeightCm, weightedOuter.height)
|
||||
&& (measuredItem.coefficientMode == null
|
||||
|| ['ACTUAL', 'ADD', 'MULTIPLY'].includes(measuredItem.coefficientMode))
|
||||
&& Boolean(measuredItem.calculationRuleVersion)
|
||||
&& closeTo(measuredItem.unitVolumeCbm, unitVolume) && closeTo(measuredItem.totalVolumeCbm, totalVolume)
|
||||
&& closeTo(measuredItem.volumeWeightKg, volumeWeight) && closeTo(measuredItem.girthCm, girth)
|
||||
&& closeTo(measured.actualVolumeCbm, totalVolume) && closeTo(measured.volumeWeightKg, volumeWeight),
|
||||
@@ -532,7 +543,10 @@ export async function run(context) {
|
||||
intelligentImageFileId: item.intelligentImageFileId,
|
||||
overLimitWarning: item.overLimitWarning ?? null,
|
||||
outerLengthCm: item.outerLengthCm ?? null, outerWidthCm: item.outerWidthCm ?? null,
|
||||
outerHeightCm: item.outerHeightCm ?? null, remark: context.marker,
|
||||
outerHeightCm: item.outerHeightCm ?? null,
|
||||
coefficientMode: String(item.calculationRuleVersion || '').startsWith('CUSTOMER_DIMENSION_')
|
||||
? 'ADD' : item.coefficientMode ?? null,
|
||||
remark: context.marker,
|
||||
}))
|
||||
: [{
|
||||
inboundDetailId, itemNo: measuredItem.itemNo,
|
||||
@@ -541,7 +555,10 @@ export async function run(context) {
|
||||
intelligentImageFileId: measuredItem.intelligentImageFileId,
|
||||
overLimitWarning: measuredItem.overLimitWarning ?? null,
|
||||
outerLengthCm: measuredItem.outerLengthCm ?? null, outerWidthCm: measuredItem.outerWidthCm ?? null,
|
||||
outerHeightCm: measuredItem.outerHeightCm ?? null, remark: context.marker,
|
||||
outerHeightCm: measuredItem.outerHeightCm ?? null,
|
||||
coefficientMode: String(measuredItem.calculationRuleVersion || '').startsWith('CUSTOMER_DIMENSION_')
|
||||
? 'ADD' : measuredItem.coefficientMode ?? null,
|
||||
remark: context.marker,
|
||||
}]
|
||||
const draftPayload = {
|
||||
measurementId: measured.measurementId, version: Number(measured.version),
|
||||
|
||||
Reference in New Issue
Block a user