gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Amount format.


From: gnunet
Subject: [libeufin] branch master updated: Amount format.
Date: Sat, 23 Oct 2021 10:44:22 +0200

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

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 9f0348d  Amount format.
9f0348d is described below

commit 9f0348d373a04fe7f96db2a19d8b2c74c2da8ec8
Author: ms <ms@taler.net>
AuthorDate: Sat Oct 23 10:41:28 2021 +0200

    Amount format.
    
    Allowing wire-transfer CLI command to keep using the
    Taler format for amounts, to stay compatible with tests.
---
 .../src/main/kotlin/tech/libeufin/sandbox/Helpers.kt   | 15 +++++++++------
 sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt  | 18 +++++++++++-------
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
index 0054609..4133568 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
@@ -127,7 +127,7 @@ fun wireTransfer(
     creditAccount: String,
     demobank: String,
     subject: String,
-    amount: String
+    amount: String // $currency:x.y
 ): String {
     val args: Triple<BankAccountEntity, BankAccountEntity, 
DemobankConfigEntity> = transaction {
         val debitAccount = BankAccountEntity.find {
@@ -151,12 +151,13 @@ fun wireTransfer(
 
         Triple(debitAccount, creditAccount, demoBank)
     }
+    val amountObj = parseAmount(amount)
     return wireTransfer(
         debitAccount = args.first,
         creditAccount = args.second,
-        demoBank = args.third,
+        Demobank = args.third,
         subject = subject,
-        amount = amount
+        amount = amountObj.amount.toPlainString()
     )
 }
 /**
@@ -172,7 +173,7 @@ fun wireTransfer(
 fun wireTransfer(
     debitAccount: BankAccountEntity,
     creditAccount: BankAccountEntity,
-    demoBank: DemobankConfigEntity,
+    Demobank: DemobankConfigEntity,
     subject: String,
     amount: String,
 ): String {
@@ -189,11 +190,12 @@ fun wireTransfer(
             debtorName = getPersonNameFromCustomer(debitAccount.owner)
             this.subject = subject
             this.amount = amount
-            this.currency = demoBank.currency
+            this.currency = Demobank.currency
             date = timeStamp
             accountServicerReference = transactionRef
             account = creditAccount
             direction = "CRDT"
+            this.demobank = Demobank
         }
         BankAccountTransactionEntity.new {
             creditorIban = creditAccount.iban
@@ -204,11 +206,12 @@ fun wireTransfer(
             debtorName = getPersonNameFromCustomer(debitAccount.owner)
             this.subject = subject
             this.amount = amount
-            this.currency = demoBank.currency
+            this.currency = Demobank.currency
             date = timeStamp
             accountServicerReference = transactionRef
             account = debitAccount
             direction = "DBIT"
+            demobank = Demobank
         }
     }
     return transactionRef
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index c3fee9f..2ee4f20 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -399,7 +399,7 @@ val sandboxApp: Application.() -> Unit = {
             }
         }
     }
-    install(io.ktor.features.ContentNegotiation) {
+    install(ContentNegotiation) {
         jackson {
             
enable(com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT)
             setDefaultPrettyPrinter(DefaultPrettyPrinter().apply {
@@ -457,18 +457,18 @@ val sandboxApp: Application.() -> Unit = {
             )
             val hostAuthPriv = transaction {
                 val host = EbicsHostEntity.find {
-                    tech.libeufin.sandbox.EbicsHostsTable.hostID.upperCase() 
eq call.attributes.get(tech.libeufin.sandbox.EbicsHostIdAttribute)
+                    EbicsHostsTable.hostID.upperCase() eq 
call.attributes.get(tech.libeufin.sandbox.EbicsHostIdAttribute)
                         .uppercase()
                 }.firstOrNull() ?: throw SandboxError(
                     io.ktor.http.HttpStatusCode.InternalServerError,
                     "Requested Ebics host ID not found."
                 )
-                
tech.libeufin.util.CryptoUtil.loadRsaPrivateKey(host.authenticationPrivateKey.bytes)
+                
CryptoUtil.loadRsaPrivateKey(host.authenticationPrivateKey.bytes)
             }
             call.respondText(
-                tech.libeufin.util.XMLUtil.signEbicsResponse(resp, 
hostAuthPriv),
-                io.ktor.http.ContentType.Application.Xml,
-                io.ktor.http.HttpStatusCode.OK
+                XMLUtil.signEbicsResponse(resp, hostAuthPriv),
+                ContentType.Application.Xml,
+                HttpStatusCode.OK
             )
         }
         exception<Throwable> { cause ->
@@ -895,9 +895,11 @@ val sandboxApp: Application.() -> Unit = {
              * generic error types to EBICS-formatted responses.
              */
             catch (e: UtilError) {
+                logger.error(e)
                 throw EbicsProcessingError("Serving EBICS threw unmanaged 
UtilError: ${e.reason}")
             }
             catch (e: SandboxError) {
+                logger.error(e)
                 // Should translate to EBICS error code.
                 when (e.errorCode) {
                     LibeufinErrorCode.LIBEUFIN_EC_INVALID_STATE -> throw 
EbicsProcessingError("Invalid bank state.")
@@ -906,11 +908,13 @@ val sandboxApp: Application.() -> Unit = {
                 }
             }
             catch (e: EbicsRequestError) {
+                logger.error(e)
                 // Preventing the last catch-all block
                 // from capturing a known type.
                 throw e
             }
             catch (e: Exception) {
+                logger.error(e)
                 if (e !is EbicsRequestError) {
                     throw EbicsProcessingError("Unmanaged error: $e")
                 }
@@ -1116,7 +1120,7 @@ val sandboxApp: Application.() -> Unit = {
                                     "Cannot transfer funds without reserve 
public key."
                                 ),
                                 // provide the currency.
-                                demoBank = ensureDemobank(call)
+                                Demobank = ensureDemobank(call)
                             )
                             wo.confirmationDone = true
                         }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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