来源仓库:jxc/ai-fresh-delivery 来源提交:f0b1a180e2deb7e4673b9d1c8542619f7bc0f73d 快照树: 09f679334ff38f0ff25e907961c94a8223bcaedd(与来源 HEAD 工作树逐字节一致,3801 个文件) 按约定本仓库不带任何历史提交:来源仓库的历史中含真实凭据 (生产 SSH 私钥 deploy/id_rsa_tencent、server/.env、.env.tencent/.env.production/.env.gitea、 deploy/小程序AppSecret.txt,其中 MP_APPSECRET / S3 AccessKey 经哈希比对与线上同值), 整包推送会把这些凭据永久带入本仓库,故只取「当前版本」的单提交快照。 供应商系统后续开发自本提交开始。
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
||
|
||
/**
|
||
* 行为契约:自采验收不套过手 120% 闸门。
|
||
* 实现见 inspectionComplianceService.submitInspectionCompliance —
|
||
* source_type=purchase 或 processing_details 含 purchase_code 时跳过 assertPassThroughOverQtyConfirmed。
|
||
*/
|
||
describe('自采验收跳过过手超量闸门', () => {
|
||
function shouldSkipPassThroughOverQtyGate(input: {
|
||
source_type?: string | null;
|
||
processing_details?: unknown;
|
||
}): boolean {
|
||
const codes = new Set<string>();
|
||
const details = input.processing_details;
|
||
if (details && typeof details === 'object' && !Array.isArray(details)) {
|
||
const primary = String((details as { purchase_code?: unknown }).purchase_code || '').trim();
|
||
if (primary) codes.add(primary);
|
||
const arr = (details as { purchase_codes?: unknown }).purchase_codes;
|
||
if (Array.isArray(arr)) {
|
||
for (const item of arr) {
|
||
const code = String(item || '').trim();
|
||
if (code) codes.add(code);
|
||
}
|
||
}
|
||
}
|
||
return String(input.source_type || '').trim() === 'purchase' || codes.size > 0;
|
||
}
|
||
|
||
it('自采 source_type=purchase 跳过(李子 66>50×1.2)', () => {
|
||
expect(
|
||
shouldSkipPassThroughOverQtyGate({
|
||
source_type: 'purchase',
|
||
processing_details: { purchase_code: 'PO1' },
|
||
})
|
||
).toBe(true);
|
||
});
|
||
|
||
it('仅挂 purchase_code 的验收也跳过', () => {
|
||
expect(
|
||
shouldSkipPassThroughOverQtyGate({
|
||
source_type: 'supplier',
|
||
processing_details: { purchase_codes: ['PO2'] },
|
||
})
|
||
).toBe(true);
|
||
});
|
||
|
||
it('供应商备货验收不跳过', () => {
|
||
expect(
|
||
shouldSkipPassThroughOverQtyGate({
|
||
source_type: 'supplier',
|
||
processing_details: { preparation_id: 'prep-1' },
|
||
})
|
||
).toBe(false);
|
||
});
|
||
});
|