libeufin

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

commit 51471a696f205b910070e981a1adaf2523a769cb
parent 3c27284f4865b537033221c5ca85a48da92f0cd1
Author: MS <ms@taler.net>
Date:   Mon, 30 Nov 2020 15:42:25 +0100

Relaxing the transaction details search.

Diffstat:
M.idea/vcs.xml | 1+
Mnexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt | 36++++++++++++------------------------
2 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/.idea/vcs.xml b/.idea/vcs.xml @@ -4,5 +4,6 @@ <mapping directory="" vcs="Git" /> <mapping directory="$PROJECT_DIR$/build-common" vcs="Git" /> <mapping directory="$PROJECT_DIR$/build-system/taler-build-scripts" vcs="Git" /> + <mapping directory="$PROJECT_DIR$/parsing-tests" vcs="Git" /> </component> </project> \ No newline at end of file diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt @@ -264,16 +264,9 @@ data class ReturnInfo( ) data class BatchTransaction( - // We tolerate the lack of amount in case - // this batch is a singleton and can inherit by - // parent node. val amount: CurrencyAmount?, - - // We tolerate the lack of direction, in case all - // the sub-transactions can inherit from the parent node. val creditDebitIndicator: CreditDebitIndicator?, - - val details: TransactionDetails + val details: TransactionDetails? ) @JsonInclude(JsonInclude.Include.NON_NULL) @@ -720,7 +713,7 @@ private fun XmlElementDestructor.extractBatches( ) } var amountChecksum: CurrencyAmount? = null - val txs = mapEachChildNamed("TxDtls") { + var txs = mapEachChildNamed("TxDtls") { val details = extractTransactionDetails(outerCreditDebitIndicator) val txCreditDebitIndicator = maybeExtractCreditDebitIndicator() if (txCreditDebitIndicator != null) { @@ -733,7 +726,7 @@ private fun XmlElementDestructor.extractBatches( if (txAmount == null) { NexusAssert( inheritableBatchAmount != null, - "Missing or inconsistent information about singleton sub-transaction(s) amount(s)" + "Missing or inconsistent information about singleton sub-transaction(s) amount(s) (0)" ) txAmount = inheritableBatchAmount } @@ -746,22 +739,17 @@ private fun XmlElementDestructor.extractBatches( } if (amountChecksum == null) { NexusAssert( - numTxs == 0 && txs.isEmpty() && inheritableBatchAmount != null, - "Internal amount-check failed (0)" + txs.isEmpty(), + "Missing or inconsistent information about singleton sub-transaction(s) amount(s) (1)" ) + // Without ANY sub-transaction defined, the batch MUST have it mentioned ALREADY somewhere "before". + NexusAssert( + inheritableBatchAmount != null, + "Missing or inconsistent information about singleton sub-transaction(s) amount(s) (2)" + ) + amountChecksum = batchAmount txs = mutableListOf( - BatchTransaction( - inheritableBatchAmount, - outerCreditDebitIndicator, - /** - * FIXME: the current "details extractor" assumes that - * only TxDtls can have details, and so it ignores the - * case where ZERO TxDtls are given but such information - * is scattered somewhere between the Ntry and the NtryDtls - * (including the Btch.) - * - */ - ) + BatchTransaction(batchAmount, outerCreditDebitIndicator, null) ) } NexusAssert(