gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: progress


From: gnunet
Subject: [libeufin] branch master updated: progress
Date: Fri, 24 Jan 2020 16:06:29 +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 01bec08  progress
01bec08 is described below

commit 01bec0882980f72b6277a74c33fd581e5c13f25d
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Jan 24 16:06:21 2020 +0100

    progress
---
 .idea/jarRepositories.xml                          | 25 ++++++++++++++++++++++
 .../src/main/kotlin/tech/libeufin/sandbox/DB.kt    |  6 ++++--
 .../src/main/kotlin/tech/libeufin/sandbox/JSON.kt  |  3 ++-
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  | 25 ++++++++++++++--------
 4 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..b3e9cbd
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RemoteRepositoriesConfiguration">
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Maven Central repository" />
+      <option name="url" value="https://repo1.maven.org/maven2"; />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="jboss.community" />
+      <option name="name" value="JBoss Community repository" />
+      <option name="url" 
value="https://repository.jboss.org/nexus/content/repositories/public/"; />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="MavenRepo" />
+      <option name="name" value="MavenRepo" />
+      <option name="url" value="https://repo.maven.apache.org/maven2/"; />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="BintrayJCenter" />
+      <option name="name" value="BintrayJCenter" />
+      <option name="url" value="https://jcenter.bintray.com/"; />
+    </remote-repository>
+  </component>
+</project>
\ No newline at end of file
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index 5b15032..a8e84f9 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -159,7 +159,8 @@ object BankTransactionsTable : IntIdTableWithAmount() {
     val counterpart = varchar("counterpart", MAX_ID_LENGTH)
     val amount = amount("amount")
     val subject = varchar("subject", MAX_SUBJECT_LENGTH)
-    val date = date("date")
+    val operationDate = datetime("operationDate")
+    val valueDate = datetime("valueDate")
     val localCustomer = reference("localCustomer", BankCustomersTable)
 }
 
@@ -176,7 +177,8 @@ class BankTransactionEntity(id: EntityID<Int>) : 
IntEntity(id) {
     var counterpart by BankTransactionsTable.counterpart
 
     var subject by BankTransactionsTable.subject
-    var date by BankTransactionsTable.date
+    var operationDate by BankTransactionsTable.operationDate
+    var valueDate by BankTransactionsTable.valueDate
     var amount by BankTransactionsTable.amount
 }
 
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
index bde1449..3b45960 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
@@ -63,7 +63,8 @@ data class CustomerHistoryResponseElement(
     var amount: String,
     val subject: String,
     val counterpart: String,
-    val date: String
+    val operationDate: String,
+    val valueDate: String
 )
 
 data class CustomerHistoryResponse(
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 04bcb5d..c582cc3 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -38,6 +38,7 @@ import io.ktor.routing.post
 import io.ktor.routing.routing
 import io.ktor.server.engine.embeddedServer
 import io.ktor.server.netty.Netty
+import org.jetbrains.exposed.sql.Date
 import org.jetbrains.exposed.sql.StdOutSqlLogger
 import org.jetbrains.exposed.sql.addLogger
 import org.jetbrains.exposed.sql.and
@@ -162,7 +163,8 @@ fun sampleData() {
                 counterpart = "IBAN"
                 amount = i
                 subject = "transaction $i"
-                date = DateTime.now()
+                operationDate = DateTime.now()
+                valueDate = DateTime.now()
                 localCustomer = customerEntity
             }
         }
@@ -170,7 +172,10 @@ fun sampleData() {
 }
 
 /**
- * Finds the history for a customer
+ * Finds the history for a customer, given dates of 'value'.  This date
+ * specifies the point in time where a operation settled.  The other type
+ * of date is 'operation', that indicates the point in time where the
+ * transaction was created in the bank's system.
  *
  * @param id the customer whose history must be returned.  This
  * id is local to the bank and is not reused/encoded into other
@@ -179,15 +184,18 @@ fun sampleData() {
  */
 fun extractHistoryForEach(id: Int, start: String?, end: String?, builder: 
(BankTransactionEntity) -> Any) {
 
-    LOGGER.debug("Fetching history from $start to $end")
+
     val s = if (start != null) DateTime.parse(start) else DateTime(0)
     val e = if (end != null) DateTime.parse(end) else DateTime.now()
 
+    LOGGER.debug("Fetching history from $s to $e")
+
     transaction {
+        addLogger(StdOutSqlLogger)
         BankTransactionEntity.find {
-            BankTransactionsTable.localCustomer eq id and
-                    BankTransactionsTable.date.between(s, e)
+            BankTransactionsTable.localCustomer eq id and 
BankTransactionsTable.valueDate.between(s, e)
         }.forEach {
+            LOGGER.debug("Found history element: $it")
             builder(it)
         }
     }
@@ -201,7 +209,7 @@ fun calculateBalance(id: Int, start: String?, end: 
String?): BigDecimal {
 
     transaction {
         BankTransactionEntity.find {
-            BankTransactionsTable.localCustomer eq id and 
BankTransactionsTable.date.between(s, e)
+            BankTransactionsTable.localCustomer eq id and 
BankTransactionsTable.operationDate.between(s, e)
         }.forEach { ret += it.amount }
     }
     return ret
@@ -246,8 +254,6 @@ fun main() {
             post("/{id}/history") {
 
                 val req = call.receive<CustomerHistoryRequest>()
-                LOGGER.debug("Fetching history from ${req.start}, to 
${req.end}")
-
                 val customer = findCustomer(call.parameters["id"])
                 val ret = CustomerHistoryResponse()
 
@@ -257,7 +263,8 @@ fun main() {
                             subject = it.subject,
                             amount = "${it.amount.signToString()}${it.amount} 
EUR",
                             counterpart = it.counterpart,
-                            date = it.date.toString("Y-M-d")
+                            operationDate = it.operationDate.toString("Y-M-d"),
+                            valueDate = it.operationDate.toString("Y-M-d")
                         )
                     )
                 }

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



reply via email to

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