diff --git a/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/SqliteBankingRepository.kt b/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/SqliteBankingRepository.kt index b0087d0..1d8668b 100644 --- a/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/SqliteBankingRepository.kt +++ b/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/SqliteBankingRepository.kt @@ -331,7 +331,7 @@ open class SqliteBankingRepository : BankingRepository { protected open fun getAllHoldings(): List = accountTransactionQueries.selectAllHoldings { id, bankId, accountId, name, isin, wkn, quantity, currency, totalBalance, marketValue, performancePercentage, totalCostPrice, averageCostPrice, pricingTime, buyingDate -> - HoldingEntity(id, bankId, accountId, name, isin, wkn, mapToInt(quantity), currency, mapToAmount(totalBalance), mapToAmount(marketValue), performancePercentage?.toFloat(), mapToAmount(totalCostPrice), mapToAmount(averageCostPrice), mapToInstant(pricingTime), mapToDate(buyingDate)) + HoldingEntity(id, bankId, accountId, name, isin, wkn, quantity, currency, mapToAmount(totalBalance), mapToAmount(marketValue), performancePercentage?.toFloat(), mapToAmount(totalCostPrice), mapToAmount(averageCostPrice), mapToInstant(pricingTime), mapToDate(buyingDate)) }.executeAsList() override suspend fun persistHoldings(bankAccount: BankAccountEntity, holdings: List): List = @@ -348,10 +348,10 @@ open class SqliteBankingRepository : BankingRepository { holding.name, holding.isin, holding.wkn, - mapInt(holding.quantity), holding.currency, + holding.quantity, holding.currency, mapAmount(holding.totalBalance), mapAmount(holding.marketValue), - holding.performancePercentage?.toDouble(), + holding.performancePercentage, mapAmount(holding.totalCostPrice), mapAmount(holding.averageCostPrice), mapInstant(holding.pricingTime), mapDate(holding.buyingDate) @@ -365,7 +365,7 @@ open class SqliteBankingRepository : BankingRepository { holdings.onEach { holding -> accountTransactionQueries.updateHolding( holding.name, holding.isin, holding.wkn, - mapInt(holding.quantity), holding.currency, + holding.quantity, holding.currency, mapAmount(holding.totalBalance), mapAmount(holding.marketValue), holding.performancePercentage?.toDouble(), diff --git a/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/entities/HoldingEntity.kt b/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/entities/HoldingEntity.kt index 0ed608b..1411d79 100644 --- a/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/entities/HoldingEntity.kt +++ b/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/entities/HoldingEntity.kt @@ -15,7 +15,7 @@ class HoldingEntity( isin: String? = null, wkn: String? = null, - quantity: Int? = null, + quantity: Double? = null, currency: String? = null, totalBalance: Amount? = null, diff --git a/BankingPersistence/src/commonMain/sqldelight/net/codinux/banking/persistence/AccountTransaction.sq b/BankingPersistence/src/commonMain/sqldelight/net/codinux/banking/persistence/AccountTransaction.sq index 2e75cf2..add2c14 100644 --- a/BankingPersistence/src/commonMain/sqldelight/net/codinux/banking/persistence/AccountTransaction.sq +++ b/BankingPersistence/src/commonMain/sqldelight/net/codinux/banking/persistence/AccountTransaction.sq @@ -182,7 +182,7 @@ CREATE TABLE IF NOT EXISTS Holding ( isin TEXT, wkn TEXT, - quantity INTEGER , + quantity REAL, currency TEXT, totalBalance TEXT, diff --git a/composeApp/src/androidMain/kotlin/net/codinux/banking/ui/composables/transactions/HoldingListItemPreview.kt b/composeApp/src/androidMain/kotlin/net/codinux/banking/ui/composables/transactions/HoldingListItemPreview.kt index cc60fec..1c819d2 100644 --- a/composeApp/src/androidMain/kotlin/net/codinux/banking/ui/composables/transactions/HoldingListItemPreview.kt +++ b/composeApp/src/androidMain/kotlin/net/codinux/banking/ui/composables/transactions/HoldingListItemPreview.kt @@ -10,8 +10,8 @@ import net.codinux.banking.ui.forms.RoundedCornersCard @Preview @Composable fun HoldingListItemPreview() { - val holding1 = Holding("MUL Amundi MSCI World V", null, null, 1693, "EUR", Amount("18578.04"), Amount("16.888"), -0.35f, Amount("17944.48"), Amount("16.828")) - val holding2 = Holding("NVIDIA Corp.", null, null, 214, "EUR", Amount("21455.36"), Amount("100.18"), 8.8f, Amount("19872.04"), Amount("92.04")) + val holding1 = Holding("MUL Amundi MSCI World V", null, null, 1693.0, "EUR", Amount("18578.04"), Amount("16.888"), -0.35f, Amount("17944.48"), Amount("16.828")) + val holding2 = Holding("NVIDIA Corp.", null, null, 214.0, "EUR", Amount("21455.36"), Amount("100.18"), 8.8f, Amount("19872.04"), Amount("92.04")) RoundedCornersCard { Column { 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 40a4fe1..7568fcd 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() + " Stück, ") + Text(holding.quantity.toString().replace(".0", "").replace(".", ",") + " Stück, ") } if (holding.averageCostPrice != null) {