From 52af60077ae2b6126faf30b88168153aabd31644 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 12 Sep 2024 03:56:34 +0200 Subject: [PATCH] Fixed Amount for wasmJs --- .../banking/client/model/Amount.wasmJs.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/BankingClientModel/src/wasmJsMain/kotlin/net/codinux/banking/client/model/Amount.wasmJs.kt b/BankingClientModel/src/wasmJsMain/kotlin/net/codinux/banking/client/model/Amount.wasmJs.kt index e26ba15f..e2298c26 100644 --- a/BankingClientModel/src/wasmJsMain/kotlin/net/codinux/banking/client/model/Amount.wasmJs.kt +++ b/BankingClientModel/src/wasmJsMain/kotlin/net/codinux/banking/client/model/Amount.wasmJs.kt @@ -3,7 +3,6 @@ package net.codinux.banking.client.model import net.codinux.banking.client.model.config.NoArgConstructor @JsModule("big.js") -@kotlin.js.JsNonModule open external class Big(value: String) { fun plus(other: Big): Big fun minus(other: Big): Big @@ -14,38 +13,41 @@ open external class Big(value: String) { @NoArgConstructor -actual class Amount actual constructor(amount: String): Big(amount) { +actual class Amount actual constructor(amount: String) { actual companion object { actual val Zero = Amount("0.00") } + internal val amount = Big(amount) + + actual operator fun plus(other: Amount): Amount { - return Amount(super.plus(other).toString()) + return Amount(amount.plus(other.amount).toString()) } actual operator fun minus(other: Amount): Amount { - return Amount(super.minus(other).toString()) + return Amount(amount.minus(other.amount).toString()) } actual operator fun times(other: Amount): Amount { - return Amount(super.times(other).toString()) + return Amount(amount.times(other.amount).toString()) } actual operator fun div(other: Amount): Amount { - return Amount(super.div(other).toString()) + return Amount(amount.div(other.amount).toString()) } override fun equals(other: Any?): Boolean { - return other is Amount && this.toString() == other.toString() + return other is Amount && amount.toString() == other.amount.toString() } override fun hashCode(): Int { return super.hashCode() } - actual override fun toString(): String = super.toString() + actual override fun toString(): String = amount.toString() } \ No newline at end of file