money-module/src/main/kotlin/com/cubetiqs/money/MoneyView.kt
Sambo Chea 8509c578ca Add money config for locale and currency from system and set default and configuratoion auto with apply default locale and currency
But for auto translate from currency to view not have yet
We need to create a new file or use exist model to generate the locale format with custom currency from system or use defined
2021-02-09 13:54:59 +07:00

33 lines
792 B
Kotlin

package com.cubetiqs.money
open class MoneyView(
private var value: Number? = null,
private var currency: String? = null,
) : MoneyMixin {
private var _currency: StdMoney.Currency? = null
constructor(money: StdMoney) : this() {
this._currency = money.getCurrency()
this.value = money.getValue()
this.currency = this._currency?.getCurrency()
}
fun getValue(): Double {
return (value?.toDouble() ?: 0.0)
}
fun getCurrency(): String? {
return currency
}
fun getSymbol(): String? {
return this._currency?.findCurrency()?.symbol
}
fun getFormat(): String {
return MoneyConfig
.getFormatter(getCurrency())
.setValue(this.asStdMoney())
.format()
}
}