2021-02-08 11:24:14 +07:00
|
|
|
package com.cubetiqs.money
|
2020-08-26 20:06:06 +07:00
|
|
|
|
2021-02-08 12:39:52 +07:00
|
|
|
// unary operators
|
2021-02-08 21:34:17 +07:00
|
|
|
operator fun StdMoney.unaryMinus() = (-getValue())
|
|
|
|
operator fun StdMoney.unaryPlus() = (+getValue())
|
2021-02-08 12:39:52 +07:00
|
|
|
|
|
|
|
// operators
|
|
|
|
operator fun StdMoney.inc() = Money.from(this).inc()
|
|
|
|
operator fun StdMoney.dec() = Money.from(this).dec()
|
2021-02-08 16:08:00 +07:00
|
|
|
operator fun StdMoney.plus(other: StdMoney): StdMoney {
|
|
|
|
val result = Money.from(this)
|
|
|
|
result.plusAssign(other)
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
operator fun StdMoney.minus(other: StdMoney): StdMoney {
|
|
|
|
val result = Money.from(this)
|
|
|
|
result.minusAssign(other)
|
|
|
|
return result
|
|
|
|
}
|
2021-02-08 12:39:52 +07:00
|
|
|
operator fun StdMoney.times(other: StdMoney) = Money.from(this).multiplyAssign(other)
|
|
|
|
operator fun StdMoney.div(other: StdMoney) = Money.from(this).divideAssign(other)
|
|
|
|
|
|
|
|
// assign operators
|
2021-02-08 16:08:00 +07:00
|
|
|
operator fun Money.timesAssign(other: StdMoney) = this.multiplyAssign(other).nor()
|
|
|
|
operator fun Money.plusAssign(other: StdMoney) = this.plusAssign(other).nor()
|
|
|
|
operator fun Money.minusAssign(other: StdMoney) = this.minusAssign(other).nor()
|
|
|
|
operator fun Money.divAssign(other: StdMoney) = this.divideAssign(other).nor()
|