Skip to content

Commit

Permalink
Merge pull request #12 from Ajai-Suvendran/main
Browse files Browse the repository at this point in the history
Enhance SWIFT MT Library with Updated and Additional Records
  • Loading branch information
RivinduM authored Feb 5, 2025
2 parents e92a883 + 2cbe7bc commit 22d9776
Show file tree
Hide file tree
Showing 20 changed files with 303 additions and 47 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ The `ballerinax/financial.swift.mt` library provides support for creating, parsi

- SWIFT MT 1XX Category
- SWIFT MT 2XX Category
- SWIFT MT 3XX Category Volume 1 (MT300 - MT341)
- SWIFT MT 9XX Category
- SWIFT MT nXX Category (n92, n95, n96)
- SWIFT MT nXX Category

## Usage

Expand Down Expand Up @@ -66,6 +67,26 @@ public function main() returns error? {
}
```

### Generating SWIFT MT Fin Message using SWIFT MT Record Values

```ballerina
import ballerina/io;
import ballerinax/fiancial.swift.mt as swiftmt;
public function main() returns error? {
//name and number of each field have to be defined in order to generate the fin message.
swiftmt:MT900Message message = {
block1: {logicalTerminal: "FTRVVY5R"},
block2: {'type: "input", messageType: "900", receiverAddress: "ADRFTY2CXXX"},
block4: {
MT20: {name: "20", msgId: {content: "245465498", number: "1"}},
MT21: {name:"21", Ref: {content: "5463557676", number: "1"}},
MT32A: {name: "32A", Dt: {content: "270125", number: "1"},
Ccy: {content: "USD", number: "2"}, Amnt: {content: "6897,", number: "3"}}}};
io:println(swiftmt:getFinMessage(message));
}
```

## Report issues

To report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina library parent repository](https://github.com/ballerina-platform/ballerina-library).
Expand Down
2 changes: 1 addition & 1 deletion swiftmt/102_multiple_customer_credit_transfer.bal
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public type MT102Transaction record {|
MT77B MT77B?;
MT33B MT33B?;
MT71A MT71A?;
MT71F MT71F?;
MT71F[] MT71F?;
MT71G MT71G?;
MT36 MT36?;
|};
Expand Down
2 changes: 1 addition & 1 deletion swiftmt/102_stp_multiple_customer_credit_transfer.bal
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public type MT102STPTransaction record {|
MT77B MT77B?;
MT33B MT33B?;
MT71A MT71A?;
MT71F MT71F?;
MT71F[] MT71F?;
MT71G MT71G?;
MT36 MT36?;
|};
Expand Down
2 changes: 1 addition & 1 deletion swiftmt/103_remit_single_customer_credit_transfer.bal
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public type MT103REMITBlock4 record {|
MT59A MT59A?;
MT59F MT59F?;
MT71A MT71A;
MT71F MT71F?;
MT71F[] MT71F?;
MT71G MT71G?;
MT72 MT72?;
MT77B MT77B?;
Expand Down
2 changes: 1 addition & 1 deletion swiftmt/103_single_customer_credit_transfer.bal
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public type MT103Block4 record {|
MT59F MT59F?;
MT70 MT70?;
MT71A MT71A;
MT71F MT71F?;
MT71F[] MT71F?;
MT71G MT71G?;
MT72 MT72?;
MT77B MT77B?;
Expand Down
2 changes: 1 addition & 1 deletion swiftmt/103_stp_single customer_credit_transfer.bal
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public type MT103STPBlock4 record {|
MT59F MT59F?;
MT70 MT70?;
MT71A MT71A;
MT71F MT71F?;
MT71F[] MT71F?;
MT71G MT71G?;
MT72 MT72?;
MT77B MT77B?;
Expand Down
2 changes: 1 addition & 1 deletion swiftmt/104_direct_debit_transfer.bal
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public type MT104Transaction record {|
MT77B MT77B?;
MT33B MT33B?;
MT71A MT71A?;
MT71F MT71F?;
MT71F[] MT71F?;
MT71G MT71G?;
MT36 MT36?;
|};
Expand Down
2 changes: 1 addition & 1 deletion swiftmt/107_general_direct_debit.bal
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public type MT107Transaction record {|
MT77B MT77B?;
MT33B MT33B?;
MT71A MT71A?;
MT71F MT71F?;
MT71F[] MT71F?;
MT71G MT71G?;
MT36 MT36?;
|};
Expand Down
31 changes: 19 additions & 12 deletions swiftmt/110_advice_of_cheque(s).bal
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,14 @@
# Defines the elements of the MT110 message block 4.
#
# + MT20 - Sender's Reference
# + MT21 - Check Number Reference
# + MT30 - Date of Issue
# + MT32A - Amount (Option A)
# + MT32B - Amount (Option B)
# + MT50A - Payer (Option A)
# + MT50F - Payer (Option F)
# + MT50K - Payer (Option K)
# + MT52A - Drawer Bank (Option A)
# + MT52B - Drawer Bank (Option B)
# + MT52D - Drawer Bank (Option D)
# + MT53A - Sender's Correpondant (Option A)
# + MT53B - Sender's Correpondant (Option B)
# + MT53D - Sender's Correpondant (Option D)
# + MT54A - Receiver's Correpondant (Option A)
# + MT54B - Receiver's Correpondant (Option B)
# + MT54D - Receiver's Correpondant (Option D)
# + MT59 - Payee
# + MT59F - Payee (Option F)
# + MT72 - Sender to Receiver Information
# + Cheques - The Sequence for Advices of Cheque
public type MT110Block4 record {|
MT20 MT20;
MT53A MT53A?;
Expand All @@ -45,6 +34,24 @@ public type MT110Block4 record {|
MT54B MT54B?;
MT54D MT54D?;
MT72 MT72?;
Cheques[] Cheques;
|};

# Defines the elements of the sequence of advices of cheque.
#
# + MT21 - Check Number Reference
# + MT30 - Date of Issue
# + MT32A - Amount (Option A)
# + MT32B - Amount (Option B)
# + MT50A - Payer (Option A)
# + MT50F - Payer (Option F)
# + MT50K - Payer (Option K)
# + MT52A - Drawer Bank (Option A)
# + MT52B - Drawer Bank (Option B)
# + MT52D - Drawer Bank (Option D)
# + MT59 - Payee
# + MT59F - Payee (Option F)
public type Cheques record {|
MT21 MT21;
MT30 MT30;
MT32A MT32A?;
Expand Down
3 changes: 1 addition & 2 deletions swiftmt/Dependencies.toml
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 Expand Up @@ -61,4 +61,3 @@ modules = [
{org = "ballerinax", packageName = "financial.swift.mt", moduleName = "financial.swift.mt.com.prowidesoftware.swift.model"},
{org = "ballerinax", packageName = "financial.swift.mt", moduleName = "financial.swift.mt.java.lang"}
]

26 changes: 19 additions & 7 deletions swiftmt/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ The `ballerinax/financial.swift.mt` library provides support for creating, parsi

- SWIFT MT 1XX Category
- SWIFT MT 2XX Category
- SWIFT MT 3XX Category Volume 1 (MT300 - MT341)
- SWIFT MT 9XX Category
- SWIFT MT nXX Category (n92, n95, n96)
- SWIFT MT nXX Category

## Usage

Expand Down Expand Up @@ -66,11 +67,22 @@ public function main() returns error? {
}
```

## Report issues
### Generating SWIFT MT Fin Message using SWIFT MT Record Values

To report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina library parent repository](https://github.com/ballerina-platform/ballerina-library).

## Useful Links
```ballerina
import ballerina/io;
import ballerinax/fiancial.swift.mt as swiftmt;
- Chat live with us via our [Discord server](https://discord.gg/ballerinalang).
- Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag.
public function main() returns error? {
//name and number of each field have to be defined in order to generate the fin message.
swiftmt:MT900Message message = {
block1: {logicalTerminal: "FTRVVY5R"},
block2: {'type: "input", messageType: "900", receiverAddress: "ADRFTY2CXXX"},
block4: {
MT20: {name: "20", msgId: {content: "245465498", number: "1"}},
MT21: {name:"21", Ref: {content: "5463557676", number: "1"}},
MT32A: {name: "32A", Dt: {content: "270125", number: "1"},
Ccy: {content: "USD", number: "2"}, Amnt: {content: "6897,", number: "3"}}}};
io:println(swiftmt:getFinMessage(message));
}
```
26 changes: 19 additions & 7 deletions swiftmt/Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ The `ballerinax/financial.swift.mt` library provides support for creating, parsi

- SWIFT MT 1XX Category
- SWIFT MT 2XX Category
- SWIFT MT 3XX Category Volume 1 (MT300 - MT341)
- SWIFT MT 9XX Category
- SWIFT MT nXX Category (n92, n95, n96)
- SWIFT MT nXX Category

## Usage

Expand Down Expand Up @@ -66,11 +67,22 @@ public function main() returns error? {
}
```

## Report issues
### Generating SWIFT MT Fin Message using SWIFT MT Record Values

To report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina library parent repository](https://github.com/ballerina-platform/ballerina-library).

## Useful Links
```ballerina
import ballerina/io;
import ballerinax/fiancial.swift.mt as swiftmt;
- Chat live with us via our [Discord server](https://discord.gg/ballerinalang).
- Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag.
public function main() returns error? {
//name and number of each field have to be defined in order to generate the fin message.
swiftmt:MT900Message message = {
block1: {logicalTerminal: "FTRVVY5R"},
block2: {'type: "input", messageType: "900", receiverAddress: "ADRFTY2CXXX"},
block4: {
MT20: {name: "20", msgId: {content: "245465498", number: "1"}},
MT21: {name:"21", Ref: {content: "5463557676", number: "1"}},
MT32A: {name: "32A", Dt: {content: "270125", number: "1"},
Ccy: {content: "USD", number: "2"}, Amnt: {content: "6897,", number: "3"}}}};
io:println(swiftmt:getFinMessage(message));
}
```
11 changes: 10 additions & 1 deletion swiftmt/common_records.bal
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public type ValidationFlag record {|
# + NdToNdTxRef - The end to end reference
# + ValidationFlag - The validation flag to identify STP, REMIT and COV
public type Block3 record {|
NdToNdTxRef NdToNdTxRef?;
ValidationFlag ValidationFlag?;
NdToNdTxRef NdToNdTxRef?;
|};

# Defines the block 1 of the message.
Expand Down Expand Up @@ -660,6 +660,15 @@ public type MT70 record {|
Nrtv Nrtv;
|};

# Defines the MT71B field in block 4.
#
# + name - The name of the field
# + Nrtv - The narrative
public type MT71B record {|
string name?;
Nrtv Nrtv;
|};

# Defines the MT77A field in block 4.
#
# + name - The name of the field
Expand Down
18 changes: 13 additions & 5 deletions swiftmt/field_names.bal
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const string[][] SWIFTMT_1XX_FIELD_SPEC = [
["30", "Dt"],
["32A", "Dt", "Ccy", "Amnt"],
["32B", "Ccy", "Amnt"],
["32C", "Dt", "Ccy", "Amnt"],
["32D", "Dt", "Ccy", "Amnt"],
["33B", "Ccy", "Amnt"],
["36", "Rt"],
["50A", "Acc", "IdnCd"],
Expand Down Expand Up @@ -98,6 +100,8 @@ const string[][] SWIFTMT_2XX_FIELD_NAME = [
["30", "Dt"],
["32A", "Dt", "Ccy", "Amnt"],
["32B", "Ccy", "Amnt"],
["32C", "Dt", "Ccy", "Amnt"],
["32D", "Dt", "Ccy", "Amnt"],
["33B", "Ccy", "Amnt"],
["50A", "Acc", "IdnCd"],
["50F", "PrtyIdn", "CdTyp", "IdentifyTag", "CdTyp", "IdentifyTag", "CdTyp", "IdentifyTag", "CdTyp", "IdentifyTag"],
Expand Down Expand Up @@ -148,6 +152,8 @@ const string[][] SWIFTMT_9XX_FIELD_SPEC = [
["28C", "StmtNo", "SeqNo"],
["30", "Dt"],
["32A", "Dt", "Ccy", "Amnt"],
["32C", "Dt", "Ccy", "Amnt"],
["32D", "Dt", "Ccy", "Amnt"],
["33B", "Ccy", "Amnt"],
["34B", "Ccy", "Amnt"],
["34F", "Ccy", "Cd", "Amnt"],
Expand Down Expand Up @@ -196,8 +202,10 @@ const string[][] IDENTIFY_TAG = [["1", "Nm"], ["2", "AdrsLine"],
["7", "NtnlIdnNum"], ["8", "AddInfo"]];

final readonly & map<typedesc<record {}>> messageMapper = {"101": MT101Message, "102": MT102Message, "102STP": MT102STPMessage,
"103": MT103Message, "103STP": MT103STPMessage, "103REMIT": MT103REMITMessage, "104": MT104Message, "107": MT107Message,
"200": MT200Message, "201": MT201Message, "202": MT202Message, "202COV": MT202COVMessage, "203": MT203Message,
"204": MT204Message, "205": MT205Message, "205COV": MT205COVMessage, "210": MT210Message, "900": MT900Message,
"910": MT910Message, "920": MT920Message, "940": MT940Message, "941": MT941Message, "942": MT942Message, "950": MT950Message,
"970": MT970Message, "971": MT971Message, "972": MT972Message, "973": MT973Message, "92": MTn92Message, "95": MTn95Message, "96": MTn96Message};
"103": MT103Message, "103STP": MT103STPMessage, "103REMIT": MT103REMITMessage, "104": MT104Message, "107": MT107Message,
"110":MT110Message, "111":MT111Message, "112":MT112Message, "200": MT200Message, "201": MT201Message,
"202": MT202Message, "202COV": MT202COVMessage, "203": MT203Message, "204": MT204Message, "205": MT205Message,
"205COV": MT205COVMessage, "210": MT210Message, "900": MT900Message, "910": MT910Message, "920": MT920Message,
"940": MT940Message, "941": MT941Message, "942": MT942Message, "950": MT950Message, "970": MT970Message,
"971": MT971Message, "972": MT972Message, "973": MT973Message, "90": MTn90Message, "91": MTn91Message,
"92": MTn92Message, "95": MTn95Message,"96": MTn96Message, "99": MTn99Message};
55 changes: 55 additions & 0 deletions swiftmt/n90_advice_of_charges_interest_other_adjustments.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

# Defines the elements of the MTn90 message block 4.
#
# + MT20 - Transaction Reference
# + MT21 - Related Reference
# + MT25 - Account Identification
# + MT32C - Value Date, Currency Code, and Amount
# + MT32D - Value Date, Currency Code, and Amount
# + MT52A - Ordering Institution (Option A)
# + MT52D - Ordering Institution (Option D)
# + MT71B - Details of Charges Information
# + MT72 - Sender to Receiver Information
public type MTn90Block4 record {|
MT20 MT20;
MT21 MT21;
MT25A MT25;
MT32A MT32C?;
MT32A MT32D?;
MT52A MT52A?;
MT52D MT52D?;
MT71B MT71B;
MT72 MT72?;
|};

# Defines the structure of the MTn90 message.
#
# + block1 - Basic Header Block
# + block2 - Application Header Block
# + block3 - User Header Block
# + block4 - Text Block containing transaction details
# + block5 - Trailer Block
# + unparsedTexts - Any additional unparsed texts
public type MTn90Message record {|
Block1 block1?;
Block2 block2;
Block3 block3?;
MTn90Block4 block4;
Block5 block5?;
UnparsedTexts unparsedTexts?;
|};
Loading

0 comments on commit 22d9776

Please sign in to comment.