diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/Amount.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/Amount.kt index 5e240bde..cd11d4b1 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/Amount.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/Amount.kt @@ -12,6 +12,19 @@ fun Amount.toFloat() = fun Amount.toDouble() = this.toString().toDouble() +val Amount.isNegative: Boolean + get() = this.toString().startsWith("-") + +fun Collection.sum(): Amount { + var sum: Amount = Amount.Zero + + for (element in this) { + sum += element + } + + return sum +} + @NoArgConstructor expect class Amount(amount: String = "0") {