Files
inquiry_robot/inquiry-backend/tests/quoteFeeLines.spec.ts
T
linmianxun bcaaf5d50d 空运按计费重改价不再把整票金额当单价,陆运多段费用行按段补线路名
- 空运调价:无数量时单价留空,避免出单按「单价×计费重」再乘一遍(WO202611250038 金额被放大)
- 报价模板:unit_price 只取单价字段,amount 仅作行合计,不再回退成单价
- 陆运一条线路多段时,同名费用行按段号/腿号补「起运 → 目的」展示名,后台与前端一致,不改金额与原名匹配
- 同义词扫描先剥掉补问清单示例行,避免示例车型/口岸覆盖销售实填值;车型正则补平板/高栏/厢车/冷藏等后缀
- 补空运计费重、报价行、陆运线路标签相关单测
2026-12-06 09:25:35 +08:00

93 lines
3.2 KiB
TypeScript

/**
* 后台「TMS标准报价」费用行:陆运同名运输费要能看出是哪一段。
*/
import { applyLandLegLabels, landLegRows } from '/@/views/inquiry/workOrder/quoteFeeLines';
function fees() {
return [
{ name: '运输费', amount: 'CNY 9000', segmentSequence: 1, routeLegSequence: 1 },
{ name: '运输费', amount: 'CNY 9600', segmentSequence: 1, routeLegSequence: 2 },
];
}
const payload = {
landSegments: [
{ origin: '上海', destination: '凭祥', segmentSequence: 1, routeLegSequence: 1 },
{ origin: '凭祥', destination: '胡志明', segmentSequence: 1, routeLegSequence: 2 },
],
};
test('按段号+腿号补起止地', () => {
const rows = fees();
applyLandLegLabels(rows, payload);
expect(rows.map((x) => x.name)).toEqual(['运输费(上海 → 凭祥)', '运输费(凭祥 → 胡志明)']);
});
test('费用行没有段号时按行序配对', () => {
const rows = [
{ name: '运输费', amount: 'CNY 9000' },
{ name: '运输费', amount: 'CNY 9600' },
];
applyLandLegLabels(rows, {
route_rows: JSON.stringify([
{ origin: '上海', destination: '凭祥', routeLegSequence: 1 },
{ origin: '凭祥', destination: '胡志明', routeLegSequence: 2 },
]),
});
expect(rows.map((x) => x.name)).toEqual(['运输费(上海 → 凭祥)', '运输费(凭祥 → 胡志明)']);
});
test('只有 selected_land_route 时也读它下面的 legs', () => {
const rows = [
{ name: '运输费', amount: 'CNY 9000' },
{ name: '运输费', amount: 'CNY 9600' },
];
applyLandLegLabels(rows, {
selected_land_route: JSON.stringify({
segmentSequence: 1,
legs: [
{ origin: '上海', destination: '凭祥', routeLegSequence: 1 },
{ origin: '凭祥', destination: '胡志明', routeLegSequence: 2 },
],
}),
});
expect(rows.map((x) => x.name)).toEqual(['运输费(上海 → 凭祥)', '运输费(凭祥 → 胡志明)']);
});
test('费用名不重复或只有一段时不改展示名', () => {
const unique = [
{ name: '运输费', amount: 'CNY 9000' },
{ name: '报关费', amount: 'CNY 300' },
];
applyLandLegLabels(unique, payload);
expect(unique.map((x) => x.name)).toEqual(['运输费', '报关费']);
const oneLeg = [
{ name: '运输费', amount: 'CNY 9000' },
{ name: '运输费', amount: 'CNY 9600' },
];
applyLandLegLabels(oneLeg, { landSegments: [payload.landSegments[0]] });
expect(oneLeg.map((x) => x.name)).toEqual(['运输费', '运输费']);
});
test('landSegments 是 JSON 串也能读,缺站名时退回第 N 段', () => {
const rows = landLegRows({
landSegments: JSON.stringify([
{ segmentSequence: 1, routeLegSequence: 1 },
{ segmentSequence: 1, routeLegSequence: 2 },
]),
});
expect(rows).toHaveLength(2);
const labeled = [
{ name: '运输费', amount: 'CNY 9000' },
{ name: '运输费', amount: 'CNY 9600' },
];
applyLandLegLabels(labeled, {
landSegments: JSON.stringify([
{ segmentSequence: 1, routeLegSequence: 1 },
{ segmentSequence: 1, routeLegSequence: 2 },
]),
});
expect(labeled.map((x) => x.name)).toEqual(['运输费(第1段)', '运输费(第2段)']);
});