26 lines
1.1 KiB
TypeScript
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");
|
|
});
|
|
});
|