[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: make BIC optional, fix typo
From: |
gnunet |
Subject: |
[libeufin] branch master updated: make BIC optional, fix typo |
Date: |
Sun, 17 Jan 2021 00:22:24 +0100 |
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 bde5eee make BIC optional, fix typo
bde5eee is described below
commit bde5eeee12ece275e824d2959f2591144c3d9da5
Author: Florian Dold <florian@dold.me>
AuthorDate: Sun Jan 17 00:22:20 2021 +0100
make BIC optional, fix typo
---
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 2 +-
nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt | 8 -----
.../tech/libeufin/nexus/iso20022/Iso20022.kt | 9 +++--
.../main/kotlin/tech/libeufin/nexus/server/JSON.kt | 2 +-
.../src/main/kotlin/tech/libeufin/sandbox/DB.kt | 8 ++---
.../tech/libeufin/sandbox/EbicsProtocolBackend.kt | 27 +++++---------
.../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 42 +++++++++++-----------
.../kotlin/tech/libeufin/sandbox/bankAccount.kt | 8 ++---
sandbox/src/test/kotlin/DBTest.kt | 6 ++--
util/src/main/kotlin/JSON.kt | 6 ++--
util/src/main/kotlin/Payto.kt | 13 ++++---
11 files changed, 61 insertions(+), 70 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index fa3dc83..8871412 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -177,7 +177,7 @@ object PaymentInitiationsTable : LongIdTable() {
val instructionId = text("instructionId")
val subject = text("subject")
val creditorIban = text("creditorIban")
- val creditorBic = text("creditorBic")
+ val creditorBic = text("creditorBic").nullable()
val creditorName = text("creditorName")
val submitted = bool("submitted").default(false)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
index ef2c4b9..cd9f4ba 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
@@ -117,14 +117,6 @@ data class TalerAddIncomingResponse(
val row_id: Long
)
-/**
- * Helper data structures.
- */
-data class Payto(
- val name: String = "NOTGIVEN",
- val iban: String,
- val bic: String = "NOTGIVEN"
-)
/** Sort query results in descending order for negative deltas, and ascending
otherwise. */
fun <T : Entity<Long>> SizedIterable<T>.orderTaler(delta: Int): List<T> {
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt
index 6e9e977..8b0ce13 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt
@@ -346,7 +346,7 @@ data class NexusPaymentInitiationData(
val preparationTimestamp: Long,
val creditorName: String,
val creditorIban: String,
- val creditorBic: String,
+ val creditorBic: String?,
val instructionId: String?
)
@@ -446,8 +446,11 @@ fun createPain001document(paymentData:
NexusPaymentInitiationData): String {
attribute("Ccy", paymentData.currency)
text(paymentData.amount)
}
- element("CdtrAgt/FinInstnId/BIC") {
- text(paymentData.creditorBic)
+ val creditorBic = paymentData.creditorBic
+ if (creditorBic != null) {
+ element("CdtrAgt/FinInstnId/BIC") {
+ text(creditorBic)
+ }
}
element("Cdtr/Nm") {
text(paymentData.creditorName)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
index c87f26a..fa827f8 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
@@ -345,7 +345,7 @@ data class TalerWireGatewayFacadeConfig(
data class Pain001Data(
val creditorIban: String,
- val creditorBic: String,
+ val creditorBic: String?,
val creditorName: String,
val sum: Amount,
val currency: String,
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index 9ea9a0e..034fcf0 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -248,11 +248,11 @@ class EbicsUploadTransactionChunkEntity(id:
EntityID<String>) : Entity<String>(i
*/
object BankAccountTransactionsTable : Table() {
val creditorIban = text("creditorIban")
- val creditorBic = text("creditorBic")
+ val creditorBic = text("creditorBic").nullable()
val creditorName = text("creditorName")
- val debitorIban = text("debitorIban")
- val debitorBic = text("debitorBic")
- val debitorName = text("debitorName")
+ val debtorIban = text("debtorIban")
+ val debtorBic = text("debtorBic").nullable()
+ val debtorName = text("debtorName")
val subject = text("subject")
val amount = text("amount")
val currency = text("currency")
diff --git
a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
index 8c506e7..2840fbb 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -35,18 +35,6 @@ import org.jetbrains.exposed.sql.transactions.transaction
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.w3c.dom.Document
-import tech.libeufin.sandbox.BankAccountTransactionsTable.amount
-import tech.libeufin.sandbox.BankAccountTransactionsTable.creditorBic
-import tech.libeufin.sandbox.BankAccountTransactionsTable.creditorIban
-import tech.libeufin.sandbox.BankAccountTransactionsTable.creditorName
-import tech.libeufin.sandbox.BankAccountTransactionsTable.currency
-import tech.libeufin.sandbox.BankAccountTransactionsTable.date
-import tech.libeufin.sandbox.BankAccountTransactionsTable.debitorBic
-import tech.libeufin.sandbox.BankAccountTransactionsTable.debitorIban
-import tech.libeufin.sandbox.BankAccountTransactionsTable.debitorName
-import tech.libeufin.sandbox.BankAccountTransactionsTable.direction
-import tech.libeufin.sandbox.BankAccountTransactionsTable.pmtInfId
-import tech.libeufin.sandbox.BankAccountTransactionsTable.subject
import tech.libeufin.util.*
import tech.libeufin.util.XMLUtil.Companion.signEbicsResponse
import tech.libeufin.util.ebics_h004.*
@@ -197,9 +185,12 @@ private fun getRelatedParty(branch: XmlElementBuilder,
payment: RawPayment) {
text(otherParty.iban)
}
}
- branch.element("RltdAgts") {
- element(otherParty.bicPath) {
- text(otherParty.bic)
+ val otherPartyBic = otherParty.bic
+ if (otherPartyBic != null) {
+ branch.element("RltdAgts") {
+ element(otherParty.bicPath) {
+ text(otherPartyBic)
+ }
}
}
}
@@ -563,9 +554,9 @@ private fun handleCct(paymentRequest: String,
initiatorName: String, ctx: Reques
it[creditorIban] = parseResult.creditorIban
it[creditorName] = parseResult.creditorName
it[creditorBic] = parseResult.creditorBic
- it[debitorIban] = parseResult.debitorIban
- it[debitorName] = parseResult.debitorName
- it[debitorBic] = parseResult.debitorBic
+ it[debtorIban] = parseResult.debitorIban
+ it[debtorName] = parseResult.debitorName
+ it[debtorBic] = parseResult.debitorBic
it[subject] = parseResult.subject
it[amount] = parseResult.amount.toString()
it[currency] = parseResult.currency
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index aac354c..3b61b46 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -70,9 +70,9 @@ import
tech.libeufin.sandbox.BankAccountTransactionsTable.creditorIban
import tech.libeufin.sandbox.BankAccountTransactionsTable.creditorName
import tech.libeufin.sandbox.BankAccountTransactionsTable.currency
import tech.libeufin.sandbox.BankAccountTransactionsTable.date
-import tech.libeufin.sandbox.BankAccountTransactionsTable.debitorBic
-import tech.libeufin.sandbox.BankAccountTransactionsTable.debitorIban
-import tech.libeufin.sandbox.BankAccountTransactionsTable.debitorName
+import tech.libeufin.sandbox.BankAccountTransactionsTable.debtorBic
+import tech.libeufin.sandbox.BankAccountTransactionsTable.debtorIban
+import tech.libeufin.sandbox.BankAccountTransactionsTable.debtorName
import tech.libeufin.sandbox.BankAccountTransactionsTable.direction
import tech.libeufin.util.*
import tech.libeufin.util.ebics_h004.EbicsResponse
@@ -305,14 +305,14 @@ fun serverMain(dbName: String, port: Int) {
ret.payments.add(
RawPayment(
creditorIban = it[creditorIban],
- debitorIban = it[debitorIban],
+ debitorIban = it[debtorIban],
subject =
it[BankAccountTransactionsTable.subject],
date = it[date].toHttpDateString(),
amount = it[amount],
creditorBic = it[creditorBic],
creditorName = it[creditorName],
- debitorBic = it[debitorBic],
- debitorName = it[debitorName],
+ debitorBic = it[debtorBic],
+ debitorName = it[debtorName],
currency = it[currency],
direction = it[direction]
)
@@ -339,9 +339,9 @@ fun serverMain(dbName: String, port: Int) {
it[creditorIban] = body.creditorIban
it[creditorBic] = body.creditorBic
it[creditorName] = body.creditorName
- it[debitorIban] = body.debitorIban
- it[debitorBic] = body.debitorBic
- it[debitorName] = body.debitorName
+ it[debtorIban] = body.debitorIban
+ it[debtorBic] = body.debitorBic
+ it[debtorName] = body.debitorName
it[subject] = body.subject
it[amount] = body.amount
it[currency] = body.currency
@@ -367,9 +367,9 @@ fun serverMain(dbName: String, port: Int) {
it[creditorIban] = account.iban
it[creditorBic] = account.bic
it[creditorName] = account.name
- it[debitorIban] = body.debtorIban
- it[debitorBic] = body.debtorBic
- it[debitorName] = body.debtorName
+ it[debtorIban] = body.debtorIban
+ it[debtorBic] = body.debtorBic
+ it[debtorName] = body.debtorName
it[subject] = body.subject
it[amount] = body.amount
it[currency] = account.currency
@@ -435,14 +435,14 @@ fun serverMain(dbName: String, port: Int) {
ret.payments.add(
RawPayment(
creditorIban = it[creditorIban],
- debitorIban = it[debitorIban],
+ debitorIban = it[debtorIban],
subject =
it[BankAccountTransactionsTable.subject],
date = it[date].toHttpDateString(),
amount = it[amount],
creditorBic = it[creditorBic],
creditorName = it[creditorName],
- debitorBic = it[debitorBic],
- debitorName = it[debitorName],
+ debitorBic = it[debtorBic],
+ debitorName = it[debtorName],
currency = it[currency],
direction = it[direction]
)
@@ -469,9 +469,9 @@ fun serverMain(dbName: String, port: Int) {
it[creditorIban] = account.iban
it[creditorBic] = account.bic
it[creditorName] = account.name
- it[debitorIban] = "DE64500105178797276788"
- it[debitorBic] = "DEUTDEBB101"
- it[debitorName] = "Max Mustermann"
+ it[debtorIban] = "DE64500105178797276788"
+ it[debtorBic] = "DEUTDEBB101"
+ it[debtorName] = "Max Mustermann"
it[subject] = "sample transaction $random"
it[BankAccountTransactionsTable.amount] =
amount.toString()
it[currency] = account.currency
@@ -488,9 +488,9 @@ fun serverMain(dbName: String, port: Int) {
val amount = Random.nextLong(5, 25)
BankAccountTransactionsTable.insert {
- it[debitorIban] = account.iban
- it[debitorBic] = account.bic
- it[debitorName] = account.name
+ it[debtorIban] = account.iban
+ it[debtorBic] = account.bic
+ it[debtorName] = account.name
it[creditorIban] = "DE64500105178797276788"
it[creditorBic] = "DEUTDEBB101"
it[creditorName] = "Max Mustermann"
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt
index 377f4f1..46780f0 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt
@@ -17,7 +17,7 @@ fun historyForAccount(iban: String): List<RawPayment> {
logger.debug("Querying transactions involving: ${iban}")
BankAccountTransactionsTable.select {
BankAccountTransactionsTable.creditorIban eq iban or
- (BankAccountTransactionsTable.debitorIban eq iban)
+ (BankAccountTransactionsTable.debtorIban eq iban)
/**
FIXME: add the following condition too:
and (BankAccountTransactionsTable.date.between(start.millis,
end.millis))
@@ -34,9 +34,9 @@ fun historyForAccount(iban: String): List<RawPayment> {
creditorIban =
it[BankAccountTransactionsTable.creditorIban],
creditorBic = it[BankAccountTransactionsTable.creditorBic],
creditorName =
it[BankAccountTransactionsTable.creditorName],
- debitorIban = it[BankAccountTransactionsTable.debitorIban],
- debitorBic = it[BankAccountTransactionsTable.debitorBic],
- debitorName = it[BankAccountTransactionsTable.debitorName],
+ debitorIban = it[BankAccountTransactionsTable.debtorIban],
+ debitorBic = it[BankAccountTransactionsTable.debtorBic],
+ debitorName = it[BankAccountTransactionsTable.debtorName],
date =
importDateFromMillis(it[BankAccountTransactionsTable.date]).toDashedDate(),
amount = it[BankAccountTransactionsTable.amount],
currency = it[BankAccountTransactionsTable.currency],
diff --git a/sandbox/src/test/kotlin/DBTest.kt
b/sandbox/src/test/kotlin/DBTest.kt
index aecccfa..ea75f1b 100644
--- a/sandbox/src/test/kotlin/DBTest.kt
+++ b/sandbox/src/test/kotlin/DBTest.kt
@@ -70,9 +70,9 @@ class DBTest {
it[creditorIban] = "earns"
it[creditorBic] = "BIC"
it[creditorName] = "Creditor Name"
- it[debitorIban] = "spends"
- it[debitorBic] = "BIC"
- it[debitorName] = "Debitor Name"
+ it[debtorIban] = "spends"
+ it[debtorBic] = "BIC"
+ it[debtorName] = "Debitor Name"
it[subject] = "deal"
it[amount] = "EUR:1"
it[date] = LocalDateTime.now().millis()
diff --git a/util/src/main/kotlin/JSON.kt b/util/src/main/kotlin/JSON.kt
index d83546e..4883056 100644
--- a/util/src/main/kotlin/JSON.kt
+++ b/util/src/main/kotlin/JSON.kt
@@ -26,10 +26,10 @@ package tech.libeufin.util
*/
data class RawPayment(
val creditorIban: String,
- val creditorBic: String,
+ val creditorBic: String?,
val creditorName: String,
val debitorIban: String,
- val debitorBic: String,
+ val debitorBic: String?,
val debitorName: String,
val amount: String,
val currency: String,
@@ -47,7 +47,7 @@ data class RawPayment(
data class IncomingPaymentInfo(
val debtorIban: String,
- val debtorBic: String,
+ val debtorBic: String?,
val debtorName: String,
val amount: String,
val currency: String,
diff --git a/util/src/main/kotlin/Payto.kt b/util/src/main/kotlin/Payto.kt
index a35aa71..04fda1a 100644
--- a/util/src/main/kotlin/Payto.kt
+++ b/util/src/main/kotlin/Payto.kt
@@ -8,7 +8,7 @@ import java.net.URI
data class Payto(
val name: String,
val iban: String,
- val bic: String
+ val bic: String?
)
class InvalidPaytoError(msg: String) : Exception(msg)
@@ -32,7 +32,12 @@ fun parsePayto(paytoLine: String): Payto {
throw InvalidPaytoError("'${paytoLine}' has unsupported query string")
}
val receiverName = splitParameter.last()
- val split_path = javaParsedUri.path.split("/").filter { it.isNotEmpty() }
- if (split_path.size != 2) throw InvalidPaytoError("BIC and IBAN are both
mandatory ($split_path)")
- return Payto(iban = split_path[1], bic = split_path[0], name =
receiverName)
+ val splitPath = javaParsedUri.path.split("/").filter { it.isNotEmpty() }
+ if (splitPath.size > 2) {
+ throw InvalidPaytoError("too many path segments in iban payto URI")
+ }
+ if (splitPath.size < 2) {
+ return Payto(iban = splitPath[0], name = receiverName, bic = null)
+ }
+ return Payto(iban = splitPath[1], bic = splitPath[0], name = receiverName)
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: make BIC optional, fix typo,
gnunet <=