This commit is contained in:
2026-10-13 21:27:46 +08:00
parent 90ef9893f3
commit d28408f678
4 changed files with 35 additions and 3 deletions
@@ -8,6 +8,11 @@ const compiled = ts.transpileModule(source, { compilerOptions: { target: ts.Scri
const exports = {}
new Function('exports', compiled)(exports)
test('多次签收的字符串箱数按数值累计:三箱加四箱等于七箱', () => {
assert.equal(exports.receiptPrintableBoxCount([{ boxCount: '3' }, { boxCount: '4' }]), 7)
assert.equal(exports.receiptPrintableBoxCount([{ boxCount: '3', labels: [{}, {}, {}] }, { boxCount: '4', labels: [{}, {}, {}, {}] }]), 7)
})
test('签收箱号只包含箱子和托盘签收,包裹实物记录不重复展示为箱子', () => {
const receipts = [{ receiptNo: 'PARCEL-1', unitType: 'PARCEL' }, { receiptNo: 'BOX-1', unitType: 'BOX' }, { receiptNo: 'PALLET-1', unitType: 'PALLET' }]
const cartons = [{ receiptNo: 'PARCEL-1', cartonMark: 'RP-1' }, { receiptNo: 'BOX-1', cartonMark: 'RC-1' }, { receiptNo: 'PALLET-1', cartonMark: 'RC-2' }, { receiptNo: 'UNKNOWN', cartonMark: 'RP-UNKNOWN' }]
@@ -1,5 +1,9 @@
import type { ReturnPallet, ReturnReceipt, ReturnReceiptCarton } from '../api/returnOrders'
export function receiptPrintableBoxCount(receipts: ReturnReceipt[]) {
return receipts.reduce((total, receipt) => total + Number(receipt.labels?.length || receipt.boxCount || 1), 0)
}
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))