gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] 06/07: comments, indentation, helpers


From: gnunet
Subject: [libeufin] 06/07: comments, indentation, helpers
Date: Mon, 03 Apr 2023 01:34:41 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

commit 9b0aafb5e814fbb4328392fbd28e80e04ca95a60
Author: MS <ms@taler.net>
AuthorDate: Mon Apr 3 01:32:14 2023 +0200

    comments, indentation, helpers
---
 nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt           |  2 +-
 .../kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt    |  5 +++++
 .../src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt  |  3 ++-
 .../src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt |  3 ++-
 nexus/src/main/kotlin/tech/libeufin/nexus/server/Helpers.kt  |  9 +++++++++
 .../main/kotlin/tech/libeufin/nexus/server/NexusServer.kt    | 12 ++++++------
 6 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
index d630b06b..ba37d8be 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
@@ -391,7 +391,7 @@ fun maybeTalerRefunds(bankAccount: NexusBankAccountEntity, 
lastSeenId: Long) {
             NexusAssert(
                 it[NexusBankTransactionsTable.creditDebitIndicator] == "CRDT" 
&&
                         it[NexusBankTransactionsTable.bankAccount] == 
bankAccount.id,
-                "Cannot refund a _outgoing_ payment!"
+                "Cannot refund an _outgoing_ payment!"
             )
             // FIXME #7116
             addPaymentInitiation(
diff --git 
a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
index 145556ed..4312e8fb 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
@@ -396,6 +396,11 @@ suspend fun fetchBankAccountTransactions(
         connectionDetails.connectionName,
         accountId
     )
+    /**
+     * Here it MIGHT just return in case of errors, but sometimes the
+     * fetcher asks for multiple results (e.g. C52 and C53), and what
+     * went through SHOULD be ingested.
+     */
 
     /**
      * This block causes new NexusBankAccountTransactions rows to be
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
index ce644ddf..0dab6190 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
@@ -800,12 +800,13 @@ class EbicsBankConnectionProtocol: BankConnectionProtocol 
{
                             HttpStatusCode.NotFound,
                             "bank connection not found"
                         )
-
+                        // Avoiding to store twice one downloaded bank account.
                         val isDuplicate = OfferedBankAccountsTable.select {
                             OfferedBankAccountsTable.bankConnection eq conn.id 
and (
                                     OfferedBankAccountsTable.offeredAccountId 
eq accountInfo.id)
                         }.firstOrNull()
                         if (isDuplicate != null) return@forEach
+                        // Storing every new bank account.
                         OfferedBankAccountsTable.insert { newRow ->
                             newRow[accountHolder] = accountInfo.accountHolder 
?: "NOT GIVEN"
                             newRow[iban] =
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 52627b66..a543d22a 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt
@@ -43,7 +43,8 @@ import java.time.ZonedDateTime
 import java.time.format.DateTimeFormatter
 
 enum class CreditDebitIndicator {
-    DBIT, CRDT
+    DBIT,
+    CRDT
 }
 
 enum class CashManagementResponseType(@get:JsonValue val jsonName: String) {
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/Helpers.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/Helpers.kt
index 8c01705a..08eb2b1d 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/Helpers.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/Helpers.kt
@@ -1,11 +1,20 @@
 package tech.libeufin.nexus.server
 
+import io.ktor.http.*
 import org.jetbrains.exposed.sql.transactions.transaction
 import tech.libeufin.nexus.NexusBankConnectionEntity
 import tech.libeufin.nexus.NexusBankConnectionsTable
+import tech.libeufin.nexus.NexusError
 import tech.libeufin.util.internalServerError
 import tech.libeufin.util.notFound
 
+fun unknownBankAccount(bankAccountLabel: String): NexusError {
+    return NexusError(
+        HttpStatusCode.NotFound,
+        "Bank account $bankAccountLabel was not found"
+    )
+}
+
 /**
  * FIXME:
  * enum type names were introduced after 0.9.2 and need to
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index fb864d3b..03f12cf6 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -456,7 +456,7 @@ val nexusApp: Application.() -> Unit = {
             resp.set<JsonNode>("schedule", ops)
             transaction {
                 NexusBankAccountEntity.findByName(accountId)
-                    ?: throw NexusError(HttpStatusCode.NotFound, "unknown bank 
account")
+                    ?: throw unknownBankAccount(accountId)
                 NexusScheduledTaskEntity.find {
                     (NexusScheduledTasksTable.resourceType eq "bank-account") 
and
                             (NexusScheduledTasksTable.resourceId eq accountId)
@@ -479,7 +479,7 @@ val nexusApp: Application.() -> Unit = {
             val accountId = ensureNonNull(call.parameters["accountId"])
             transaction {
                 NexusBankAccountEntity.findByName(accountId)
-                    ?: throw NexusError(HttpStatusCode.NotFound, "unknown bank 
account")
+                    ?: throw unknownBankAccount(accountId)
                 try {
                     NexusCron.parser.parse(schedSpec.cronspec)
                 } catch (e: IllegalArgumentException) {
@@ -550,7 +550,7 @@ val nexusApp: Application.() -> Unit = {
             transaction {
                 val bankAccount = NexusBankAccountEntity.findByName(accountId)
                 if (bankAccount == null) {
-                    throw NexusError(HttpStatusCode.NotFound, "unknown bank 
account")
+                    throw unknownBankAccount(accountId)
                 }
                 val oldSchedTask = NexusScheduledTaskEntity.find {
                     (NexusScheduledTasksTable.taskName eq taskId) and
@@ -571,7 +571,7 @@ val nexusApp: Application.() -> Unit = {
             val res = transaction {
                 val bankAccount = NexusBankAccountEntity.findByName(accountId)
                 if (bankAccount == null) {
-                    throw NexusError(HttpStatusCode.NotFound, "unknown bank 
account")
+                    throw unknownBankAccount(accountId)
                 }
                 val holderEnc = URLEncoder.encode(bankAccount.accountHolder, 
Charsets.UTF_8)
                 val lastSeenBalance = NexusBankBalanceEntity.find {
@@ -693,7 +693,7 @@ val nexusApp: Application.() -> Unit = {
             val res = transaction {
                 val bankAccount = NexusBankAccountEntity.findByName(accountId)
                 if (bankAccount == null) {
-                    throw NexusError(HttpStatusCode.NotFound, "unknown bank 
account ($accountId)")
+                    throw unknownBankAccount(accountId)
                 }
                 val amount = parseAmount(body.amount)
                 val paymentEntity = addPaymentInitiation(
@@ -767,7 +767,7 @@ val nexusApp: Application.() -> Unit = {
             transaction {
                 val bankAccount = 
NexusBankAccountEntity.findByName(bankAccountId)
                 if (bankAccount == null) {
-                    throw NexusError(HttpStatusCode.NotFound, "unknown bank 
account")
+                    throw unknownBankAccount(bankAccountId)
                 }
                 NexusBankTransactionEntity.find { 
NexusBankTransactionsTable.bankAccount eq bankAccount.id }.map {
                     val tx = jacksonObjectMapper().readValue(

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]