Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/SRU2024' into SRU2024_v10
Browse files Browse the repository at this point in the history
  • Loading branch information
zubri committed Aug 14, 2024
2 parents 77dbd01 + fdf3346 commit 139f1cc
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Prowide ISO 20022 - CHANGELOG

#### 10.2.3 - August 2024
* (PW-1958) Fixed the `DefaultMxMetadataStrategy` NPE issue when the amount values are null

#### 10.2.2 - August 2024
* (PW-1947) Updated MX model with latest SWIFT SRU2024 schema update, including new messages such as trck.001.001.03
* (PW-1933) Fix backward compatibility issue on DateTime fields when doing JSON to model conversion (thanks @elominp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,53 @@ public static BusinessAppHdrV04 createBusinessAppHdrV04(
return h;
}

/**
* Convenient method to create a new ISO header version 4, initialized from simple parameters.
*
* <p>All parameters are optional but in order for the header to be valid the sender, receiver and reference must
* be set. Creation date will be set to current time.
*
* @param sender optional sender BIC for the Fr element or null to leave not set
* @param receiver optional receiver BIC for the To element or null to leave not set
* @param reference optional reference for the BizMsgIdr (business message identifier) or null to leave not set
* @param id optional MX identification for the MsgDefIdr (message definition identifier) element or null to leave not set
* @return new header initialized from parameters.
* @since 9.5.3
*/
public static BusinessAppHdrV04 createBusinessAppHdrV04(
final String sender, final String receiver, final String reference, final MxId id) {
BusinessAppHdrV04 h = new BusinessAppHdrV04();

if (sender != null) {
h.setFr(new Party51Choice());
h.getFr().setFIId(new BranchAndFinancialInstitutionIdentification8());
h.getFr().getFIId().setFinInstnId(new FinancialInstitutionIdentification23());
h.getFr().getFIId().getFinInstnId().setBICFI(sender);
}

if (receiver != null) {
h.setTo(new Party51Choice());
h.getTo().setFIId(new BranchAndFinancialInstitutionIdentification8());
h.getTo().getFIId().setFinInstnId(new FinancialInstitutionIdentification23());
h.getTo().getFIId().getFinInstnId().setBICFI(receiver);
}

if (reference != null) {
h.setBizMsgIdr(reference);
}

if (id != null) {
h.setMsgDefIdr(id.id());
if (id.getBusinessService().isPresent()) {
h.setBizSvc(id.getBusinessService().get());
}
}

h.setCreDt(XMLGregorianCalendarUtils.now());

return h;
}

/**
* Convenient method to create a new legacy SWIFT header, initialized from simple parameters.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,23 @@ public Optional<Money> amount(AbstractMessage message) {

private Money getCamt29Amount(MxNode document) {
MxNode amount = document.findFirst("./RsltnOfInvstgtn/CxlDtls/OrgnlPmtInfAndSts/TxInfAndSts/OrgnlInstdAmt");
if (amount != null) {
if (amount != null && amount.getValue() != null) {
return new Money(amount.getAttribute("Ccy"), new BigDecimal(amount.getValue()));
}
return null;
}

private Money getCamt52Amount(MxNode document) {
MxNode amount = document.findFirst("./BkToCstmrAcctRpt/Rpt/Bal/Amt");
if (amount != null) {
if (amount != null && amount.getValue() != null) {
return new Money(amount.getAttribute("Ccy"), new BigDecimal(amount.getValue()));
}
return null;
}

private Money getCamt53Amount(MxNode document) {
MxNode amount = document.findFirst("./BkToCstmrStmt/Stmt/Bal/Amt");
if (amount != null) {
if (amount != null && amount.getValue() != null) {
return new Money(amount.getAttribute("Ccy"), new BigDecimal(amount.getValue()));
}
return null;
Expand All @@ -121,23 +121,23 @@ private Money getCamt54Amount(MxNode document) {
if (amount == null) {
amount = document.findFirst("./BkToCstmrDbtCdtNtfctn/Ntfctn/Ntry/NtryDtls/TxDtls/Amt");
}
if (amount != null) {
if (amount != null && amount.getValue() != null) {
return new Money(amount.getAttribute("Ccy"), new BigDecimal(amount.getValue()));
}
return null;
}

private Money getCamt56Amount(MxNode document) {
MxNode amount = document.findFirst("./FIToFIPmtCxlReq/Undrlyg/TxInf/OrgnlIntrBkSttlmAmt");
if (amount != null) {
if (amount != null && amount.getValue() != null) {
return new Money(amount.getAttribute("Ccy"), new BigDecimal(amount.getValue()));
}
return null;
}

private Money getCamt57Amount(MxNode document) {
MxNode amount = document.findFirst("./NtfctnToRcv/Ntfctn/TtlAmt");
if (amount != null) {
if (amount != null && amount.getValue() != null) {
return new Money(amount.getAttribute("Ccy"), new BigDecimal(amount.getValue()));
}
return null;
Expand All @@ -148,7 +148,7 @@ private Money getPacs004Amount(MxNode document) {
if (amount == null) {
amount = document.findFirst("./PmtRtr/TxInf/RtrdIntrBkSttlmAmt");
}
if (amount != null) {
if (amount != null && amount.getValue() != null) {
return new Money(amount.getAttribute("Ccy"), new BigDecimal(amount.getValue()));
}
return null;
Expand Down Expand Up @@ -181,7 +181,7 @@ private Money getPacsAmount(MxNode document) {
MxNode cdtTrfNode = document.findFirstByName("CdtTrfTxInf");
if (cdtTrfNode != null) {
MxNode amount = cdtTrfNode.findFirst("./IntrBkSttlmAmt");
if (amount != null) {
if (amount != null && amount.getValue() != null) {
return new Money(amount.getAttribute("Ccy"), new BigDecimal(amount.getValue()));
}
}
Expand Down
114 changes: 114 additions & 0 deletions iso20022-core/src/test/java/com/prowidesoftware/issues/Issue1958.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package com.prowidesoftware.issues;

import static org.junit.jupiter.api.Assertions.fail;

import com.prowidesoftware.swift.model.MxSwiftMessage;
import org.junit.jupiter.api.Test;

public class Issue1958 {

@Test
void test() {
try {
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
+ "<RequestPayload>"
+ "<h:AppHdr xmlns:h=\"urn:swift:xsd:$ahV10\">"
+ " <h:From>"
+ " <h:Type>BIC</h:Type>"
+ " <h:Id>AAAANGL0XXX</h:Id>"
+ " </h:From>"
+ " <h:To>"
+ " <h:Type>BIC</h:Type>"
+ " <h:Id>BBBBUS33XXX</h:Id>"
+ " </h:To>"
+ " <h:MsgName>pacs.008.001.08</h:MsgName>"
+ " <h:MsgRef>FOOBAR1</h:MsgRef>"
+ " <h:CrDate>2022-05-05T06:07:14Z</h:CrDate>"
+ "</h:AppHdr>"
+ "<Doc:Document xmlns:Doc=\"urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08\">"
+ " <Doc:FIToFICstmrCdtTrf>"
+ " <Doc:GrpHdr>"
+ " <Doc:MsgId>FOOBAR2</Doc:MsgId>"
+ " <Doc:CreDtTm>2022-05-05T06:07:14Z</Doc:CreDtTm>"
+ " <Doc:NbOfTxs>1</Doc:NbOfTxs>"
+ " <Doc:SttlmInf>"
+ " <Doc:SttlmMtd>INDA</Doc:SttlmMtd>"
+ " <Doc:SttlmAcct>"
+ " <Doc:Id>"
+ " <Doc:Othr>"
+ " <Doc:Id>04435001</Doc:Id>"
+ " </Doc:Othr>"
+ " </Doc:Id>"
+ " </Doc:SttlmAcct>"
+ " </Doc:SttlmInf>"
+ " <Doc:InstgAgt>"
+ " <Doc:FinInstnId>"
+ " <Doc:BICFI>AAAANGL0XXX</Doc:BICFI>"
+ " </Doc:FinInstnId>"
+ " </Doc:InstgAgt>"
+ " <Doc:InstdAgt>"
+ " <Doc:FinInstnId>"
+ " <Doc:BICFI>BBBBUS33XXX</Doc:BICFI>"
+ " </Doc:FinInstnId>"
+ " </Doc:InstdAgt>"
+ " </Doc:GrpHdr>"
+ " <Doc:CdtTrfTxInf>"
+ " <Doc:PmtId>"
+ " <Doc:InstrId>REF333222333</Doc:InstrId>"
+ " <Doc:EndToEndId>RRRR345345</Doc:EndToEndId>"
+ " <Doc:TxId>FFDD34534</Doc:TxId>"
+ " </Doc:PmtId>"
+ " <Doc:IntrBkSttlmAmt Ccy=\"USD\"></Doc:IntrBkSttlmAmt>"
+ " <Doc:IntrBkSttlmDt>2022-05-05</Doc:IntrBkSttlmDt>"
+ " <Doc:InstdAmt Ccy=\"USD\"></Doc:InstdAmt>"
+ " <Doc:ChrgBr>DEBT</Doc:ChrgBr>"
+ " <Doc:Dbtr>"
+ " <Doc:Nm>FOO FEED MILLS COLTD</Doc:Nm>"
+ " <Doc:PstlAdr>"
+ " <Doc:AdrLine>1 GOLDEN PENNY PLACE, WHARF ROAD,</Doc:AdrLine>"
+ " <Doc:AdrLine>APAPA LAGOS</Doc:AdrLine>"
+ " </Doc:PstlAdr>"
+ " </Doc:Dbtr>"
+ " <Doc:DbtrAcct>"
+ " <Doc:Id>"
+ " <Doc:Othr>"
+ " <Doc:Id>2028766092</Doc:Id>"
+ " </Doc:Othr>"
+ " </Doc:Id>"
+ " </Doc:DbtrAcct>"
+ " <Doc:DbtrAgt>"
+ " <Doc:FinInstnId>"
+ " <Doc:BICFI>AAAANGLA</Doc:BICFI>"
+ " </Doc:FinInstnId>"
+ " </Doc:DbtrAgt>"
+ " <Doc:CdtrAgt>"
+ " <Doc:FinInstnId>"
+ " <Doc:BICFI>BBBBRU21</Doc:BICFI>"
+ " </Doc:FinInstnId>"
+ " </Doc:CdtrAgt>"
+ " <Doc:Cdtr>"
+ " <Doc:Nm>TEST</Doc:Nm>"
+ " <Doc:PstlAdr>"
+ " <Doc:AdrLine>TEST</Doc:AdrLine>"
+ " </Doc:PstlAdr>"
+ " </Doc:Cdtr>"
+ " <Doc:CdtrAcct>"
+ " <Doc:Id>"
+ " <Doc:Othr>"
+ " <Doc:Id>TEST</Doc:Id>"
+ " </Doc:Othr>"
+ " </Doc:Id>"
+ " </Doc:CdtrAcct>"
+ " <Doc:RmtInf>"
+ " <Doc:Ustrd>AGRICULTURAL SECTOR</Doc:Ustrd>"
+ " </Doc:RmtInf>"
+ " </Doc:CdtTrfTxInf>"
+ " </Doc:FIToFICstmrCdtTrf>"
+ "</Doc:Document>"
+ "</RequestPayload>";
new MxSwiftMessage(xml);
} catch (Exception e) {
fail();
}
}
}

0 comments on commit 139f1cc

Please sign in to comment.