gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] 05/05: POST ../collected-transactions


From: gnunet
Subject: [libeufin] 05/05: POST ../collected-transactions
Date: Sun, 10 May 2020 01:15:21 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

commit 7033a39afafcfa430e5a9bea57ac022f13905e97
Author: Marcello Stanisci <address@hidden>
AuthorDate: Sun May 10 01:14:59 2020 +0200

    POST ../collected-transactions
---
 nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt   |  2 ++
 nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt |  2 +-
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 30 ++++++++---------------
 3 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 8d47c84..957e3ca 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -94,6 +94,7 @@ object RawBankTransactionsTable : LongIdTable() {
     val counterpartName = text("counterpartName")
     val bookingDate = long("bookingDate")
     val status = text("status") // BOOK or other.
+    val bankAccount = reference("bankAccount", BankAccountsTable)
 }
 
 class RawBankTransactionEntity(id: EntityID<Long>) : LongEntity(id) {
@@ -109,6 +110,7 @@ class RawBankTransactionEntity(id: EntityID<Long>) : 
LongEntity(id) {
     var bookingDate by RawBankTransactionsTable.bookingDate
     var nexusUser by NexusUserEntity referencedOn 
RawBankTransactionsTable.nexusUser
     var status by RawBankTransactionsTable.status
+    var bankAccount by BankAccountEntity referencedOn 
RawBankTransactionsTable.bankAccount
 }
 /**
  * Represent a prepare payment.
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
index b0613b4..ded37a1 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt
@@ -120,7 +120,7 @@ data class Transaction(
 )
 
 data class Transactions(
-    val transactions: MutableList<Transaction>
+    val transactions: MutableList<Transaction> = mutableListOf()
 )
 
 /** Request type of "POST /prepared-payments/submit" */
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 1a33c5f..4a6daf7 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -309,6 +309,7 @@ fun main() {
                                     val camt53doc = 
XMLUtil.parseStringIntoDom(it.second)
                                     transaction {
                                         RawBankTransactionEntity.new {
+                                            bankAccount = 
getBankAccountFromIban(camt53doc.pickString("//*[local-name()='Stmt']/Acct/Id/IBAN"))
                                             sourceFileName = fileName
                                             unstructuredRemittanceInformation 
= camt53doc.pickString("//*[local-name()='Ntry']//*[local-name()='Ustrd']")
                                             transactionType = 
camt53doc.pickString("//*[local-name()='Ntry']//*[local-name()='CdtDbtInd']")
@@ -317,24 +318,8 @@ fun main() {
                                             status = 
camt53doc.pickString("//*[local-name()='Ntry']//*[local-name()='Sts']")
                                             bookingDate = 
parseDashedDate(camt53doc.pickString("//*[local-name()='BookgDt']//*[local-name()='Dt']")).millis
                                             nexusUser = 
extractNexusUser(userId)
-                                            counterpartIban = 
camt53doc.pickString(
-                                                if (this.transactionType == 
"DBIT") {
-                                                    // counterpart is credit
-                                                    
"//*[local-name()='CdtrAcct']//*[local-name()='IBAN']"
-                                                } else {
-                                                    // counterpart is debit
-                                                    
"//*[local-name()='DbtrAcct']//*[local-name()='IBAN']"
-                                                }
-                                            )
-                                            counterpartName = 
camt53doc.pickString(
-                                                
"//*[local-name()='RltdPties']//*[local-name()='${
-                                                if (this.transactionType == 
"DBIT") {
-                                                    "Cdtr"
-                                                } else {
-                                                    "Dbtr"
-                                                }
-                                                }']//*[local-name()='Nm']"
-                                            )
+                                            counterpartIban = 
camt53doc.pickString("//*[local-name()='${if (this.transactionType == "DBIT") 
"CdtrAcct" else "DbtrAcct"}']//*[local-name()='IBAN']")
+                                            counterpartName = 
camt53doc.pickString("//*[local-name()='RltdPties']//*[local-name()='${if 
(this.transactionType == "DBIT") "Cdtr" else "Dbtr"}']//*[local-name()='Nm']")
                                             counterpartBic = 
camt53doc.pickString("//*[local-name()='RltdAgts']//*[local-name()='BIC']")
                                         }
                                     }
@@ -383,10 +368,15 @@ fun main() {
                     }.forEach {
                         ret.transactions.add(
                             Transaction(
-                                account = it.
+                                account = it.bankAccount.id.value,
+                                counterpartBic = it.counterpartBic,
+                                counterpartIban = it.counterpartIban,
+                                counterpartName = it.counterpartName,
+                                date = DateTime(it.bookingDate).toDashedDate(),
+                                subject = it.unstructuredRemittanceInformation,
+                                amount = "${it.currency}:${it.amount}"
                             )
                         )
-
                     }
                 }
                 return@get

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



reply via email to

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