Skip to content

Commit

Permalink
Update MT110 message records and parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajai-Suvendran committed Jan 28, 2025
1 parent 11f56dc commit ea3afae
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 12 deletions.
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
33 changes: 33 additions & 0 deletions swiftmt/parser.bal
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ isolated function convertToProprietaryXml(xml swiftMessageXml) returns xml{
// customer credit transfer details and copy of original message in the SWIFT message during data mapping. To replicate the original SWIFT
// message format, these fields are now being removed.
if tagElement.getName().equalsIgnoreCaseAscii("Transaction") ||
tagElement.getName().equalsIgnoreCaseAscii("Cheques") ||
tagElement.getName().equalsIgnoreCaseAscii("UndrlygCstmrCdtTrf") ||
tagElement.getName().equalsIgnoreCaseAscii("MessageCopy") {
block4Xml += tagElement.elementChildren();
Expand Down Expand Up @@ -202,6 +203,9 @@ isolated function customizeGeneratedXml(xml customXml) returns xml|error {
}
}

if messageType.equalsIgnoreCaseAscii("110") {
return addChequeSequenceForMT110(customXml);
}
if isTransactionSequencerequired && messageType.startsWith("1") && isNotCommonMessageType {
return addTransactionSequenceForMT1XX(customXml);
}
Expand Down Expand Up @@ -279,6 +283,35 @@ isolated function separateTransactionSequenceForMT1XX(xml customXml) returns (xm
return [xmlArray,isSequenceCPresent];
}

isolated function addChequeSequenceForMT110(xml customXml) returns xml {
xml[] xmlArray = [];
xml chequeXml = xml ``;

foreach xml tagElement in customXml/**/<block4>/* {
string name = tagElement.elementChildren("name").data();
if name.equalsIgnoreCaseAscii("21") {
xmlArray.push(chequeXml);
chequeXml = xml ``;
}
chequeXml += tagElement;
}
xmlArray.push(chequeXml);
xml newBlock4Xml = xmlArray[0];

foreach int index in 1 ... xmlArray.length() - 1 {
xml:Element rootXml = xml `<Cheques/>`;
rootXml.setChildren(xmlArray[index]);
newBlock4Xml += rootXml;
}

foreach xml block in customXml.elementChildren() {
if block.getName().equalsIgnoreCaseAscii("block4") {
block.setChildren(newBlock4Xml);
}
}
return customXml;
}

# Adds a transaction sequence for MT2XX message types by identifying specific tags like "20","50A","50F","50K",
# and grouping the message content accordingly into XML transactions.
#
Expand Down

0 comments on commit ea3afae

Please sign in to comment.