diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/HoldingListItem.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/HoldingListItem.kt index 7568fcd..889ec60 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/HoldingListItem.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/HoldingListItem.kt @@ -70,7 +70,7 @@ fun HoldingListItem(holding: Holding, isOddItem: Boolean = false, isNotLastItem: Row(Modifier.weight(1f).padding(end = 6.dp), verticalAlignment = Alignment.CenterVertically) { // TODO: set maxLines = 1 and TextOverflow.Ellipsis if (holding.quantity != null) { - Text(holding.quantity.toString().replace(".0", "").replace(".", ",") + " Stück, ") + Text(formatUtil.formatQuantity(holding.quantity) + " Stück, ") } if (holding.averageCostPrice != null) { diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/FormatUtil.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/FormatUtil.kt index 80d8d00..f9aa12d 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/FormatUtil.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/FormatUtil.kt @@ -74,6 +74,9 @@ class FormatUtil { fun formatPercentage(performance: Float): String = (if (performance > 0) "+" else "") + formatToTwoDecimalPlaces(performance.toString()) + " %" + fun formatQuantity(quantity: Double?): String = + quantity.toString().replace(".0", "").replace(".", ",") // TODO: find a better way + private fun formatToTwoDecimalPlaces(amount: String): String { // TODO: find a better way val parts = amount.split('.')