libeufin

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

commit 9f34f086bab15cda3f1eac459e0a90ea87b01641
parent 593880f7767f54b232607469f82c8d0e302f7199
Author: MS <ms@taler.net>
Date:   Tue,  9 Jun 2020 14:27:44 +0200

duplication check based on transaction status

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 20+++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt @@ -106,12 +106,26 @@ fun getEbicsSubscriberDetails(userId: String, transportId: String): EbicsClientS // returns true if the payment is found in the database. fun isDuplicate(camt: Document, acctSvcrRef: String): Boolean { - val found = transaction { - RawBankTransactionEntity.find { + val foundWithStatus = transaction { + val res = RawBankTransactionEntity.find { RawBankTransactionsTable.uid eq acctSvcrRef }.firstOrNull() + if (res != null) { + Pair(true, res.status) + } else { + Pair(false, null) + } } - return found != null + if (!foundWithStatus.first) + return false + + // ignore if status if the same as the one stored previously + val givenStatus = camt.pickString("//*[local-name()='Ntry']//*[local-name()='Sts']") + if (givenStatus == foundWithStatus.second) + return true + + // at this point, the message has neither a known status, or it is itself known. + return false } fun processCamtMessage(