[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated (939de8f -> f7dde5a)
From: |
gnunet |
Subject: |
[libeufin] branch master updated (939de8f -> f7dde5a) |
Date: |
Tue, 16 Jun 2020 14:27:56 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a change to branch master
in repository libeufin.
from 939de8f prefer IS020022 terminology
new 22045f1 look for old transaction to supersede
new f7dde5a use enum
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 8 +++++++-
.../src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 22 ++++++++++------------
nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt | 2 +-
3 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 97997a4..2bd40e5 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -147,7 +147,12 @@ object RawBankTransactionsTable : LongIdTable() {
/**
* Booked / pending / informational.
*/
- val status = text("status")
+ val status = enumerationByName("status", 16, TransactionStatus::class)
+
+ /**
+ * Another, later transaction that updates the status of the current
transaction.
+ */
+ val updatedBy = optReference("updatedBy", RawBankTransactionsTable)
/**
* Full details of the transaction in JSON format.
@@ -165,6 +170,7 @@ class RawBankTransactionEntity(id: EntityID<Long>) :
LongEntity(id) {
var bankAccount by NexusBankAccountEntity referencedOn
RawBankTransactionsTable.bankAccount
var transactionJson by RawBankTransactionsTable.transactionJson
var accountTransactionId by RawBankTransactionsTable.accountTransactionId
+ val updatedBy by RawBankTransactionEntity optionalReferencedOn
RawBankTransactionsTable.updatedBy
}
/**
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
index d3c0903..ad07c9f 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
@@ -20,12 +20,9 @@
package tech.libeufin.nexus
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
-import io.ktor.client.HttpClient
import io.ktor.http.HttpStatusCode
-import io.ktor.request.ApplicationRequest
import org.jetbrains.exposed.sql.SortOrder
import org.jetbrains.exposed.sql.and
-import org.jetbrains.exposed.sql.statements.api.ExposedBlob
import org.jetbrains.exposed.sql.transactions.transaction
import org.w3c.dom.Document
import tech.libeufin.util.*
@@ -103,14 +100,13 @@ fun getEbicsSubscriberDetailsInternal(subscriber:
EbicsSubscriberEntity): EbicsC
/**
* Check if the transaction is already found in the database.
*/
-private fun isDuplicate(acctSvcrRef: String): Boolean {
+private fun findDuplicate(bankAccountId: String, acctSvcrRef: String):
RawBankTransactionEntity? {
// FIXME: make this generic depending on transaction identification scheme
val ati = "AcctSvcrRef:$acctSvcrRef"
return transaction {
- val res = RawBankTransactionEntity.find {
- RawBankTransactionsTable.accountTransactionId eq ati
+ RawBankTransactionEntity.find {
+ (RawBankTransactionsTable.accountTransactionId eq ati) and
(RawBankTransactionsTable.bankAccount eq bankAccountId)
}.firstOrNull()
- res != null
}
}
@@ -126,16 +122,18 @@ fun processCamtMessage(
}
val transactions = getTransactions(camtDoc)
logger.info("found ${transactions.size} transactions")
- for (tx in transactions) {
+ txloop@for (tx in transactions) {
val acctSvcrRef = tx.accountServicerReference
if (acctSvcrRef == null) {
// FIXME(dold): Report this!
logger.error("missing account servicer reference in
transaction")
continue
}
- if (isDuplicate(acctSvcrRef)) {
- logger.info("Processing a duplicate, not storing it.")
- return@transaction
+ val duplicate = findDuplicate(bankAccountId, acctSvcrRef)
+ if (duplicate != null) {
+ // FIXME(dold): See if an old transaction needs to be
superseded by this one
+ // https://bugs.gnunet.org/view.php?id=6381
+ break
}
RawBankTransactionEntity.new {
bankAccount = acct
@@ -144,7 +142,7 @@ fun processCamtMessage(
currency = tx.currency
transactionJson =
jacksonObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(tx)
creditDebitIndicator = tx.creditDebitIndicator.name
- status = tx.status.name
+ status = tx.status
}
}
}
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
index 85e9cc8..f09a332 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
@@ -515,7 +515,7 @@ fun ingestTalerTransactions() {
/** Those with exchange bank account involved */
RawBankTransactionsTable.bankAccount eq subscriberAccount.id.value
and
/** Those that are booked */
- (RawBankTransactionsTable.status eq "BOOK") and
+ (RawBankTransactionsTable.status eq
TransactionStatus.BOOK) and
/** Those that came later than the latest processed
payment */
(RawBankTransactionsTable.id.greater(lastId))
}.orderBy(Pair(RawBankTransactionsTable.id, SortOrder.ASC)).forEach {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libeufin] branch master updated (939de8f -> f7dde5a),
gnunet <=