[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Camt parsing.
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Camt parsing. |
Date: |
Tue, 01 Dec 2020 13:17:13 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new c8e211a Camt parsing.
c8e211a is described below
commit c8e211af05fd8727fc2e6d706b2c4bd92328e2cb
Author: MS <ms@taler.net>
AuthorDate: Tue Dec 1 13:15:19 2020 +0100
Camt parsing.
Handling the case where one batch has multiple individual
transactions. In this case, the individual transaction's amount
should be retrieved from a field named "AmtDtls", instead of the more
general "Amt".
---
.../tech/libeufin/nexus/iso20022/Iso20022.kt | 32 ++++++++++------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt
index 796f49b..b534244 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt
@@ -630,6 +630,18 @@ private fun XmlElementDestructor.extractCurrencyAmount():
CurrencyAmount {
)
}
+private fun XmlElementDestructor.maybeExtractTxCurrencyAmount():
CurrencyAmount? {
+ NexusAssert(
+ this.focusElement.tagName == "TxDtls",
+ "Wrong place to fetch a detailed amount"
+ )
+ return maybeUniqueChildNamed("AmtDtls") {
+ requireUniqueChildNamed("TxAmt") {
+ maybeExtractCurrencyAmount()
+ }
+ }
+}
+
private fun XmlElementDestructor.maybeExtractCurrencyAmount(): CurrencyAmount?
{
return maybeUniqueChildNamed("Amt") {
CurrencyAmount(
@@ -652,21 +664,6 @@ private fun
XmlElementDestructor.extractMaybeCurrencyExchange(): CurrencyExchang
}
}
-/*
- * 1, see if TxDtls add to a sum.
- * 2, if not, see if Btch provides a sum.
- * 3, if not, see if NtryDtls provides a sum.
- * 4, if not, keep the batch without a sum (it's not required to have one,
- * only the very outer Ntry must have one. In fact, what goes in the DB
- * is only the outer Ntry's amount).
- *
- * note: condition 4 should be rare, therefore a check on the batched
- * amount could be done towards the end, and complain if none is found.
- *
- * Right now, the code assumes that one Ntry has only one NtryDtls with only
- * one TxDtls; this assumption is too strong, and ideally should be removed.
- * */
-
// FIXME: move to util module.
private fun currencyAmountSum(amount1: CurrencyAmount?, amount2:
CurrencyAmount?): CurrencyAmount? {
if (amount1 == null) return amount2
@@ -679,7 +676,6 @@ private fun currencyAmountSum(amount1: CurrencyAmount?,
amount2: CurrencyAmount?
return CurrencyAmount(currency = amount1.currency, value = amount1.value +
amount2.value)
}
-// this function runs with a Ntry as its context.
private fun XmlElementDestructor.extractBatches(
inheritableAmount: CurrencyAmount?,
outerCreditDebitIndicator: CreditDebitIndicator
@@ -722,11 +718,11 @@ private fun XmlElementDestructor.extractBatches(
"Divergent credit-debit indicator (2)
$txCreditDebitIndicator vs $outerCreditDebitIndicator"
)
}
- var txAmount = maybeExtractCurrencyAmount()
+ var txAmount = maybeExtractCurrencyAmount() ?:
maybeExtractTxCurrencyAmount()
if (txAmount == null) {
NexusAssert(
inheritableBatchAmount != null,
- "Missing or inconsistent information about singleton
sub-transaction(s) amount(s) (0)"
+ "Singleton transaction has no amount and can't inherit it
from its container."
)
txAmount = inheritableBatchAmount
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: Camt parsing.,
gnunet <=