-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unfortunately, it not much better and even FastMoney is still a SlowMoney
- Loading branch information
Showing
55 changed files
with
941 additions
and
1,177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ jte-classes/ | |
.kotlin/sessions | ||
.env | ||
export-data/ | ||
.resourceCache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.20.0-display-currency1 | ||
0.20.0-display-currency3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
marketplace-client/src/main/kotlin/dev/ja/marketplace/client/moneyUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2024 Joachim Ansorg. | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
package dev.ja.marketplace.client | ||
|
||
import org.javamoney.moneta.FastMoney | ||
import java.math.BigDecimal | ||
import java.math.RoundingMode | ||
import javax.money.MonetaryAmount | ||
|
||
operator fun MonetaryAmount.plus(other: MonetaryAmount): MonetaryAmount { | ||
return this.add(other) | ||
} | ||
|
||
operator fun MonetaryAmount.minus(other: MonetaryAmount): MonetaryAmount { | ||
return this.subtract(other) | ||
} | ||
|
||
operator fun MonetaryAmount.times(other: Number): MonetaryAmount { | ||
require(this is FastMoney) | ||
val result = (other as? BigDecimal ?: BigDecimal(other.toString())) | ||
.multiply(this.number.numberValue(BigDecimal::class.java)) | ||
.setScale(this.scale, RoundingMode.HALF_UP) | ||
return FastMoney.of(result, this.currency) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.