- Add missing pacs008.ts, pacs009.ts, pain001.ts files - Add missing config.ts, threshold.ts, documentation.ts files - Fix property access errors (orderingCustomerTaxId -> orderingCustomer.taxId) - Add contractActive property to FXContractCheckResult type - Fix undefined handling in validateBrazilianTaxId calls - Update web app tsconfig to exclude dist folders - Remove tsc from web build (Vite handles TypeScript)
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import type {
|
|
Transaction,
|
|
ThresholdCheckResult,
|
|
RuleResult,
|
|
RuleSeverity,
|
|
RuleDecision,
|
|
} from '@brazil-swift-ops/types';
|
|
import { getDefaultConverter } from '@brazil-swift-ops/utils';
|
|
import { getConfig } from './config';
|
|
|
|
export function evaluateThreshold(
|
|
transaction: Transaction
|
|
): ThresholdCheckResult {
|
|
const config = getConfig();
|
|
const converter = getDefaultConverter();
|
|
|
|
const usdEquivalent = converter.getUSDEquivalent(
|
|
transaction.amount,
|
|
transaction.currency
|
|
);
|
|
|
|
const threshold = config.threshold.usdReportingThreshold;
|
|
const requiresReporting = usdEquivalent >= threshold;
|
|
|
|
return {
|
|
passed: true,
|
|
transactionAmount: transaction.amount,
|
|
currency: transaction.currency,
|
|
usdEquivalent,
|
|
threshold,
|
|
requiresReporting,
|
|
rationale: requiresReporting
|
|
? `Transaction amount (${transaction.amount} ${transaction.currency} = ${usdEquivalent.toFixed(2)} USD) exceeds reporting threshold of ${threshold} USD. Reporting to Banco Central required.`
|
|
: `Transaction amount (${transaction.amount} ${transaction.currency} = ${usdEquivalent.toFixed(2)} USD) is below reporting threshold of ${threshold} USD.`,
|
|
};
|
|
}
|
|
|
|
export function createThresholdRuleResult(
|
|
check: ThresholdCheckResult
|
|
): RuleResult {
|
|
const severity: RuleSeverity = check.requiresReporting ? 'Warning' : 'Info';
|
|
const decision: RuleDecision = check.requiresReporting ? 'Hold' : 'Allow';
|
|
|
|
return {
|
|
ruleId: 'threshold-check',
|
|
ruleName: 'USD Equivalent Threshold Check',
|
|
passed: true,
|
|
severity,
|
|
decision,
|
|
rationale: check.rationale,
|
|
details: {
|
|
transactionAmount: check.transactionAmount,
|
|
currency: check.currency,
|
|
usdEquivalent: check.usdEquivalent,
|
|
threshold: check.threshold,
|
|
requiresReporting: check.requiresReporting,
|
|
},
|
|
};
|
|
}
|