Skip to content

Commit

Permalink
Currency conversion floating point hotfix (#1569)
Browse files Browse the repository at this point in the history
* Currency conversion floating point hotfix

* Revert "Currency conversion floating point hotfix"

This reverts commit 2a0774d.

* Currency conversion floating point hotfix

* Currency conversion floating point hotfix
  • Loading branch information
Milan-Cerovsky authored Aug 27, 2024
1 parent a4550c2 commit 4cb0b06
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,10 @@ fun BigDecimal.convertFiatDecimalToFiatString(
monetarySeparators: MonetarySeparators,
includeSymbols: Boolean = true
): String {
val numberFormat =
if (includeSymbols) {
NumberFormat.getCurrencyInstance(locale)
} else {
NumberFormat.getInstance(locale)
}
val numberFormat = NumberFormat.getCurrencyInstance(locale)

return numberFormat.apply {
if (includeSymbols) {
currency = fiatCurrency
}

currency = fiatCurrency
roundingMode = RoundingMode.HALF_EVEN
if (this is DecimalFormat) {
decimalFormatSymbols.apply {
Expand All @@ -95,5 +87,11 @@ fun BigDecimal.convertFiatDecimalToFiatString(
}
}
}
}.format(this)
}.format(this).let {
if (includeSymbols) {
it
} else {
it.replace(fiatCurrency.symbol, "").trim()
}
}
}

0 comments on commit 4cb0b06

Please sign in to comment.