[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: use long to represent date values.
From: |
gnunet |
Subject: |
[libeufin] branch master updated: use long to represent date values. |
Date: |
Tue, 18 Feb 2020 22:49:32 +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 d2184ee use long to represent date values.
d2184ee is described below
commit d2184eeac65907be5c32505ec0ee8297189b8f34
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Feb 18 22:48:44 2020 +0100
use long to represent date values.
Also, create wrapper class to hold all the
values needed to create a PAIN.001 instance.
---
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 5 +++--
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 27 +++++++++++++++++++++++
nexus/src/test/kotlin/DbTest.kt | 17 ++++++++++++++
3 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 9db3566..42f4936 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -4,6 +4,7 @@ import org.jetbrains.exposed.dao.*
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.TransactionManager
import org.jetbrains.exposed.sql.transactions.transaction
+import org.joda.time.DateTime
import tech.libeufin.nexus.EbicsSubscribersTable.entityId
import tech.libeufin.nexus.EbicsSubscribersTable.primaryKey
import tech.libeufin.util.IntIdTableWithAmount
@@ -60,7 +61,7 @@ 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 date = date("fileDate").date()
+ val fileDate = long("fileDate").default(DateTime.now().millis)
val sum = amount("sum")
val debtorAccount = text("debtorAccount")
val endToEndId = integer("EndToEndId").uniqueIndex().autoIncrement() // id
for this and the creditor system
@@ -77,7 +78,7 @@ class Pain001Entity(id: EntityID<Int>) : IntEntity(id) {
var msgId by Pain001Table.msgId
var paymentId by Pain001Table.paymentId
- var date by Pain001Table.date
+ var date by Pain001Table.fileDate
var sum by Pain001Table.sum
var debtorAccount by Pain001Table.debtorAccount
var endToEndId by Pain001Table.endToEndId
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 152cab6..242c1ed 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -158,6 +158,33 @@ fun getSubscriberDetailsFromId(id: String):
EbicsClientSubscriberDetails {
}
}
+data class Pain001Entry(
+ val debtorAccountId: String,
+ val creditorIban: String,
+ val creditorBic: String,
+ val creditorName: String,
+ val sum: Amount,
+ val subject: String
+
+)
+
+/**
+ * Insert one row in the database, and leaves it marked as non-submitted.
+ */
+fun createPain001entry(entry: Pain001Entry) {
+ transaction {
+ Pain001Entity.new {
+ subject = entry.subject
+ sum = entry.sum
+ debtorAccount = entry.debtorAccountId
+ creditorName = entry.creditorName
+ creditorBic = entry.creditorBic
+ creditorIban = entry.creditorIban
+ }
+ }
+
+}
+
fun main() {
dbCreateTables()
testData()
diff --git a/nexus/src/test/kotlin/DbTest.kt b/nexus/src/test/kotlin/DbTest.kt
index 2a4b4af..e79b783 100644
--- a/nexus/src/test/kotlin/DbTest.kt
+++ b/nexus/src/test/kotlin/DbTest.kt
@@ -7,6 +7,8 @@ import org.junit.Test
import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.transactions.transaction
import org.jetbrains.exposed.sql.SchemaUtils
+import org.joda.time.DateTime
+import tech.libeufin.util.Amount
import javax.sql.rowset.serial.SerialBlob
@@ -17,6 +19,7 @@ class DbTest {
Database.connect("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", driver =
"org.h2.Driver")
transaction {
SchemaUtils.create(EbicsSubscribersTable)
+ SchemaUtils.create(Pain001Table)
}
}
@@ -36,4 +39,18 @@ class DbTest {
assert(EbicsSubscriberEntity.findById("123asdf") != null)
}
}
+
+ @Test
+ fun testPain001() {
+ createPain001entry(
+ Pain001Entry(
+ debtorAccountId = "da",
+ creditorBic = "cb",
+ creditorIban = "ci",
+ creditorName = "cn",
+ sum = Amount(2),
+ subject = "s"
+ )
+ )
+ }
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: use long to represent date values.,
gnunet <=