commit 96ed7be496dafa5d033e131cb47dcc350ae40e20
parent f91bbdac3e752cb3246de8ad2decfb6d8d8227f3
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date: Thu, 26 Mar 2020 12:45:29 +0100
Use native long 'id' for table.
Diffstat:
4 files changed, 12 insertions(+), 25 deletions(-)
diff --git a/cli/python/libeufin-cli b/cli/python/libeufin-cli
@@ -433,18 +433,11 @@ def crz(obj, account_id, date_range, nexus_base_url):
@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)
+def show_collected_c53(obj, account_id, nexus_base_url):
+ url = urljoin(nexus_base_url, "/ebics/subscribers/{}/show-collected-transactions-c53".format(account_id))
+ resp = get(url)
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
@@ -13,8 +13,7 @@ import java.sql.Connection
const val ID_MAX_LENGTH = 50
-object EbicsRawBankTransactionsTable : IdTable<Long>() {
- override val id = EbicsSubscribersTable.long("id").entityId().primaryKey()
+object EbicsRawBankTransactionsTable : LongIdTable() {
val nexusSubscriber = reference("subscriber", EbicsSubscribersTable)
// How did we learn about this transaction? C52 / C53 / C54
val sourceType = text("sourceType")
@@ -27,7 +26,7 @@ object EbicsRawBankTransactionsTable : IdTable<Long>() {
val currency = text("currency")
val amount = text("amount")
val creditorIban = text("creditorIban")
- val debitorIban = text("creditorIban")
+ val debitorIban = text("debitorIban")
val bookingDate = text("bookingDate")
}
@@ -134,8 +133,9 @@ fun dbCreateTables() {
addLogger(StdOutSqlLogger)
SchemaUtils.create(
Pain001Table,
- EbicsSubscribersTable,
- EbicsAccountsInfoTable
+ EbicsSubscribersTable,
+ EbicsAccountsInfoTable,
+ EbicsRawBankTransactionsTable
)
}
}
\ No newline at end of file
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -143,7 +143,6 @@ fun extractFirstBic(bankCodes: List<EbicsTypes.AbstractBankCode>?): String? {
return item.value
}
}
-
return null
}
@@ -274,7 +273,6 @@ fun createPain001document(pain001Entity: Pain001Entity): String {
EbicsAccountInfoEntity.findById(pain001Entity.debtorAccount)?.bankCode ?: throw NexusError(HttpStatusCode.NotFound,"Debtor BIC not found in database")
})
}
-
element("ChrgBr") {
text("SLEV")
}
@@ -434,7 +432,6 @@ fun main() {
}
}
}
-
get("/ebics/subscribers/{id}/accounts") {
// this information is only avaiable *after* HTD or HKD has been called
val id = expectId(call.parameters["id"])
@@ -625,20 +622,19 @@ fun main() {
// FIXME(florian): Download C52 and store the result in the right database table
}
-
get("/ebics/subscribers/{id}/show-collected-transactions-c53") {
val id = expectId(call.parameters["id"])
var ret = ""
transaction {
- val subscriber = getSubscriberEntityFromId(id)
+ val subscriber: EbicsSubscriberEntity = getSubscriberEntityFromId(id)
EbicsRawBankTransactionEntry.find {
- (EbicsRawBankTransactionsTable.nexusSubscriber eq subscriber.id) and
+ (EbicsRawBankTransactionsTable.nexusSubscriber eq subscriber.id.value) and
(EbicsRawBankTransactionsTable.sourceType eq "C53")
}.forEach {
- ret += "\n###\nCreditor: ${it.creditorIban}\nDebitor: ${it.debitorIban}\nAmount: ${it.currency}:${it.amount}\nDate: ${it.bookingDate}"
+ ret += "###\nDebitor: ${it.debitorIban}\nCreditor: ${it.creditorIban}\nAmount: ${it.currency}:${it.amount}\nDate: ${it.bookingDate}\n"
}
}
-
+
call.respondText(
ret,
ContentType.Text.Plain,
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -95,7 +95,6 @@ enum class KeyState {
object BankTransactionsTable : IntIdTableWithAmount() {
-
/* Using varchar to store the IBAN - or possibly other formats
* - from the counterpart. */
val counterpart = varchar("counterpart", MAX_ID_LENGTH)
@@ -107,7 +106,6 @@ object BankTransactionsTable : IntIdTableWithAmount() {
}
class BankTransactionEntity(id: EntityID<Int>) : IntEntity(id) {
-
companion object : IntEntityClass<BankTransactionEntity>(BankTransactionsTable)
/* the id of the local customer involved in this transaction,
* either as the credit or the debit part; makes lookups easier */