Fix TypeScript build errors
- Remove duplicate EscalationLevel export from regulatory.ts - Add missing logger.ts and reports.ts files to audit package - Fix treasury package type issues - Clean dist folders and rebuild
This commit is contained in:
73
packages/iso20022/src/mt-mapper.js
Normal file
73
packages/iso20022/src/mt-mapper.js
Normal file
@@ -0,0 +1,73 @@
|
||||
import { createPacs008Message } from './pacs008';
|
||||
import { createPacs009Message } from './pacs009';
|
||||
import { createPain001Message } from './pain001';
|
||||
export function mapMT103ToTransaction(mt103) {
|
||||
const [valueDate, currency, amountStr] = mt103.field32A.split(/(\d{6})([A-Z]{3})([\d,]+)/).filter(Boolean);
|
||||
const amount = parseFloat(amountStr.replace(',', '.'));
|
||||
return {
|
||||
id: mt103.field20,
|
||||
direction: 'outbound',
|
||||
amount,
|
||||
currency: currency || 'USD',
|
||||
orderingCustomer: {
|
||||
name: mt103.field50A || '',
|
||||
country: 'BR',
|
||||
},
|
||||
beneficiary: {
|
||||
name: mt103.field59,
|
||||
country: 'BR',
|
||||
},
|
||||
purposeOfPayment: mt103.field70,
|
||||
swiftReference: mt103.field20,
|
||||
status: 'pending',
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
}
|
||||
export function mapTransactionToMT103(transaction) {
|
||||
const valueDate = new Date().toISOString().slice(0, 10).replace(/-/g, '');
|
||||
const amountStr = transaction.amount.toFixed(2).replace('.', ',');
|
||||
return {
|
||||
field20: transaction.swiftReference || transaction.id,
|
||||
field23B: 'CRED',
|
||||
field32A: `${valueDate}${transaction.currency}${amountStr}`,
|
||||
field50A: transaction.orderingCustomer.name,
|
||||
field59: transaction.beneficiary.name,
|
||||
field70: transaction.purposeOfPayment || '',
|
||||
field71A: 'OUR',
|
||||
field72: `//${transaction.fxContractId || ''}`,
|
||||
};
|
||||
}
|
||||
export function convertMT103ToISO20022(mt103, targetType = 'pacs.008', version) {
|
||||
const transaction = mapMT103ToTransaction(mt103);
|
||||
switch (targetType) {
|
||||
case 'pacs.008':
|
||||
return createPacs008Message(transaction, version);
|
||||
case 'pacs.009':
|
||||
return createPacs009Message(transaction, version);
|
||||
case 'pain.001':
|
||||
return createPain001Message(transaction, version);
|
||||
}
|
||||
}
|
||||
export function convertISO20022ToMT103(message) {
|
||||
// This is a simplified conversion - in production would need full mapping
|
||||
const transaction = {
|
||||
id: message.groupHeader.messageIdentification,
|
||||
direction: 'outbound',
|
||||
amount: message.groupHeader.controlSum || 0,
|
||||
currency: 'USD',
|
||||
orderingCustomer: {
|
||||
name: message.groupHeader.initiatingParty.name || '',
|
||||
country: 'BR',
|
||||
},
|
||||
beneficiary: {
|
||||
name: '',
|
||||
country: 'BR',
|
||||
},
|
||||
status: 'pending',
|
||||
createdAt: message.creationDateTime,
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
return mapTransactionToMT103(transaction);
|
||||
}
|
||||
//# sourceMappingURL=mt-mapper.js.map
|
||||
Reference in New Issue
Block a user