gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Sample data, plus balance construction


From: gnunet
Subject: [libeufin] branch master updated: Sample data, plus balance construction.
Date: Fri, 06 Dec 2019 23:31:21 +0100

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

marcello pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 9aa0c1a  Sample data, plus balance construction.
9aa0c1a is described below

commit 9aa0c1a031d4c72d045b553a215d776994a9b4ee
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Dec 6 23:30:35 2019 +0100

    Sample data, plus balance construction.
---
 .../src/main/kotlin/tech/libeufin/sandbox/DB.kt    |  1 +
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  | 28 ++++++++++++++++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index 1c866ea..e97e3f0 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -371,6 +371,7 @@ fun dbCreateTables() {
     transaction {
 
         SchemaUtils.createMissingTablesAndColumns(
+            BankTransactionsTable,
             BankCustomersTable,
             EbicsSubscribersTable,
             EbicsHostsTable,
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index c44ce30..2e0bec4 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -40,6 +40,7 @@ import io.ktor.server.engine.embeddedServer
 import io.ktor.server.netty.Netty
 import org.jetbrains.exposed.sql.and
 import org.jetbrains.exposed.sql.transactions.transaction
+import org.joda.time.DateTime
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 import org.w3c.dom.Document
@@ -118,6 +119,10 @@ inline fun <reified T> Document.toObject(): T {
     return m.unmarshal(this, T::class.java).value
 }
 
+fun sampleTransactions() {
+
+}
+
 fun main() {
     dbCreateTables()
 
@@ -138,7 +143,6 @@ fun main() {
             name = "Mina"
             }
 
-
         EbicsSubscriberEntity.new {
             partnerId = "PARTNER1"
             userId = "USER1"
@@ -147,6 +151,17 @@ fun main() {
             nextOrderID = 1
             bankCustomer = customerEntity
         }
+
+        for (i in 1..10) {
+            BankTransactionEntity.new {
+                counterpart = "IBAN"
+                amount = Amount(1)
+                subject = "transaction $i"
+                date = DateTime.now()
+                localCustomer = customerEntity
+            }
+
+        }
     }
 
     val server = embeddedServer(Netty, port = 5000) {
@@ -179,7 +194,14 @@ fun main() {
             get("/{id}/balance") {
                 val (name, balance) = transaction {
                     val tmp: BankCustomerEntity = 
findCustomer(call.parameters["id"])
-                    Pair(tmp.name, 0) // fixme/todo!
+
+                    var ret = Amount(0)
+                    BankTransactionEntity.find {
+                        BankTransactionsTable.localCustomer eq tmp.id
+                    }.forEach {
+                        ret += it.amount
+                    }
+                    Pair(tmp.name, ret)
                 }
 
                 call.respond(
@@ -188,6 +210,8 @@ fun main() {
                     balance = "EUR:${balance}"
                     )
                 )
+
+                return@get
             }
 
             get("/") {

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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