Files
SupplierSystem/server/tests/pickingZeroSalePriceReturnedRows.test.ts
T
Ubuntu b18eeae8c2
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s
fix(分拣): 零价校验排除已退回行——退货行 price 归零导致已在售订单被误拦「销售价为 0」
2026-10-24 11:28:58 +08:00

30 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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');
});
});