[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: transactions belong to the bank accoun
From: |
gnunet |
Subject: |
[libeufin] branch master updated: transactions belong to the bank account, not the user |
Date: |
Sun, 24 May 2020 19:41:24 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new 18dd2f7 transactions belong to the bank account, not the user
18dd2f7 is described below
commit 18dd2f70ed5d87f4bcdb36028571bb5976387230
Author: Florian Dold <address@hidden>
AuthorDate: Sun May 24 23:11:19 2020 +0530
transactions belong to the bank account, not the user
---
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 2 --
.../src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 36 +++++-----------------
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 6 ++--
3 files changed, 10 insertions(+), 34 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index e6853ce..9d486b5 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -91,7 +91,6 @@ class TalerIncomingPaymentEntity(id: EntityID<Long>) :
LongEntity(id) {
* CAMT message.
*/
object RawBankTransactionsTable : LongIdTable() {
- val nexusUser = reference("nexusUser", NexusUsersTable)
val unstructuredRemittanceInformation =
text("unstructuredRemittanceInformation")
val transactionType = text("transactionType") /* DBIT or CRDT */
val currency = text("currency")
@@ -115,7 +114,6 @@ class RawBankTransactionEntity(id: EntityID<Long>) :
LongEntity(id) {
var counterpartBic by RawBankTransactionsTable.counterpartBic
var counterpartName by RawBankTransactionsTable.counterpartName
var bookingDate by RawBankTransactionsTable.bookingDate
- var nexusUser by NexusUserEntity referencedOn
RawBankTransactionsTable.nexusUser
var status by RawBankTransactionsTable.status
var bankAccount by BankAccountEntity referencedOn
RawBankTransactionsTable.bankAccount
}
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
index a213782..ab86308 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
@@ -104,20 +104,16 @@ fun getEbicsSubscriberDetails(userId: String,
transportId: String): EbicsClientS
// FIXME(dold): This should put stuff under *fixed* bank account, not some we
find via the IBAN.
fun processCamtMessage(
- userId: String,
+ bankAccountId: String,
camt53doc: Document
) {
transaction {
- val user = NexusUserEntity.findById(userId)
- if (user == null) {
+ val acct = BankAccountEntity.findById(bankAccountId)
+ if (acct == null) {
throw NexusError(HttpStatusCode.NotFound, "user not found")
}
RawBankTransactionEntity.new {
- bankAccount = getBankAccountFromIban(
- camt53doc.pickString(
-
"//*[local-name()='Stmt']/*[local-name()='Acct']/*[local-name()='Id']/*[local-name()='IBAN']"
- )
- )
+ bankAccount = acct
unstructuredRemittanceInformation =
camt53doc.pickString("//*[local-name()='Ntry']//*[local-name()='Ustrd']")
transactionType =
camt53doc.pickString("//*[local-name()='Ntry']//*[local-name()='CdtDbtInd']")
@@ -126,7 +122,6 @@ fun processCamtMessage(
status =
camt53doc.pickString("//*[local-name()='Ntry']//*[local-name()='Sts']")
bookingDate =
parseDashedDate(camt53doc.pickString("//*[local-name()='BookgDt']//*[local-name()='Dt']")).millis
- nexusUser = user
counterpartIban =
camt53doc.pickString("//*[local-name()='${if
(this.transactionType == "DBIT") "CdtrAcct" else
"DbtrAcct"}']//*[local-name()='IBAN']")
counterpartName =
@@ -139,7 +134,8 @@ fun processCamtMessage(
suspend fun downloadAndPersistC5xEbics(
historyType: String,
client: HttpClient,
- userId: String,
+ bankAccountId: String,
+ bankConnectionId: String,
start: String?, // dashed date YYYY-MM(01-12)-DD(01-31)
end: String?, // dashed date YYYY-MM(01-12)-DD(01-31)
subscriberDetails: EbicsClientSubscriberDetails
@@ -163,7 +159,7 @@ suspend fun downloadAndPersistC5xEbics(
response.orderData.unzipWithLambda {
logger.debug("Camt entry: ${it.second}")
val camt53doc = XMLUtil.parseStringIntoDom(it.second)
- processCamtMessage(userId, camt53doc)
+ processCamtMessage(bankAccountId, camt53doc)
}
}
is EbicsDownloadBankErrorResult -> {
@@ -400,21 +396,3 @@ fun authenticateRequest(request: ApplicationRequest):
NexusUserEntity {
}
return user
}
-
-
-fun getBankAccountFromIban(iban: String): BankAccountEntity {
- return transaction {
- BankAccountEntity.find {
- BankAccountsTable.iban eq iban
- }.firstOrNull() ?: throw NexusError(
- HttpStatusCode.NotFound,
- "Bank account with IBAN '$iban' not found"
- )
- }
-}
-
-/** Check if the nexus user is allowed to use the claimed bank account. */
-fun userHasRights(nexusUser: NexusUserEntity, iban: String): Boolean {
- // FIXME: implement permissions
- return true
-}
\ 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
index d945d90..da5894b 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -534,7 +534,8 @@ fun serverMain() {
downloadAndPersistC5xEbics(
"C53",
client,
- res.userId,
+ accountid,
+ res.connectionName,
body.start,
body.end,
res.subscriberDetails
@@ -560,8 +561,7 @@ fun serverMain() {
transaction {
val userId = transaction {
authenticateRequest(call.request).id.value }
RawBankTransactionEntity.find {
- RawBankTransactionsTable.nexusUser eq userId and
- (RawBankTransactionsTable.bankAccount eq
bankAccount) and
+ (RawBankTransactionsTable.bankAccount eq bankAccount)
and
RawBankTransactionsTable.bookingDate.between(
parseDashedDate(start ?:
"1970-01-01").millis,
parseDashedDate(end ?:
DateTime.now().toDashedDate()).millis
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: transactions belong to the bank account, not the user,
gnunet <=