优化
This commit is contained in:
@@ -21,6 +21,16 @@ test('volume rounds upward to exactly three decimal places without increasing ex
|
||||
}
|
||||
})
|
||||
|
||||
test('箱子在签收箱号明细展示一次,真实托盘和缺少箱号明细的实物仍保留', () => {
|
||||
const boxes = Array.from({ length: 6 }, (_, index) => ({ cartonMark: `RC-${index}` }))
|
||||
const units = boxes.map(box => ({ unitType: 'BOX', unitCode: box.cartonMark, palletCode: 'PLT-SHARED' }))
|
||||
assert.deepEqual(exports.receiptPhysicalDetails(units, boxes), [])
|
||||
const pallet = { unitType: 'PALLET', unitCode: 'PLT-SHARED', palletCode: 'PLT-SHARED' }
|
||||
const unmatchedBox = { unitType: 'BOX', unitCode: 'RC-UNKNOWN', palletCode: 'PLT-SHARED' }
|
||||
assert.deepEqual(exports.receiptPhysicalDetails([...units, pallet, unmatchedBox], boxes), [pallet, unmatchedBox])
|
||||
assert.deepEqual(exports.receiptPhysicalDetails(units, []), units)
|
||||
})
|
||||
|
||||
test('parcel waybills appear as tracking numbers while generated parcel codes remain physical codes', () => {
|
||||
assert.equal(exports.receiptTrackingNo({ unitType: 'PARCEL', unitCode: 'sf561626' }), 'sf561626')
|
||||
assert.equal(exports.receiptTrackingNo({ unitType: 'PARCEL', unitCode: 'PK0123456789ABCDEF' }), '')
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import type { ReturnReceipt, ReturnReceiptCarton } from '../api/returnOrders'
|
||||
import type { ReturnPallet, ReturnReceipt, ReturnReceiptCarton } from '../api/returnOrders'
|
||||
|
||||
export function receiptPhysicalDetails(pallets: ReturnPallet[], boxes: ReturnReceiptCarton[]) {
|
||||
const signedBoxMarks = new Set(boxes.map(box => box.cartonMark))
|
||||
return pallets.filter(unit => unit.unitType !== 'BOX' || !signedBoxMarks.has(unit.unitCode || unit.palletCode))
|
||||
}
|
||||
|
||||
export function receiptBoxDetails(receipts: Pick<ReturnReceipt, 'receiptNo' | 'unitType'>[], cartons: ReturnReceiptCarton[]) {
|
||||
const boxReceiptNos = new Set(receipts.filter(receipt => receipt.unitType === 'BOX' || receipt.unitType === 'PALLET').map(receipt => receipt.receiptNo))
|
||||
|
||||
Reference in New Issue
Block a user