libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit b92a628982bde6582269734713183f3760e1f5e6
parent da28f823688911eb41ca004ba637f0cb8f171f1d
Author: ms <ms@taler.net>
Date:   Mon, 20 Mar 2023 18:20:25 +0100

rounding the estimate

Diffstat:
Mnexus/src/test/kotlin/SandboxCircuitApiTest.kt | 2+-
Msandbox/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 @@ -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 @@ -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") {