libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit af8fb100172f3f26d0e1a9a58c1ee3b614bd2d82
parent fccc2eff22a0528658d6d1a42ac27e5dd2b4f34c
Author: Antoine A <>
Date:   Sat, 20 Apr 2024 18:59:16 +0900

Catch reversal using bank status code

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt | 30++++++++++++++++++++++++++++--
Mnexus/src/main/kotlin/tech/libeufin/nexus/Iso20022CodeSets.kt | 3++-
2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt @@ -334,7 +334,20 @@ fun parseTx( } } } - val reversal = opt("RvslInd")?.bool() ?: false + var reversal = opt("RvslInd")?.bool() ?: false + opt("BkTxCd") { + opt("Domn") { + // TODO automate enum generation for all those code + val domainCode = one("Cd") + one("Fmly") { + val familyCode = one("Cd") + val subFamilyCode = one("SubFmlyCd").text() + if (subFamilyCode == "RRTN" || subFamilyCode == "RPCR") { + reversal = true + } + } + } + } val info = opt("AddtlNtryInf")?.text() val bookDate: Instant = one("BookgDt").one("Dt").date().atStartOfDay().toInstant(ZoneOffset.UTC) val ref = opt("AcctSvcrRef")?.text() @@ -375,7 +388,7 @@ fun parseTx( } } } - val reversal = opt("RvslInd")?.bool() ?: false + var reversal = opt("RvslInd")?.bool() ?: false val info = opt("AddtlNtryInf")?.text() val bookDate: Instant = one("BookgDt").one("Dt").date().atStartOfDay().toInstant(ZoneOffset.UTC) val kind = one("CdtDbtInd").text() @@ -387,6 +400,19 @@ fun parseTx( } val ref = opt("AcctSvcrRef")?.text() return one("NtryDtls").one("TxDtls") { + opt("BkTxCd") { + opt("Domn") { + // TODO automate enum generation for all those code + val domainCode = one("Cd") + one("Fmly") { + val familyCode = one("Cd") + val subFamilyCode = one("SubFmlyCd").text() + if (subFamilyCode == "RRTN" || subFamilyCode == "RPCR") { + reversal = true + } + } + } + } var msgId = opt("Refs")?.opt("MsgId")?.text() val subject = opt("RmtInf")?.map("Ustrd") { text() }?.joinToString("") var debtorPayto = opt("RltdPties") { payto("Dbtr") } diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022CodeSets.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022CodeSets.kt @@ -327,4 +327,4 @@ enum class ExternalPaymentTransactionStatusCode(val isoCode: String, val descrip PRES("Presented", "Request for Payment has been presented to the Debtor."), RCVD("Received", "Payment instruction has been received."), RJCT("Rejected", "Payment instruction has been rejected."), -} +} +\ No newline at end of file