gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: logging wire transfer subjects along C


From: gnunet
Subject: [libeufin] branch master updated: logging wire transfer subjects along Camt communication
Date: Mon, 28 Nov 2022 21:00: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 846b72e6 logging wire transfer subjects along Camt communication
846b72e6 is described below

commit 846b72e6703dc6c43894aee8aad02e2222b6c54c
Author: MS <ms@taler.net>
AuthorDate: Mon Nov 28 20:59:33 2022 +0100

    logging wire transfer subjects along Camt communication
---
 .../tech/libeufin/nexus/bankaccount/BankAccount.kt    | 15 +++++++++++++--
 .../kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt    |  5 ++---
 nexus/src/test/kotlin/DownloadAndSubmit.kt            | 19 ++++++++++++++++---
 .../tech/libeufin/sandbox/EbicsProtocolBackend.kt     |  7 ++++++-
 4 files changed, 37 insertions(+), 9 deletions(-)

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 b0365000..3b0ef108 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
@@ -146,6 +146,10 @@ data class CamtTransactionsCount(
     val downloadedTransactions: Int
 )
 
+/**
+ * Get the Camt parsed by a helper function, discards duplicates
+ * and stores new transactions.
+ */
 fun processCamtMessage(
     bankAccountId: String, camtDoc: Document, code: String
 ): CamtTransactionsCount {
@@ -173,6 +177,7 @@ fun processCamtMessage(
                 if (b.type == "CLBD") {
                     clbdCount++
                     val lastBalance = NexusBankBalanceEntity.all().lastOrNull()
+                    // Only store non seen balances.
                     if (lastBalance != null && b.amount.toPlainString() != 
lastBalance.balance) {
                         NexusBankBalanceEntity.new {
                             bankAccount = acct
@@ -188,7 +193,10 @@ fun processCamtMessage(
                 }
             }
         }
-
+        /**
+         * Why is the report/statement creation timestamp important,
+         * rather than each individual payment identification value?
+         */
         val stamp =
             ZonedDateTime.parse(res.creationDateTime, 
DateTimeFormatter.ISO_DATE_TIME).toInstant().toEpochMilli()
         when (code) {
@@ -206,7 +214,7 @@ fun processCamtMessage(
             }
         }
         val entries = res.reports.map { it.entries }.flatten()
-        logger.info("found ${entries.size} money movements")
+        var newPaymentsLog = ""
         downloadedTransactions = entries.size
         txloop@ for (entry in entries) {
             val singletonBatchedTransaction = 
entry.batches?.get(0)?.batchTransactions?.get(0)
@@ -238,6 +246,7 @@ fun processCamtMessage(
             }
             rawEntity.flush()
             newTransactions++
+            newPaymentsLog += "\n- " + 
entry.batches[0].batchTransactions[0].details.unstructuredRemittanceInformation
             // This block tries to acknowledge a former outgoing payment as 
booked.
             if (singletonBatchedTransaction.creditDebitIndicator == 
CreditDebitIndicator.DBIT) {
                 val t0 = singletonBatchedTransaction.details
@@ -255,6 +264,8 @@ fun processCamtMessage(
                 }
             }
         }
+        if (newTransactions > 0)
+            logger.debug("Camt $code '${res.messageId}' has new 
payments:${newPaymentsLog}")
     }
     return CamtTransactionsCount(
         newTransactions = newTransactions,
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 28c34b68..e1d63e5b 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
@@ -489,9 +489,8 @@ class EbicsBankConnectionProtocol: BankConnectionProtocol {
                 }
             }
         }
-        /* Not handling errors here because
-          sub-calls should throw and get caught by
-          global handlers.
+        /**
+         * Downloads and stores the bank message into the database.  No 
ingestion.
          */
         for (spec in specs)
             fetchEbicsC5x(
diff --git a/nexus/src/test/kotlin/DownloadAndSubmit.kt 
b/nexus/src/test/kotlin/DownloadAndSubmit.kt
index 9a387523..f061b4f9 100644
--- a/nexus/src/test/kotlin/DownloadAndSubmit.kt
+++ b/nexus/src/test/kotlin/DownloadAndSubmit.kt
@@ -100,16 +100,29 @@ class SchedulingTest {
     @Test
     fun download() {
         withNexusAndSandboxUser {
+            wireTransfer(
+                "bank",
+                "foo",
+                "default",
+                "Show up in logging!",
+                "TESTKUDOS:5"
+            )
+            wireTransfer(
+                "bank",
+                "foo",
+                "default",
+                "Exist in logging!",
+                "TESTKUDOS:5"
+            )
             withTestApplication(sandboxApp) {
                 val conn = EbicsBankConnectionProtocol()
                 runBlocking {
-                    conn.fetchTransactions(
+                    fetchBankAccountTransactions(
+                        client,
                         fetchSpec = FetchSpecAllJson(
                             level = FetchLevel.REPORT,
                             "foo"
                         ),
-                        client,
-                        "foo",
                         "mock-bank-account"
                     )
                 }
diff --git 
a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
index 103b8759..b6e9f237 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -551,7 +551,12 @@ private fun constructCamtResponse(
             balancePrcd = lastBalance,
             balanceClbd = freshBalance
         )
-        logger.debug("camt.052 document '${camtData.messageId}' generated.")
+        val payments: String = if (logger.isDebugEnabled) {
+            var ret = " It includes the payments:"
+            for (p in history) ret += "\n- ${p.subject}"
+            ret
+        } else ""
+        logger.debug("camt.052 document '${camtData.messageId}' 
generated.$payments")
         return listOf(
             camtData.camtMessage
         )

-- 
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]