test(合并键): 钉住「同一天不同主系统分公司 ⇒ 拆两张单」(2026-10-27 裁决 §5.1)
- 同一天 + 不同主系统分公司 ⇒ 两个桶(不得并单:送达地址不同) - 同一天 + 同一主系统分公司 ⇒ 仍并一张(原口径不回退) - 行里没有主系统分公司 ⇒ 空键(与存量占坑行同口径) 设计:docs/design/20261027-分公司接入编码与主系统供应商绑定.md §5.1
This commit is contained in:
@@ -92,13 +92,26 @@ function row(over: Record<string, unknown>) {
|
||||
} as never;
|
||||
}
|
||||
|
||||
function group(orderCode: string, deliveryDate: string | null, names: string[]): MainOrderGroup {
|
||||
function group(
|
||||
orderCode: string,
|
||||
deliveryDate: string | null,
|
||||
names: string[],
|
||||
/** 主系统分公司(行的 `branch_code`);不传 = 行里没带(走主系统单号兜底/空键) */
|
||||
mainBranchCode?: string
|
||||
): MainOrderGroup {
|
||||
return {
|
||||
orderCode,
|
||||
deliveryDate,
|
||||
taskDay: deliveryDate,
|
||||
rows: names.map((itemName, index) =>
|
||||
row({ id: `${orderCode}-${index}`, orderCode, itemName, deliveryDate, prepareQty: index + 1 })
|
||||
row({
|
||||
id: `${orderCode}-${index}`,
|
||||
orderCode,
|
||||
itemName,
|
||||
deliveryDate,
|
||||
prepareQty: index + 1,
|
||||
...(mainBranchCode ? { branchCode: mainBranchCode } : {}),
|
||||
})
|
||||
),
|
||||
} as MainOrderGroup;
|
||||
}
|
||||
@@ -119,6 +132,45 @@ describe('按配送日合并', () => {
|
||||
expect(buckets[1].groups.map((g) => g.orderCode)).toEqual(['MO-C']);
|
||||
});
|
||||
|
||||
/**
|
||||
* 2026-10-27 裁决(接入编码设计 §5.1):合并键加上**主系统分公司**。
|
||||
* 为什么必须加:一个接入编码可被主系统 A/B/C 三行授权绑定 ⇒ 同一家我方分公司同一天会收到
|
||||
* 多个主系统分公司的货,而它们的**送达地址(各自分公司仓库)不同** ⇒ 并成一张单就会出现
|
||||
* "一张单两个送达地址",派车/送达/免入库取货全错。
|
||||
*/
|
||||
it('同一天但**主系统分公司不同** ⇒ 拆成两个桶(不得并单)', () => {
|
||||
const buckets = bucketGroupsByDeliveryDate([
|
||||
group('MO-A1', '2026-10-09', ['土豆'], 'BR002'),
|
||||
group('MO-B1', '2026-10-09', ['白菜'], 'BR003'),
|
||||
]);
|
||||
expect(buckets).toHaveLength(2);
|
||||
expect(buckets.map((b) => `${b.mainBranchCode}@${b.deliveryDate}`)).toEqual([
|
||||
'BR002@2026-10-09',
|
||||
'BR003@2026-10-09',
|
||||
]);
|
||||
expect(buckets[0].groups.map((g) => g.orderCode)).toEqual(['MO-A1']);
|
||||
expect(buckets[1].groups.map((g) => g.orderCode)).toEqual(['MO-B1']);
|
||||
});
|
||||
|
||||
it('同一天 + 同一主系统分公司 ⇒ 仍并成一张单(原口径不回退)', () => {
|
||||
const buckets = bucketGroupsByDeliveryDate([
|
||||
group('MO-A1', '2026-10-09', ['土豆'], 'BR002'),
|
||||
group('MO-A2', '2026-10-09', ['白菜'], 'BR002'),
|
||||
]);
|
||||
expect(buckets).toHaveLength(1);
|
||||
expect(buckets[0].mainBranchCode).toBe('BR002');
|
||||
expect(buckets[0].groups.map((g) => g.orderCode)).toEqual(['MO-A1', 'MO-A2']);
|
||||
});
|
||||
|
||||
it('行里没有主系统分公司 ⇒ 归到空键(与存量占坑行同口径)', () => {
|
||||
const buckets = bucketGroupsByDeliveryDate([
|
||||
group('MO-X', '2026-10-09', ['土豆']),
|
||||
group('MO-Y', '2026-10-09', ['白菜'], 'BR002'),
|
||||
]);
|
||||
expect(buckets).toHaveLength(2);
|
||||
expect(buckets.map((b) => b.mainBranchCode)).toEqual(['', 'BR002']);
|
||||
});
|
||||
|
||||
it('配送日缺失时用哨兵日兜底(不丢行)', () => {
|
||||
const buckets = bucketGroupsByDeliveryDate([group('MO-D', null, ['土豆'])]);
|
||||
expect(buckets).toHaveLength(1);
|
||||
|
||||
Reference in New Issue
Block a user