- agent: 6 auto-collecting registries (parsers/checks/risk/scoring/tools/pipelines); 15 doc parsers, 12 check packs, 6 risk models, scoring dimensions + reconciler, ~15 Claude tools, 8 pipelines (financing/underwriting/dpp/compliance/grading/esg) + routes; 380 tests - infra: BaseRepository + ~35 typed repositories, 56 composed schema modules, storage/queue/notifications/cache/events adapters; 203 tests - pnpm -r typecheck/build/test all green Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
75 lines
2.4 KiB
TypeScript
75 lines
2.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { TRADE_CHECKS } from '../src/checks/trade.js';
|
|
import { checkRegistry } from '../src/checks/index.js';
|
|
import { sampleProvenance, invoiceDoc } from './helpers.js';
|
|
import { makeDoc, runPack, codesOf, cleanInput } from './checks-support.js';
|
|
|
|
describe('trade cross-check pack', () => {
|
|
it('registers its checks under the trade domain', () => {
|
|
for (const c of TRADE_CHECKS) expect(checkRegistry.has(c.code)).toBe(true);
|
|
});
|
|
|
|
it('is silent on a clean single-invoice input', () => {
|
|
expect(runPack(TRADE_CHECKS, cleanInput())).toHaveLength(0);
|
|
});
|
|
|
|
it('flags conflicting currencies across documents', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [
|
|
invoiceDoc({ fields: { total: 100, currency: 'USD' } }),
|
|
makeDoc('packing_list', { currency: 'EUR' }),
|
|
],
|
|
};
|
|
expect(codesOf(runPack(TRADE_CHECKS, input))).toContain(
|
|
'TRADE_CURRENCY_MISMATCH',
|
|
);
|
|
});
|
|
|
|
it('flags an invalid ISO-4217 currency code', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [invoiceDoc({ fields: { total: 100, currency: 'US$' } })],
|
|
};
|
|
expect(codesOf(runPack(TRADE_CHECKS, input))).toContain(
|
|
'TRADE_CURRENCY_INVALID',
|
|
);
|
|
});
|
|
|
|
it('flags a non-positive invoice total', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [invoiceDoc({ fields: { total: 0, currency: 'USD' } })],
|
|
};
|
|
expect(codesOf(runPack(TRADE_CHECKS, input))).toContain(
|
|
'TRADE_NONPOSITIVE_TOTAL',
|
|
);
|
|
});
|
|
|
|
it('reconciles invoice against an accompanying letter of credit', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [
|
|
invoiceDoc({ fields: { total: 1_000, currency: 'USD' } }),
|
|
makeDoc('letter_of_credit', { total: 900, currency: 'USD' }),
|
|
],
|
|
};
|
|
expect(codesOf(runPack(TRADE_CHECKS, input))).toContain(
|
|
'TRADE_INVOICE_LC_MISMATCH',
|
|
);
|
|
});
|
|
|
|
it('accepts a matching invoice/LC pair', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [
|
|
invoiceDoc({ fields: { total: 1_000, currency: 'USD' } }),
|
|
makeDoc('letter_of_credit', { total: 1_000, currency: 'USD' }),
|
|
],
|
|
};
|
|
expect(codesOf(runPack(TRADE_CHECKS, input))).not.toContain(
|
|
'TRADE_INVOICE_LC_MISMATCH',
|
|
);
|
|
});
|
|
});
|