[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated (b5d69ec -> 159225a)
From: |
gnunet |
Subject: |
[libeufin] branch master updated (b5d69ec -> 159225a) |
Date: |
Fri, 15 Jan 2021 10:59:55 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a change to branch master
in repository libeufin.
from b5d69ec 'make env' gone.
new 577a417 prefer installed cli
new c1abb57 (Redundantly) asking direction for mock payments.
new 3d688bb place fixme
new 159225a Counting transactions.
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
cli/bin/libeufin-cli | 7 ++++++
cli/setup-template.sh | 14 ++++++------
.../tech/libeufin/nexus/bankaccount/BankAccount.kt | 25 +++++++++++-----------
.../tech/libeufin/nexus/server/NexusServer.kt | 4 ++--
util/src/main/kotlin/JSON.kt | 5 +++--
5 files changed, 32 insertions(+), 23 deletions(-)
diff --git a/cli/bin/libeufin-cli b/cli/bin/libeufin-cli
index 0e45332..7cc0b42 100755
--- a/cli/bin/libeufin-cli
+++ b/cli/bin/libeufin-cli
@@ -808,6 +808,11 @@ def bankaccount_generate_transactions(obj, account_label):
@click.option("--amount", help="amount, no currency", prompt=True)
@click.option("--currency", help="currency", prompt=True)
@click.option("--subject", help="payment subject", prompt=True)
+@click.option(
+ "--direction",
+ help="direction respect to the bank account hosted at Sandbox: allows
DBIT/CRDT values.",
+ prompt=True
+)
@click.pass_obj
def book_payment(
obj,
@@ -820,6 +825,7 @@ def book_payment(
amount,
currency,
subject,
+ direction,
):
sandbox_base_url = obj.require_sandbox_base_url()
url = urljoin(sandbox_base_url, "/admin/payments")
@@ -833,6 +839,7 @@ def book_payment(
amount=amount,
currency=currency,
subject=subject,
+ direction=direction
)
try:
resp = post(url, json=body)
diff --git a/cli/setup-template.sh b/cli/setup-template.sh
index 13b75ec..05b42a5 100755
--- a/cli/setup-template.sh
+++ b/cli/setup-template.sh
@@ -54,14 +54,14 @@ curl -s --retry 5 --retry-connrefused $NEXUS_URL > /dev/null
# make ebics host at sandbox
echo Making a ebics host at the sandbox
-./bin/libeufin-cli \
+libeufin-cli \
sandbox --sandbox-url=$SANDBOX_URL \
ebicshost create \
--host-id=$EBICS_HOST_ID
# activate a ebics subscriber on that host
echo Activating the ebics subscriber at the sandbox
-./bin/libeufin-cli \
+libeufin-cli \
sandbox --sandbox-url=$SANDBOX_URL \
ebicssubscriber create \
--host-id=$EBICS_HOST_ID \
@@ -70,7 +70,7 @@ echo Activating the ebics subscriber at the sandbox
# give a bank account to such user
echo Giving a bank account to such subscriber
-./bin/libeufin-cli \
+libeufin-cli \
sandbox --sandbox-url=$SANDBOX_URL \
ebicsbankaccount create \
--iban=$IBAN \
@@ -93,7 +93,7 @@ libeufin-nexus \
# create a bank connection
echo Creating a bank connection for such user
-./bin/libeufin-cli \
+libeufin-cli \
connections \
new-ebics-connection \
--ebics-url $EBICS_BASE_URL \
@@ -104,17 +104,17 @@ echo Creating a bank connection for such user
# Bootstrapping such connection.
echo Bootstrapping the bank connection
-./bin/libeufin-cli \
+libeufin-cli \
connections sync $NEXUS_BANK_CONNECTION_NAME
# Download bank accounts.
echo Download bank accounts
-./bin/libeufin-cli \
+libeufin-cli \
connections download-bank-accounts \
$NEXUS_BANK_CONNECTION_NAME
# Import bank account for user.
-./bin/libeufin-cli \
+libeufin-cli \
connections import-bank-account \
--offered-account-id=$ACCOUNT_NAME \
--nexus-bank-account-id=$ACCOUNT_NAME_AT_NEXUS \
diff --git
a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
index 019a091..c3dc485 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
@@ -119,16 +119,18 @@ private fun findDuplicate(bankAccountId: String,
acctSvcrRef: String): NexusBank
}
}
-fun processCamtMessage(bankAccountId: String, camtDoc: Document, code:
String): Boolean {
+fun processCamtMessage(bankAccountId: String, camtDoc: Document, code:
String): Int {
logger.info("processing CAMT message")
- val success = transaction {
+ var newTransactions = 0
+ transaction {
val acct = NexusBankAccountEntity.findById(bankAccountId)
if (acct == null) {
throw NexusError(HttpStatusCode.NotFound, "user not found")
}
val res = try { parseCamtMessage(camtDoc) } catch (e:
CamtParsingError) {
logger.warn("Invalid CAMT received from bank: $e")
- return@transaction false
+ newTransactions = -1
+ return@transaction
}
val stamp = ZonedDateTime.parse(res.creationDateTime,
DateTimeFormatter.ISO_DATE_TIME).toInstant().toEpochMilli()
when (code) {
@@ -176,6 +178,8 @@ fun processCamtMessage(bankAccountId: String, camtDoc:
Document, code: String):
status = entry.status
}
rawEntity.flush()
+ newTransactions++
+ // This block tries to acknowledge a former outgoing payment as
booked.
if (singletonBatchedTransaction.creditDebitIndicator ==
CreditDebitIndicator.DBIT) {
val t0 = singletonBatchedTransaction.details
val msgId = t0.messageId
@@ -192,13 +196,10 @@ fun processCamtMessage(bankAccountId: String, camtDoc:
Document, code: String):
paymentInitiation.confirmationTransaction = rawEntity
}
}
- // FIXME: find matching PaymentInitiation
- // by PaymentInformationID, message ID or whatever is present
}
}
- return@transaction true
}
- return success
+ return newTransactions
}
/**
@@ -221,14 +222,14 @@ fun ingestBankMessagesIntoAccount(bankConnectionId:
String, bankAccountId: Strin
(NexusBankMessagesTable.bankConnection eq conn.id) and
(NexusBankMessagesTable.id greater
acct.highestSeenBankMessageId)
}.orderBy(Pair(NexusBankMessagesTable.id, SortOrder.ASC)).forEach {
- logger.debug("Unseen Camt, account: ${bankAccountId}, connection:
${conn.id}, msgId: ${it.messageId}")
- totalNew++
val doc =
XMLUtil.parseStringIntoDom(it.message.bytes.toString(Charsets.UTF_8))
- if (!processCamtMessage(bankAccountId, doc, it.code)) {
+ val newTransactions = processCamtMessage(bankAccountId, doc,
it.code)
+ if (newTransactions == -1) {
it.errors = true
return@forEach
}
lastId = it.id.value
+ totalNew += newTransactions
}
acct.highestSeenBankMessageId = lastId
}
@@ -313,9 +314,9 @@ suspend fun fetchBankAccountTransactions(client:
HttpClient, fetchSpec: FetchSpe
"Connection type '${res.connectionType}' not implemented"
)
}
- val newMessages = ingestBankMessagesIntoAccount(res.connectionName,
accountId)
+ val newTransactions = ingestBankMessagesIntoAccount(res.connectionName,
accountId)
ingestTalerTransactions()
- return newMessages
+ return newTransactions
}
fun importBankAccount(call: ApplicationCall, offeredBankAccountId: String,
nexusBankAccountId: String) {
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index e1ff46b..878f7e8 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -671,8 +671,8 @@ fun serverMain(dbName: String, host: String, port: Int) {
null
)
}
- val newMessages = fetchBankAccountTransactions(client,
fetchSpec, accountid)
- call.respond(object {val newMessages = newMessages})
+ val newTransactions = fetchBankAccountTransactions(client,
fetchSpec, accountid)
+ call.respond(object {val newTransactions = newTransactions})
return@post
}
diff --git a/util/src/main/kotlin/JSON.kt b/util/src/main/kotlin/JSON.kt
index 26b8f53..a2f6c54 100644
--- a/util/src/main/kotlin/JSON.kt
+++ b/util/src/main/kotlin/JSON.kt
@@ -36,8 +36,9 @@ data class RawPayment(
val subject: String,
val date: String? = null,
val uid: String? = null, // FIXME: explain this value.
- val direction: String,
- // the following two values are rather CAMT/PAIN
+ val direction: String, // FIXME: this following value should be restricted
to only DBIT/CRDT.
+
+ // The following two values are rather CAMT/PAIN
// specific, therefore do not need to be returned
// along every API call using this object.
val pmtInfId: String? = null,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libeufin] branch master updated (b5d69ec -> 159225a),
gnunet <=