Files
SupplierSystem/server/tests/stockCoverOnlyActualPickingLock.test.ts
T
Ubuntu f1fe645f8c
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(库存抵扣): 未开拣分拣行不再锁死库存抵扣
早期任务下单即建 picking_items;仅实际已拣/已核货/已出库才锁定 cover,未开拣允许重算。
2026-10-26 17:03:48 +08:00

26 lines
1.1 KiB
TypeScript

import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
const src = readFileSync(
new URL('../src/services/inventoryStockCoverService.ts', import.meta.url),
'utf8'
);
describe('库存抵扣锁定仅在真实拣货/核货/出库后生效', () => {
it('未开拣的空 picking_items 不再锁死抵扣', () => {
const start = src.indexOf('async function loadLockedStockCoverIfInboundOrPicking');
const end = src.indexOf('export async function applyStockCoverForOrderItem', start);
const fn = src.slice(start, end);
expect(fn).toContain('COALESCE(pi.picked_qty, 0) > 0');
expect(fn).toContain('COALESCE(pi.loaded_qty, 0) > 0');
expect(fn).toContain('COALESCE(pi.review_status, 0) >= 20');
expect(fn).toContain('COALESCE(pt.pick_status, 10) >= 30');
expect(fn).not.toContain('EXISTS (\n SELECT 1 FROM picking_items pi WHERE pi.order_item_id = oi.id\n )');
});
it('已入库锁定保留', () => {
expect(src).toContain('AS has_inbound');
expect(src).toContain("NULLIF(TRIM(i.inbound_batch_no), '') IS NOT NULL");
});
});