gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Avoid autoIncrement().


From: gnunet
Subject: [libeufin] branch master updated: Avoid autoIncrement().
Date: Tue, 03 Mar 2020 19:07:09 +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 b230122  Avoid autoIncrement().
b230122 is described below

commit b230122c9f62c889f297c58451c0fa1d2dad1ebc
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Mar 3 19:05:39 2020 +0100

    Avoid autoIncrement().
---
 nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt   |  9 +++++----
 nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt |  8 ++++++++
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 13 +++++--------
 nexus/src/test/kotlin/PainGeneration.kt           | 19 +++++++++++++++++++
 sandbox/src/main/python/libeufin-cli              | 12 +++++++-----
 5 files changed, 44 insertions(+), 17 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 5404bd2..3e4735b 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -59,12 +59,12 @@ const val ID_MAX_LENGTH = 50
 //}
 
 object Pain001Table : IntIdTableWithAmount() {
-    val msgId = integer("msgId").uniqueIndex().autoIncrement()
-    val paymentId = integer("paymentId").uniqueIndex().autoIncrement() // id 
for this system
-    val fileDate = long("fileDate").default(DateTime.now().millis)
+    val msgId = long("msgId").uniqueIndex().autoIncrement()
+    val paymentId = long("paymentId")
+    val fileDate = long("fileDate")
     val sum = amount("sum")
     val debtorAccount = text("debtorAccount")
-    val endToEndId = integer("EndToEndId").uniqueIndex().autoIncrement() // id 
for this and the creditor system
+    val endToEndId = long("EndToEndId")
     val subject = text("subject")
     val creditorIban = text("creditorIban")
     val creditorBic = text("creditorBic")
@@ -137,6 +137,7 @@ fun dbCreateTables() {
     transaction {
         addLogger(StdOutSqlLogger)
          SchemaUtils.create(
+             Pain001Table,
             EbicsSubscribersTable,
             EbicsAccountsInfoTable
          )
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
index 68f46b2..8b4aa04 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
@@ -85,6 +85,14 @@ data class EbicsSubscriberInfoResponseJson(
     val systemID: String? = null
 )
 
+data class Pain001Data(
+    val creditorIban: String,
+    val creditorBic: String,
+    val creditorName: String,
+    val sum: Amount,
+    val subject: String
+)
+
 /**
  * Admin call that tells all the subscribers managed by Nexus.
  */
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 39c3fd6..52cec6c 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -159,14 +159,6 @@ fun getSubscriberDetailsFromId(id: String): 
EbicsClientSubscriberDetails {
     }
 }
 
-data class Pain001Data(
-    val creditorIban: String,
-    val creditorBic: String,
-    val creditorName: String,
-    val sum: Amount,
-    val subject: String
-)
-
 /**
  * Create a PAIN.001 XML document according to the input data.
  * Needs to be called within a transaction block.
@@ -291,6 +283,7 @@ fun createPain001document(pain001Entity: Pain001Entity): 
String {
  * Insert one row in the database, and leaves it marked as non-submitted.
  */
 fun createPain001entry(entry: Pain001Data, debtorAccountId: String) {
+    val randomId = Random().nextLong()
     transaction {
         Pain001Entity.new {
             subject = entry.subject
@@ -299,6 +292,10 @@ fun createPain001entry(entry: Pain001Data, 
debtorAccountId: String) {
             creditorName = entry.creditorName
             creditorBic = entry.creditorBic
             creditorIban = entry.creditorIban
+            date = DateTime.now().millis
+            paymentId = randomId
+            msgId = randomId
+            endToEndId = randomId
         }
     }
 }
diff --git a/nexus/src/test/kotlin/PainGeneration.kt 
b/nexus/src/test/kotlin/PainGeneration.kt
index 05db5bb..1296747 100644
--- a/nexus/src/test/kotlin/PainGeneration.kt
+++ b/nexus/src/test/kotlin/PainGeneration.kt
@@ -42,6 +42,20 @@ class PainTest {
         }
     }
 
+    @Test
+    fun testPain001helper() {
+        val data = Pain001Data(
+            creditorIban = "xy",
+            creditorBic = "xy",
+            creditorName = "xy",
+            sum = Amount("1.01"),
+            subject = "xy"
+        )
+        transaction {
+            createPain001entry(data, "debtor-bankaccount-id")
+        }
+    }
+
     @Test
     fun testPain001document() {
         transaction {
@@ -52,6 +66,11 @@ class PainTest {
                 creditorIban = "CREDIT IBAN"
                 creditorBic = "CREDIT BIC"
                 creditorName = "CREDIT NAME"
+                paymentId = 1
+                msgId = 1
+                endToEndId = 1
+                date = 1
+
             }
             val s = createPain001document(pain001Entity)
             println(s)
diff --git a/sandbox/src/main/python/libeufin-cli 
b/sandbox/src/main/python/libeufin-cli
index 7a202ca..fb91f4d 100755
--- a/sandbox/src/main/python/libeufin-cli
+++ b/sandbox/src/main/python/libeufin-cli
@@ -613,15 +613,17 @@ def prepare(ctx, account_id, nexus_base_url):
 )
 def prepare_payment(
     ctx, account_id, bank_account_id, creditor_iban,
-    creditor_bic, creditor_name, subject, amount, nexus_base_url):
+    creditor_bic, creditor_name, subject, sum, nexus_base_url):
     nexus_url = urljoin(
         nexus_base_url, 
"/ebics/subscribers/{}/accounts/{}/prepare-payment".format(
             account_id, bank_account_id))
     body = dict(
-            ebicsURL=ebics_url,
-            userID=user_id,
-            partnerID=partner_id,
-            hostID=host_id
+        debtorAccount = bank_account_id,
+        creditorIban = creditor_iban,
+        creditorBic = creditor_bic,
+        creditorName = creditor_name,
+        subject = subject,
+        sum = sum
     )
     try:
         resp = post(nexus_url, json=body)

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



reply via email to

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