gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: improve sandbox transaction history


From: gnunet
Subject: [libeufin] branch master updated: improve sandbox transaction history
Date: Sun, 17 Jan 2021 01:04:52 +0100

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

dold pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new ccba644  improve sandbox transaction history
ccba644 is described below

commit ccba644bd59347255a4740575170e96353f24304
Author: Florian Dold <florian@dold.me>
AuthorDate: Sun Jan 17 01:04:47 2021 +0100

    improve sandbox transaction history
---
 .../src/main/kotlin/tech/libeufin/sandbox/JSON.kt  |  8 +++++++
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  | 27 +++++++++++++---------
 util/src/main/kotlin/JSON.kt                       | 16 +++++++++++++
 3 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
index 69804e7..c7f906c 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
@@ -19,6 +19,7 @@
 
 package tech.libeufin.sandbox
 
+import tech.libeufin.util.PaymentInfo
 import tech.libeufin.util.RawPayment
 
 /**
@@ -50,6 +51,13 @@ data class PaymentsResponse(
     val payments: MutableList<RawPayment> = mutableListOf()
 )
 
+/**
+ * List type that show all the payments existing in the system.
+ */
+data class AccountTransactions(
+    val payments: MutableList<PaymentInfo> = mutableListOf()
+)
+
 /**
  * Used to create AND show one Ebics subscriber in the system.
  */
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 3b61b46..ca7cc89 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -74,6 +74,7 @@ import 
tech.libeufin.sandbox.BankAccountTransactionsTable.debtorBic
 import tech.libeufin.sandbox.BankAccountTransactionsTable.debtorIban
 import tech.libeufin.sandbox.BankAccountTransactionsTable.debtorName
 import tech.libeufin.sandbox.BankAccountTransactionsTable.direction
+import tech.libeufin.sandbox.BankAccountTransactionsTable.pmtInfId
 import tech.libeufin.util.*
 import tech.libeufin.util.ebics_h004.EbicsResponse
 import tech.libeufin.util.ebics_h004.EbicsTypes
@@ -425,7 +426,7 @@ fun serverMain(dbName: String, port: Int) {
                 call.respond(accounts)
             }
             get("/admin/bank-accounts/{label}/transactions") {
-                val ret = PaymentsResponse()
+                val ret = AccountTransactions()
                 transaction {
                     val accountLabel = ensureNonNull(call.parameters["label"])
                     transaction {
@@ -433,28 +434,32 @@ fun serverMain(dbName: String, port: Int) {
                         BankAccountTransactionsTable.select { 
BankAccountTransactionsTable.account eq account.id }
                             .forEach {
                                 ret.payments.add(
-                                    RawPayment(
+                                    PaymentInfo(
+                                        accountLabel = account.label,
                                         creditorIban = it[creditorIban],
-                                        debitorIban = it[debtorIban],
+                                        // FIXME: We need to modify the 
transactions table to have an actual
+                                        // account servicer reference here.
+                                        accountServicerReference = 
it[pmtInfId],
+                                        debtorIban = it[debtorIban],
                                         subject = 
it[BankAccountTransactionsTable.subject],
                                         date = it[date].toHttpDateString(),
                                         amount = it[amount],
                                         creditorBic = it[creditorBic],
                                         creditorName = it[creditorName],
-                                        debitorBic = it[debtorBic],
-                                        debitorName = it[debtorName],
+                                        debtorBic = it[debtorBic],
+                                        debtorName = it[debtorName],
                                         currency = it[currency],
-                                        direction = it[direction]
+                                        creditDebitIndicator = when 
(it[direction]) {
+                                            "CRDT" -> "credit"
+                                            "DBIT" -> "debit"
+                                            else -> throw Error("invalid 
direction")
+                                        }
                                     )
                                 )
                             }
                     }
                 }
-                call.respond(
-                    object {
-                        val payments = ret
-                    }
-                )
+                call.respond(ret)
             }
             post("/admin/bank-accounts/{label}/generate-transactions") {
                 transaction {
diff --git a/util/src/main/kotlin/JSON.kt b/util/src/main/kotlin/JSON.kt
index 4883056..1b9cb03 100644
--- a/util/src/main/kotlin/JSON.kt
+++ b/util/src/main/kotlin/JSON.kt
@@ -53,3 +53,19 @@ data class IncomingPaymentInfo(
     val currency: String,
     val subject: String
 )
+
+data class PaymentInfo(
+    val accountLabel: String,
+    val creditorIban: String,
+    val creditorBic: String?,
+    val creditorName: String,
+    val debtorIban: String,
+    val debtorBic: String?,
+    val debtorName: String,
+    val amount: String,
+    val currency: String,
+    val subject: String,
+    val date: String? = null,
+    val creditDebitIndicator: String,
+    val accountServicerReference: String
+)
\ No newline at end of file

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