summaryrefslogtreecommitdiff
path: root/nexus/src/main/kotlin/tech
diff options
context:
space:
mode:
authorAntoine A <>2024-04-20 18:59:16 +0900
committerAntoine A <>2024-04-20 18:59:16 +0900
commitaf8fb100172f3f26d0e1a9a58c1ee3b614bd2d82 (patch)
tree012cb960b8b8c8d2cc5e36df740e728aec4d6e3f /nexus/src/main/kotlin/tech
parentfccc2eff22a0528658d6d1a42ac27e5dd2b4f34c (diff)
downloadlibeufin-af8fb100172f3f26d0e1a9a58c1ee3b614bd2d82.tar.gz
libeufin-af8fb100172f3f26d0e1a9a58c1ee3b614bd2d82.tar.bz2
libeufin-af8fb100172f3f26d0e1a9a58c1ee3b614bd2d82.zip
Catch reversal using bank status code
Diffstat (limited to 'nexus/src/main/kotlin/tech')
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022.kt30
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/Iso20022CodeSets.kt2
2 files changed, 29 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
index edb53d67..429c21bf 100644
--- 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
index bc2c7eae..624a6b0e 100644
--- 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