[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Give endpoint to query C53 entries in
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Give endpoint to query C53 entries in DB. |
Date: |
Thu, 26 Mar 2020 11:56:14 +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 f91bbda Give endpoint to query C53 entries in DB.
f91bbda is described below
commit f91bbdac3e752cb3246de8ad2decfb6d8d8227f3
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Mar 26 11:55:01 2020 +0100
Give endpoint to query C53 entries in DB.
---
cli/python/libeufin-cli | 22 ++++++++++++++
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 2 ++
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 35 +++++++++++++++++------
3 files changed, 50 insertions(+), 9 deletions(-)
diff --git a/cli/python/libeufin-cli b/cli/python/libeufin-cli
index 20de048..6500923 100755
--- a/cli/python/libeufin-cli
+++ b/cli/python/libeufin-cli
@@ -423,6 +423,28 @@ def crz(obj, account_id, date_range, nexus_base_url):
print(resp.content.decode("utf-8"))
+@ebics.command(help="Show raw transactions from the Nexus database")
+@click.pass_obj
+@click.option(
+ "--account-id",
+ help="Numerical ID of the customer at the Nexus",
+ required=True
+)
+@click.argument(
+ "nexus-base-url"
+)
+def show_collected_c53(obj, account_id, date_range, nexus_base_url):
+ if date_range is not None and len(date_range) == 2:
+ req = dict(dateRange=dict(start=date_range[0], end=date_range[1]))
+ else:
+ req = dict()
+ url = urljoin(nexus_base_url,
"/ebics/subscribers/{}/collect-transactions-c53".format(account_id))
+ resp = post(url, json=req)
+ print(resp.content.decode("utf-8"))
+
+
+
+
@ebics.command(help="Send C53 message AND instruct the Nexus to persist the
result")
@click.pass_obj
@click.option(
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 1c0c900..8362ae0 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -28,6 +28,7 @@ object EbicsRawBankTransactionsTable : IdTable<Long>() {
val amount = text("amount")
val creditorIban = text("creditorIban")
val debitorIban = text("creditorIban")
+ val bookingDate = text("bookingDate")
}
class EbicsRawBankTransactionEntry(id: EntityID<Long>) : LongEntity(id) {
@@ -40,6 +41,7 @@ class EbicsRawBankTransactionEntry(id: EntityID<Long>) :
LongEntity(id) {
var amount by EbicsRawBankTransactionsTable.amount
var creditorIban by EbicsRawBankTransactionsTable.creditorIban
var debitorIban by EbicsRawBankTransactionsTable.debitorIban
+ var bookingDate by EbicsRawBankTransactionsTable.bookingDate
var nexusSubscriber by EbicsSubscriberEntity referencedOn
EbicsRawBankTransactionsTable.nexusSubscriber
}
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 3032ccb..89546be 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -626,6 +626,27 @@ fun main() {
}
+ get("/ebics/subscribers/{id}/show-collected-transactions-c53") {
+ val id = expectId(call.parameters["id"])
+ var ret = ""
+ transaction {
+ val subscriber = getSubscriberEntityFromId(id)
+ EbicsRawBankTransactionEntry.find {
+ (EbicsRawBankTransactionsTable.nexusSubscriber eq
subscriber.id) and
+ (EbicsRawBankTransactionsTable.sourceType eq
"C53")
+ }.forEach {
+ ret += "\n###\nCreditor: ${it.creditorIban}\nDebitor:
${it.debitorIban}\nAmount: ${it.currency}:${it.amount}\nDate: ${it.bookingDate}"
+ }
+ }
+
+ call.respondText(
+ ret,
+ ContentType.Text.Plain,
+ HttpStatusCode.OK
+ )
+
+ return@get
+ }
post("/ebics/subscribers/{id}/collect-transactions-c53") {
// FIXME(florian): Download C53 and store the result in the
right database table
val id = expectId(call.parameters["id"])
@@ -662,6 +683,10 @@ fun main() {
camt53doc,
"//*[local-name()='Ntry']//*[local-name()='Amt']"
)
+ val bookingDate = XMLUtil.getStringFromXpath(
+ camt53doc,
+
"//*[local-name()='BookgDt']//*[local-name()='Dt']"
+ )
val subject = XMLUtil.getStringFromXpath(
camt53doc,
"//*[local-name()='RmtInf']//*[local-name()='Ustrd']"
@@ -670,15 +695,6 @@ fun main() {
camt53doc,
"//*[local-name()='Ntry']//*[local-name()='Amt']/@Ccy"
)
- println(
- "####" +
- "\n\tCreditor IBAN: $creditorIban," +
- "\n\tDebitor IBAN: $debitorIban," +
- "\n\tCurrency: $currency," +
- "\n\tAmount: ${amount}" +
- "\n\tSubject: $subject," +
- "\n\tFile name: $fileName"
- )
transaction {
EbicsRawBankTransactionEntry.new {
sourceType = "C53"
@@ -689,6 +705,7 @@ fun main() {
this.amount = amount
this.creditorIban = creditorIban
this.debitorIban = debitorIban
+ this.bookingDate = bookingDate
nexusSubscriber =
getSubscriberEntityFromId(id)
}
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: Give endpoint to query C53 entries in DB.,
gnunet <=