Updated on 2026-08-14
This commit is contained in:
commit
44848e7ca8
1 changed files with 10 additions and 2 deletions
|
|
@ -23,9 +23,17 @@ fun BigDecimal.toFormattedString(
|
|||
}
|
||||
|
||||
fun BigDecimal.toFormattedCurrencyString(
|
||||
decimals: Int, currency: String, roundingMode: RoundingMode = RoundingMode.DOWN
|
||||
decimals: Int, currency: String, roundingMode: RoundingMode = RoundingMode.DOWN,
|
||||
limitNumberOfDecimals: Boolean = true
|
||||
): String {
|
||||
val formattedAmount = this.toFormattedString(decimals = decimals, roundingMode = roundingMode)
|
||||
val decimalsForRounding = if (limitNumberOfDecimals){
|
||||
if (decimals > 8) 8 else decimals
|
||||
} else {
|
||||
decimals
|
||||
}
|
||||
val formattedAmount = this.toFormattedString(
|
||||
decimals = decimalsForRounding, roundingMode = roundingMode
|
||||
)
|
||||
return "$formattedAmount $currency"
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue