money-module/src/main/kotlin/com/cubetiqs/money/MoneyOperator.kt

12 lines
615 B
Kotlin
Raw Normal View History

package com.cubetiqs.money
2020-08-26 20:06:06 +07:00
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()
}