Compare commits
No commits in common. "1a447f1954fab3bfbaf09488b56ef7dfa82f0406" and "003e1a59dbb8a032b1d40157690a91fd0b5bf887" have entirely different histories.
1a447f1954
...
003e1a59db
@ -1,8 +1,5 @@
|
|||||||
package com.cubetiqs.money
|
package com.cubetiqs.money
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
|
||||||
import java.util.concurrent.ConcurrentMap
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default money config in static object.
|
* Default money config in static object.
|
||||||
* Sample parse format: USD=1,KHR=4000,EUR=0.99
|
* Sample parse format: USD=1,KHR=4000,EUR=0.99
|
||||||
@ -17,10 +14,10 @@ object MoneyConfig {
|
|||||||
* Key is the currency
|
* Key is the currency
|
||||||
* Value is the rate
|
* Value is the rate
|
||||||
*/
|
*/
|
||||||
private val config: ConcurrentMap<String, Double> = ConcurrentHashMap()
|
private val config: MutableMap<String, Double> = mutableMapOf()
|
||||||
|
|
||||||
// use to format the money for each value, if have
|
// use to format the money for each value, if have
|
||||||
private val configFormatter: ConcurrentMap<String, MoneyFormatProvider> = ConcurrentHashMap()
|
private val configFormatter: MutableMap<String, MoneyFormatProvider> = mutableMapOf()
|
||||||
|
|
||||||
// use to identified for config dataset with prefix mode
|
// use to identified for config dataset with prefix mode
|
||||||
private var configPrefix: String = ""
|
private var configPrefix: String = ""
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.cubetiqs.money
|
package com.cubetiqs.money
|
||||||
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
infix fun StdMoney.exchangeTo(currency: StdMoney.Currency): StdMoney {
|
infix fun StdMoney.exchangeTo(currency: StdMoney.Currency): StdMoney {
|
||||||
return MoneyExchangeUtils.exchange(this, currency)
|
return MoneyExchangeUtils.exchange(this, currency)
|
||||||
}
|
}
|
||||||
@ -129,8 +127,3 @@ fun MoneyView.asStdMoney(): StdMoney {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// detect currency symbol, if needed
|
|
||||||
fun StdMoney.Currency.findCurrency(): Currency? {
|
|
||||||
return Currency.getInstance(this.getCurrency())
|
|
||||||
}
|
|
@ -4,12 +4,9 @@ open class MoneyView(
|
|||||||
private var value: Number? = null,
|
private var value: Number? = null,
|
||||||
private var currency: String? = null,
|
private var currency: String? = null,
|
||||||
) : MoneyMixin {
|
) : MoneyMixin {
|
||||||
private var _currency: StdMoney.Currency? = null
|
|
||||||
|
|
||||||
constructor(money: StdMoney) : this() {
|
constructor(money: StdMoney) : this() {
|
||||||
this._currency = money.getCurrency()
|
|
||||||
this.value = money.getValue()
|
this.value = money.getValue()
|
||||||
this.currency = this._currency?.getCurrency()
|
this.currency = money.getCurrency().getCurrency()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getValue(): Double {
|
fun getValue(): Double {
|
||||||
@ -20,10 +17,6 @@ open class MoneyView(
|
|||||||
return currency
|
return currency
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSymbol(): String? {
|
|
||||||
return this._currency?.findCurrency()?.symbol
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getFormat(): String {
|
fun getFormat(): String {
|
||||||
return MoneyConfig
|
return MoneyConfig
|
||||||
.getFormatter(getCurrency())
|
.getFormatter(getCurrency())
|
||||||
|
Loading…
Reference in New Issue
Block a user