Add money extension and operator
This commit is contained in:
parent
377809383d
commit
4dc6ae521c
@ -0,0 +1,3 @@
|
||||
package com.cubetiqs.libra.moneyutils
|
||||
|
||||
fun StdMoney
|
@ -1,13 +1,12 @@
|
||||
package com.cubetiqs.libra.moneyutils
|
||||
|
||||
operator fun Money.unaryMinus() = (-getMoneyValue())
|
||||
operator fun Money.unaryPlus() = (+getMoneyValue())
|
||||
operator fun StdMoney.unaryMinus() = (-getMoneyValue())
|
||||
operator fun StdMoney.unaryPlus() = (+getMoneyValue())
|
||||
operator fun Money.inc() = Money(value++)
|
||||
operator fun Money.dec() = Money(value--)
|
||||
operator fun Money.plus(other: Money) = Money(value + other.value)
|
||||
operator fun Money.times(other: Money) = Money(value * other.value)
|
||||
operator fun Money.div(other: Money) = Money(value / other.value)
|
||||
operator fun Money.timesAssign(other: Money) {
|
||||
this.value = this.value * other.value
|
||||
}
|
||||
operator fun Money.not() = this.value != this.value
|
||||
operator fun StdMoney.plus(other: StdMoney) = Money(getMoneyValue() + other.getMoneyValue())
|
||||
operator fun StdMoney.times(other: StdMoney) = Money(getMoneyValue() * other.getMoneyValue())
|
||||
operator fun StdMoney.div(other: StdMoney) = Money(getMoneyValue() / other.getMoneyValue())
|
||||
operator fun Money.timesAssign(other: StdMoney) {
|
||||
this.value = this.getMoneyValue() * other.getMoneyValue()
|
||||
}
|
Loading…
Reference in New Issue
Block a user