moneyutils/src/main/kotlin/com/cubetiqs/libra/moneyutils/MoneyOperator.kt

12 lines
626 B
Kotlin
Raw Permalink Normal View History

2020-08-26 20:06:06 +07:00
package com.cubetiqs.libra.moneyutils
2020-08-27 10:48:31 +07:00
operator fun StdMoney.unaryMinus() = (-getMoneyValue())
operator fun StdMoney.unaryPlus() = (+getMoneyValue())
2020-08-26 20:06:06 +07:00
operator fun Money.inc() = Money(value++)
operator fun Money.dec() = Money(value--)
2020-08-27 10:48:31 +07:00
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()
}