gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: rounding the estimate


From: gnunet
Subject: [libeufin] branch master updated: rounding the estimate
Date: Mon, 20 Mar 2023 18:20:42 +0100

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 b92a6289 rounding the estimate
b92a6289 is described below

commit b92a628982bde6582269734713183f3760e1f5e6
Author: ms <ms@taler.net>
AuthorDate: Mon Mar 20 18:20:25 2023 +0100

    rounding the estimate
---
 nexus/src/test/kotlin/SandboxCircuitApiTest.kt              | 2 +-
 sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/nexus/src/test/kotlin/SandboxCircuitApiTest.kt 
b/nexus/src/test/kotlin/SandboxCircuitApiTest.kt
index 4664cceb..24070081 100644
--- a/nexus/src/test/kotlin/SandboxCircuitApiTest.kt
+++ b/nexus/src/test/kotlin/SandboxCircuitApiTest.kt
@@ -50,7 +50,7 @@ class SandboxCircuitApiTest {
                 val creditAmount = respJson.get("amount_credit").asText()
                 // sell ratio and fee are the following constants: 0.95 and 0.
                 // expected credit amount = 2 * 0.95 - 0 = 1.90
-                assert("CHF:1.90" == creditAmount)
+                assert("CHF:1.90" == creditAmount || "CHF:1.9" == creditAmount)
             }
         }
     }
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt
index 4fd041ee..e9a87cad 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt
@@ -389,7 +389,9 @@ fun circuitApi(circuitRoute: Route) {
             amountDebit.amount.toBigDecimal()
         } catch (e: Exception) { throw badRequest("POSTed debit amount has 
invalid number.") }
         val estimate = applyCashoutRatioAndFee(amountDebitValue, ratiosAndFees)
-        call.respond(object { val amount_credit = "$FIAT_CURRENCY:$estimate" })
+        val twoDigitsRounding = MathContext(2)
+        val estimateRounded = estimate.round(twoDigitsRounding)
+        call.respond(object { val amount_credit = 
"$FIAT_CURRENCY:$estimateRounded" })
     }
     // Create a cash-out operation.
     circuitRoute.post("/cashouts") {

-- 
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]