money-module/src/main/kotlin/com/cubetiqs/money/MoneyOperator.kt
Sambo Chea 31760ee901 Add and updated for whole the money modules with new style and some operators and computation
But money object not full implementation yet, because we need the exchange and filter the object states for money
2021-02-08 12:39:52 +07:00

17 lines
769 B
Kotlin

package com.cubetiqs.money
// unary operators
operator fun StdMoney.unaryMinus() = (-getMoneyValue())
operator fun StdMoney.unaryPlus() = (+getMoneyValue())
// operators
operator fun StdMoney.inc() = Money.from(this).inc()
operator fun StdMoney.dec() = Money.from(this).dec()
operator fun StdMoney.plus(other: StdMoney) = Money.from(this).plusAssign(other)
operator fun StdMoney.times(other: StdMoney) = Money.from(this).multiplyAssign(other)
operator fun StdMoney.div(other: StdMoney) = Money.from(this).divideAssign(other)
// assign operators
operator fun Money.timesAssign(other: StdMoney) = this.multiplyAssign(other)
operator fun Money.plusAssign(other: StdMoney) = this.plusAssign(other)
operator fun Money.divAssign(other: StdMoney) = this.divideAssign(other)