Fixed Amount for wasmJs
This commit is contained in:
parent
bf211e238f
commit
52af60077a
|
@ -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()
|
||||
|
||||
}
|
Loading…
Reference in New Issue