Skip to content

Commit

Permalink
Merge pull request #5 from Ajai-Suvendran/data-mapper-0.9.1
Browse files Browse the repository at this point in the history
Resolve Build Issue
  • Loading branch information
RivinduM authored Jan 6, 2025
2 parents 26fc817 + e1225e5 commit 39f55e1
Show file tree
Hide file tree
Showing 25 changed files with 551 additions and 423 deletions.
86 changes: 63 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ballerina SWIFT MT to ISO 20022 Data Mapper Library
# Ballerina ISO 20022 to SWIFT MT Data Mapper Library

## Overview

Expand Down Expand Up @@ -29,35 +29,75 @@ The DataMapper Library is a comprehensive toolkit designed to convert ISO 20022

## Usage

### Conversion of ISO 20022 to SWIFT MT
### Conversion of ISO 20022 xml to SWIFT MT message

```ballerina
import ballerina/io;
import ballerinax/financial.iso20022ToSwiftMT as mxToMt;
public function main() returns error? {
string isoMessage = string `<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.054.001.04">
<BkToCstmrDbtCdtNtfctn>
<GrpHdr>
<MsgId>C11126A1378</MsgId>
<CreDtTm>2024-12-16T12:00:00Z</CreDtTm>
</GrpHdr>
<Ntfctn>
<Id>5482ABC</Id>
<Acct>
<Id>
<IBAN>CH9380000000009876543</IBAN>
</Id>
</Acct>
<TxsSummry>
<TtlAmt>
<Amt Ccy="USD">233530.00</Amt>
</TtlAmt>
</TxsSummry>
</Ntfctn>
</BkToCstmrDbtCdtNtfctn>
xml isoMessage = xml `<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.057.001.08">
<NtfctnToRcv>
<GrpHdr>
<MsgId>318393</MsgId>
<CreDtTm>2025-01-01T10:12:11.802172400Z</CreDtTm>
</GrpHdr>
<Ntfctn>
<Id>318393</Id>
<Itm>
<Id>BEBEBB0023CRESZZ</Id>
<EndToEndId>BEBEBB0023CRESZZ</EndToEndId>
<Acct>
<Id>
<Othr>
<SchmeNm/>
</Othr>
</Id>
</Acct>
<Amt>
<ActiveOrHistoricCurrencyAndAmount_SimpleType Ccy="USD">
<ActiveOrHistoricCurrencyAndAmount_SimpleType>230000.00</ActiveOrHistoricCurrencyAndAmount_SimpleType>
</ActiveOrHistoricCurrencyAndAmount_SimpleType>
</Amt>
<XpctdValDt>2010-02-22</XpctdValDt>
<Dbtr>
<Pty>
<PstlAdr/>
<Id>
<OrgId/>
<PrvtId>
<Othr>
<SchmeNm/>
</Othr>
</PrvtId>
</Id>
</Pty>
</Dbtr>
<DbtrAgt>
<FinInstnId>
<BICFI>CRESCHZZ</BICFI>
<ClrSysMmbId>
<ClrSysId/>
<MmbId/>
</ClrSysMmbId>
<PstlAdr/>
</FinInstnId>
</DbtrAgt>
<IntrmyAgt>
<FinInstnId>
<BICFI>CITIUS33</BICFI>
<ClrSysMmbId>
<ClrSysId/>
<MmbId/>
</ClrSysMmbId>
<PstlAdr/>
</FinInstnId>
</IntrmyAgt>
</Itm>
</Ntfctn>
</NtfctnToRcv>
</Document>`;
io:println(mxToMt:toSwiftMtMessage(finMessage));
io:println(mxToMt:toSwiftMtMessage(isoMessage, "210"));
}
```

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ distribution-version = "2201.10.1"
[[package]]
org = "ballerina"
name = "data.xmldata"
version = "1.0.0"
version = "1.1.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand Down
102 changes: 102 additions & 0 deletions iso20022_to_swiftmt/Module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Ballerina ISO 20022 to SWIFT MT Data Mapper Library

## Overview

The DataMapper Library is a comprehensive toolkit designed to convert ISO 20022 XML messages into SWIFT MT format within Ballerina applications. It simplifies the process of mapping ISO 20022 elements to their corresponding SWIFT MT fields, leveraging predefined records and parsers from the ISO 20022 and SWIFT MT libraries. This enables developers to seamlessly convert financial messages from the structured ISO 20022 XML standard into SWIFT MT record value format, ensuring accurate and efficient data conversion.

## Supported Conversions

- pain.001.001.12 to SWIFT MT101
- pacs.008.001.12 to SWIFT MT102
- pacs.008.001.12 to SWIFT MT102STP
- pacs.008.001.12 to SWIFT MT103
- pacs.008.001.12 to SWIFT MT103STP
- pacs.008.001.12 to SWIFT MT103REMIT
- pacs.003.001.11 to SWIFT MT104
- pacs.003.001.11 to SWIFT MT107
- pacs.009.001.11 to SWIFT MT200
- pacs.009.001.11 to SWIFT MT201
- pacs.009.001.11 to SWIFT MT202
- pacs.009.001.11 to SWIFT MT202COV
- pacs.009.001.11 to SWIFT MT203
- pacs.010.001.06 to SWIFT MT204
- pacs.009.001.11 to SWIFT MT205
- pacs.009.001.11 to SWIFT MT205COV
- camt.057.001.08 to SWIFT MT210
- camt.056.001.11 to SWIFT MTn92
- camt.026.001.10 to SWIFT MTn95
- camt.029.001.13 to SWIFT MTn96

## Usage

### Conversion of ISO 20022 xml to SWIFT MT message

```ballerina
import ballerina/io;
import ballerinax/financial.iso20022ToSwiftMT as mxToMt;
public function main() returns error? {
xml isoMessage = xml `<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.057.001.08">
<NtfctnToRcv>
<GrpHdr>
<MsgId>318393</MsgId>
<CreDtTm>2025-01-01T10:12:11.802172400Z</CreDtTm>
</GrpHdr>
<Ntfctn>
<Id>318393</Id>
<Itm>
<Id>BEBEBB0023CRESZZ</Id>
<EndToEndId>BEBEBB0023CRESZZ</EndToEndId>
<Acct>
<Id>
<Othr>
<SchmeNm/>
</Othr>
</Id>
</Acct>
<Amt>
<ActiveOrHistoricCurrencyAndAmount_SimpleType Ccy="USD">
<ActiveOrHistoricCurrencyAndAmount_SimpleType>230000.00</ActiveOrHistoricCurrencyAndAmount_SimpleType>
</ActiveOrHistoricCurrencyAndAmount_SimpleType>
</Amt>
<XpctdValDt>2010-02-22</XpctdValDt>
<Dbtr>
<Pty>
<PstlAdr/>
<Id>
<OrgId/>
<PrvtId>
<Othr>
<SchmeNm/>
</Othr>
</PrvtId>
</Id>
</Pty>
</Dbtr>
<DbtrAgt>
<FinInstnId>
<BICFI>CRESCHZZ</BICFI>
<ClrSysMmbId>
<ClrSysId/>
<MmbId/>
</ClrSysMmbId>
<PstlAdr/>
</FinInstnId>
</DbtrAgt>
<IntrmyAgt>
<FinInstnId>
<BICFI>CITIUS33</BICFI>
<ClrSysMmbId>
<ClrSysId/>
<MmbId/>
</ClrSysMmbId>
<PstlAdr/>
</FinInstnId>
</IntrmyAgt>
</Itm>
</Ntfctn>
</NtfctnToRcv>
</Document>`;
io:println(mxToMt:toSwiftMtMessage(isoMessage, "210"));
}
```
102 changes: 102 additions & 0 deletions iso20022_to_swiftmt/Package.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Ballerina ISO 20022 to SWIFT MT Data Mapper Library

## Overview

The DataMapper Library is a comprehensive toolkit designed to convert ISO 20022 XML messages into SWIFT MT format within Ballerina applications. It simplifies the process of mapping ISO 20022 elements to their corresponding SWIFT MT fields, leveraging predefined records and parsers from the ISO 20022 and SWIFT MT libraries. This enables developers to seamlessly convert financial messages from the structured ISO 20022 XML standard into SWIFT MT record value format, ensuring accurate and efficient data conversion.

## Supported Conversions

- pain.001.001.12 to SWIFT MT101
- pacs.008.001.12 to SWIFT MT102
- pacs.008.001.12 to SWIFT MT102STP
- pacs.008.001.12 to SWIFT MT103
- pacs.008.001.12 to SWIFT MT103STP
- pacs.008.001.12 to SWIFT MT103REMIT
- pacs.003.001.11 to SWIFT MT104
- pacs.003.001.11 to SWIFT MT107
- pacs.009.001.11 to SWIFT MT200
- pacs.009.001.11 to SWIFT MT201
- pacs.009.001.11 to SWIFT MT202
- pacs.009.001.11 to SWIFT MT202COV
- pacs.009.001.11 to SWIFT MT203
- pacs.010.001.06 to SWIFT MT204
- pacs.009.001.11 to SWIFT MT205
- pacs.009.001.11 to SWIFT MT205COV
- camt.057.001.08 to SWIFT MT210
- camt.056.001.11 to SWIFT MTn92
- camt.026.001.10 to SWIFT MTn95
- camt.029.001.13 to SWIFT MTn96

## Usage

### Conversion of ISO 20022 xml to SWIFT MT message

```ballerina
import ballerina/io;
import ballerinax/financial.iso20022ToSwiftMT as mxToMt;
public function main() returns error? {
xml isoMessage = xml `<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.057.001.08">
<NtfctnToRcv>
<GrpHdr>
<MsgId>318393</MsgId>
<CreDtTm>2025-01-01T10:12:11.802172400Z</CreDtTm>
</GrpHdr>
<Ntfctn>
<Id>318393</Id>
<Itm>
<Id>BEBEBB0023CRESZZ</Id>
<EndToEndId>BEBEBB0023CRESZZ</EndToEndId>
<Acct>
<Id>
<Othr>
<SchmeNm/>
</Othr>
</Id>
</Acct>
<Amt>
<ActiveOrHistoricCurrencyAndAmount_SimpleType Ccy="USD">
<ActiveOrHistoricCurrencyAndAmount_SimpleType>230000.00</ActiveOrHistoricCurrencyAndAmount_SimpleType>
</ActiveOrHistoricCurrencyAndAmount_SimpleType>
</Amt>
<XpctdValDt>2010-02-22</XpctdValDt>
<Dbtr>
<Pty>
<PstlAdr/>
<Id>
<OrgId/>
<PrvtId>
<Othr>
<SchmeNm/>
</Othr>
</PrvtId>
</Id>
</Pty>
</Dbtr>
<DbtrAgt>
<FinInstnId>
<BICFI>CRESCHZZ</BICFI>
<ClrSysMmbId>
<ClrSysId/>
<MmbId/>
</ClrSysMmbId>
<PstlAdr/>
</FinInstnId>
</DbtrAgt>
<IntrmyAgt>
<FinInstnId>
<BICFI>CITIUS33</BICFI>
<ClrSysMmbId>
<ClrSysId/>
<MmbId/>
</ClrSysMmbId>
<PstlAdr/>
</FinInstnId>
</IntrmyAgt>
</Itm>
</Ntfctn>
</NtfctnToRcv>
</Document>`;
io:println(mxToMt:toSwiftMtMessage(isoMessage, "210"));
}
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions iso20022_to_switmt/main.bal → iso20022_to_swiftmt/main.bal
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@

import ballerina/data.xmldata;

# Converts an ISO 20022 XML message to its corresponding SWIFT MT message format.
#
# The function uses a map of transformation functions for different ISO 20022 message types
# and applies the appropriate transformation based on the provided XML content and target SWIFT MT message type.
#
# + xmlContent - The ISO 20022 XML content that needs to be converted.
# + messageType - The target SWIFT MT message type (e.g., "103", "102STP","202", "202COV").
# + return - Returns the transformed SWIFT MT message as a record value or an error if the conversion fails.
public isolated function toSwiftMtMessage(xml xmlContent, string messageType) returns record {}|error {
xml:Element document = check xmlContent.get(0).ensureType();
string? isoMessageType = (document).getAttributes()["{" + xml:XMLNS_NAMESPACE_URI + "}xmlns"];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 39f55e1

Please sign in to comment.