Files
SupplierSystem/server/tests/autoCompletePurchaseZeroCost.test.ts
Ubuntu 495d5907ca
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(采购): 配送核货/分拣自动补完成允许0成本
手工采购完成仍受允许成本价为0开关控制;配送核货自动收口不被0成本卡住。
2026-10-26 17:23:08 +08:00

29 lines
1.4 KiB
TypeScript

import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
const read = (rel: string) => readFileSync(new URL(`../${rel}`, import.meta.url), 'utf8');
const svc = read('src/services/purchaseOperationService.ts');
const backfill = read('src/services/deliveryLoadingBackfillService.ts');
const picking = read('src/services/pickingService.ts');
const manual = read('src/routes/mobile/mobilePurchaseRoutes.ts');
describe('自动补完成采购允许 0 成本', () => {
it('internal allowZeroCost 仅 status20 放行 0/未填,负数/NaN 仍拒', () => {
expect(svc).toContain('allowZeroCost?: boolean');
expect(svc).toContain('const internalAllowZeroCost = input.allowZeroCost === true');
expect(svc).toContain('selfProcessed || warehouseDemand || internalAllowZeroCost');
expect(svc).toContain('!Number.isFinite(effectivePrice) || effectivePrice < 0');
expect(svc).toContain('if (actualPrice === null || actualPrice <= 0) actualPrice = 0');
});
it('自动补完成 4 处传 true;手工路由不传', () => {
expect((backfill.match(/allowZeroCost: true/g) || []).length).toBe(3);
expect((picking.match(/allowZeroCost: true/g) || []).length).toBe(1);
expect(manual).not.toContain('allowZeroCost');
});
it('zeroPurchaseCost 清计划价逻辑认 internal flag', () => {
expect(svc).toContain('if (internalAllowZeroCost || Boolean(flagRow.rows[0]?.self_processed)');
});
});