feat(client): align account and order foundations

This commit is contained in:
2026-09-01 19:34:37 +08:00
parent c1e7ba411e
commit 1305ae4669
23 changed files with 602 additions and 258 deletions
@@ -140,6 +140,17 @@ test('requires public destination ids while keeping private addresses detached f
assert.ok(validateFirstLegOrderDraft(privateDraft).includes('私人地址不能引用平台公共仓库'))
})
test('requires customs inspection when any cargo is a wooden product', () => {
const draft = validDraft()
draft.items[0].woodenProduct = true
draft.customsInspection = null
assert.ok(validateFirstLegOrderDraft(draft).includes('木制品必须选择商检'))
draft.customsInspection = false
assert.ok(validateFirstLegOrderDraft(draft).includes('木制品必须选择商检'))
draft.customsInspection = true
assert.ok(!validateFirstLegOrderDraft(draft).includes('木制品必须选择商检'))
})
test('summarizes cargo values from line items', () => {
const first = validDraft().items[0]
const second = { ...first, id: 'cargo-2', pieces: 40, packageCount: 4, grossWeightKg: 300, volumeCbm: 1.25 }
@@ -84,6 +84,7 @@ export function createEmptyCargoItem(id = `cargo-${Date.now()}`): FirstLegCargoI
declaredValue: 0,
currency: 'USD',
dangerousGoods: false,
woodenProduct: false,
}
}
@@ -99,12 +100,14 @@ export function validateFirstLegOrderDraft(draft: FirstLegOrderDraft) {
if (!['TAX_INCLUDED', 'TAX_EXCLUDED'].includes(draft.pricingTaxMode)) errors.push('请选择报价包税方式')
if (!draft.receivingWarehouseId) errors.push('请选择平台收货仓')
if (draft.pickupMethod === 'PICKUP') {
if (!draft.senderAddressId) errors.push('请选择已保存的提货地址')
if (!draft.shipperPartySnapshot?.contactName.trim()) errors.push('请填写提货联系人')
if (!draft.shipperPartySnapshot?.phone.trim()) errors.push('请填写提货联系电话')
if (!draft.shipperPartySnapshot?.city.trim()) errors.push('请填写提货城市')
if (!draft.shipperPartySnapshot?.address.trim()) errors.push('请填写提货地址')
}
if (draft.destinationType === 'PRIVATE') {
if (!draft.privateDestinationAddressId) errors.push('请选择已保存的私人仓地址')
if (!draft.consigneePartySnapshot?.name.trim()) errors.push('请填写私人地址名称')
if (!draft.consigneePartySnapshot?.contactName.trim()) errors.push('请填写收件人姓名')
if (!draft.consigneePartySnapshot?.phone.trim()) errors.push('请填写收件人电话')
@@ -130,6 +133,9 @@ export function validateFirstLegOrderDraft(draft: FirstLegOrderDraft) {
if (item.grossWeightKg <= 0) errors.push(`${line}毛重必须大于 0`)
if (item.volumeCbm <= 0) errors.push(`${line}体积必须大于 0`)
})
if (draft.items.some((item) => item.woodenProduct) && draft.customsInspection !== true) {
errors.push('木制品必须选择商检')
}
return errors
}