优化
This commit is contained in:
@@ -8,6 +8,13 @@ const compiled = ts.transpileModule(source, { compilerOptions: { target: ts.Scri
|
||||
const exports = {}
|
||||
new Function('exports', compiled)(exports)
|
||||
|
||||
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' }]
|
||||
assert.deepEqual(exports.receiptBoxDetails(receipts, cartons).map(item => item.cartonMark), ['RC-1', 'RC-2'])
|
||||
assert.deepEqual(exports.receiptBoxDetails(receipts.slice(0, 1), cartons), [])
|
||||
})
|
||||
|
||||
test('volume rounds upward to exactly three decimal places without increasing exact thousandths', () => {
|
||||
for (const [input, expected] of [[0.186624, '0.187'], [0.15, '0.150'], [1.001, '1.001'], [1.00100001, '1.002'], [0.0000001, '0.001'], [0, '0.000'], [null, '—'], [NaN, '—']]) {
|
||||
assert.equal(exports.formatReturnVolume(input), expected)
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import type { ReturnReceipt } from '../api/returnOrders'
|
||||
import type { ReturnReceipt, ReturnReceiptCarton } from '../api/returnOrders'
|
||||
|
||||
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))
|
||||
return cartons.filter(carton => boxReceiptNos.has(carton.receiptNo))
|
||||
}
|
||||
|
||||
export function receiptTrackingNo(receipt: Pick<ReturnReceipt, 'trackingNo' | 'unitCode' | 'unitType'> | Record<string, unknown>) {
|
||||
const trackingNo = typeof receipt.trackingNo === 'string' ? receipt.trackingNo.trim() : ''
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export function returnRelabelStatusLabel(status?: string) {
|
||||
const labels: Record<string, string> = { UNLABELLED: '未换标', BOUND: '处理中', PROCESSING: '处理中', PARTIALLY_COMPLETED: '部分完成', COMPLETED: '全部完成' }
|
||||
return status ? labels[status] || '—' : '—'
|
||||
}
|
||||
Reference in New Issue
Block a user