30 lines
1.5 KiB
TypeScript
30 lines
1.5 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
||
import { describe, expect, it } from 'vitest';
|
||
|
||
/**
|
||
* 分拣完成前的「销售价为 0」校验必须**排除已退回行**(2026-10-24 真机误拦)。
|
||
*
|
||
* 现象:订单详情里 4 行销售价 5/3/5/3 元都在,点「分拣完成」却被拦
|
||
* 「以下商品销售价为 0…木瓜、白心火龙果」。真因:退货留下 `is_returned=true` 的历史行,
|
||
* 其 price 被清零,旧查询把它们也算进来;而这些行在订单详情中**不显示** ⇒ 用户无从排查。
|
||
*/
|
||
const svc = readFileSync(new URL('../src/services/pickingService.ts', import.meta.url), 'utf8');
|
||
|
||
describe('分拣零价校验', () => {
|
||
it('零价查询排除 is_returned 行', () => {
|
||
const block = svc.slice(svc.indexOf('const zeroPriced'), svc.indexOf('if (zeroPriced.rowCount)'));
|
||
expect(block).toContain('COALESCE(is_returned, false) = false');
|
||
expect(block).toContain('COALESCE(price, 0) <= 0');
|
||
});
|
||
|
||
it('独立进货单豁免逻辑仍在(不因这次修改丢掉)', () => {
|
||
expect(svc).toContain("=== '__INDEPENDENT_INBOUND__'");
|
||
expect(svc).toContain('const checkedOrders = pickOrderCodes.filter');
|
||
});
|
||
|
||
it('覆盖范围仍按"该分拣单涉及的所有订单"(不是只看 picked SKU)', () => {
|
||
expect(svc).toContain('SELECT DISTINCT order_code FROM picking_items WHERE pick_code = $1');
|
||
expect(svc).toContain('SELECT order_code FROM picking_tasks WHERE pick_code = $1');
|
||
});
|
||
});
|