From 6fe8cdf15d9fb4e25e85798e0df369ffecbfdd1d Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 2 Sep 2024 01:12:23 +0200 Subject: [PATCH] Updated to BankingClient version 0.5.2-SNAPSHOT which renamed reference to unparsedReference --- composeApp/build.gradle.kts | 2 ++ .../codinux/banking/dataaccess/SqliteBankingRepository.kt | 6 +++--- .../banking/dataaccess/entities/AccountTransactionEntity.kt | 2 +- .../codinux/banking/ui/model/AccountTransactionViewModel.kt | 2 +- .../banking/ui/service/BankDataImporterAndExporter.kt | 2 +- .../kotlin/net/codinux/banking/ui/service/BankingService.kt | 4 +--- composeApp/src/commonMain/sqldelight/migrations/1.sqm | 2 ++ .../sqldelight/net/codinux/banking/ui/AccountTransaction.sq | 6 +++--- .../src/desktopMain/kotlin/net/codinux/banking/ui/main.kt | 3 +-- .../banking/dataaccess/SqliteBankingRepositoryTest.kt | 4 ++-- gradle/libs.versions.toml | 2 +- 11 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 composeApp/src/commonMain/sqldelight/migrations/1.sqm diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 6a81b1b..57de705 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -120,6 +120,8 @@ sqldelight { create("BankmeisterDb") { packageName.set("net.codinux.banking.dataaccess") generateAsync = true + + schemaOutputDirectory = file("src/commonMain/sqldelight/databases") } } } diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt index c48ed98..9d4039c 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt @@ -100,8 +100,8 @@ open class SqliteBankingRepository( override fun getAllAccountTransactionsAsViewModel(): List = // TODO: find a better way to express the reference value to display, sepaReference or (unparsed)reference - accountTransactionQueries.selectAllTransactionsAsViewModel { id, userAccountId, bankAccountId, amount, currency, reference, valueDate, otherPartyName, bookingText, sepaReference, userSetDisplayName, category -> - AccountTransactionViewModel(id, userAccountId, bankAccountId, mapToAmount(amount), currency, sepaReference ?: reference, mapToDate(valueDate), otherPartyName, bookingText, userSetDisplayName, category) + accountTransactionQueries.selectAllTransactionsAsViewModel { id, userAccountId, bankAccountId, amount, currency, unparsedReference, valueDate, otherPartyName, bookingText, sepaReference, userSetDisplayName, category -> + AccountTransactionViewModel(id, userAccountId, bankAccountId, mapToAmount(amount), currency, sepaReference ?: unparsedReference, mapToDate(valueDate), otherPartyName, bookingText, userSetDisplayName, category) }.executeAsList() override fun getAllAccountTransactions(): List { @@ -146,7 +146,7 @@ open class SqliteBankingRepository( accountTransactionQueries.insertTransaction( userAccountId, bankAccountId, - mapAmount(transaction.amount), transaction.currency, transaction.reference, + mapAmount(transaction.amount), transaction.currency, transaction.unparsedReference, mapDate(transaction.bookingDate), mapDate(transaction.valueDate), transaction.otherPartyName, transaction.otherPartyBankCode, transaction.otherPartyAccountId, transaction.bookingText, diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/AccountTransactionEntity.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/AccountTransactionEntity.kt index f65194a..4b36c7f 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/AccountTransactionEntity.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/AccountTransactionEntity.kt @@ -83,7 +83,7 @@ class AccountTransactionEntity( ) { constructor(id: Long, userAccountId: Long, bankAccountId: Long, transaction: AccountTransaction) : this( id, userAccountId, bankAccountId, - transaction.amount, transaction.currency, transaction.reference, transaction.bookingDate, transaction.valueDate, + transaction.amount, transaction.currency, transaction.unparsedReference, transaction.bookingDate, transaction.valueDate, transaction.otherPartyName, transaction.otherPartyBankCode, transaction.otherPartyAccountId, transaction.bookingText, transaction.userSetDisplayName, transaction.category, transaction.notes, transaction.information, diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/model/AccountTransactionViewModel.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/model/AccountTransactionViewModel.kt index 3161f48..1b0111c 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/model/AccountTransactionViewModel.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/model/AccountTransactionViewModel.kt @@ -23,5 +23,5 @@ data class AccountTransactionViewModel( constructor(entity: AccountTransactionEntity) : this(entity.id, entity.userAccountId, entity.bankAccountId, entity) constructor(id: Long, userAccountId: Long, bankAccountId: Long, transaction: AccountTransaction) - : this(id, userAccountId, bankAccountId, transaction.amount, transaction.currency, transaction.sepaReference ?: transaction.reference, transaction.valueDate, transaction.otherPartyName, transaction.bookingText) + : this(id, userAccountId, bankAccountId, transaction.amount, transaction.currency, transaction.reference, transaction.valueDate, transaction.otherPartyName, transaction.bookingText) } diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankDataImporterAndExporter.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankDataImporterAndExporter.kt index 898c488..ce15568 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankDataImporterAndExporter.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankDataImporterAndExporter.kt @@ -21,7 +21,7 @@ class BankDataImporterAndExporter { // TODO: add bank and bank account formatAmount(transaction.amount, decimalSeparator), transaction.currency, transaction.valueDate.toString(), transaction.bookingDate.toString(), - transaction.sepaReference ?: transaction.reference, + transaction.reference, transaction.otherPartyName, transaction.otherPartyBankCode, transaction.otherPartyAccountId // TODO: export all columns / transaction data ) diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankingService.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankingService.kt index 4f7f60e..0666886 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankingService.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankingService.kt @@ -18,9 +18,7 @@ import net.codinux.banking.fints.config.FinTsClientOptions import net.codinux.banking.ui.model.AccountTransactionViewModel import net.codinux.banking.ui.model.BankInfo import net.codinux.banking.ui.model.TanChallengeReceived -import net.codinux.banking.ui.model.error.BankingClientAction -import net.codinux.banking.ui.model.error.BankingClientError -import net.codinux.banking.ui.model.error.ErroneousAction +import net.codinux.banking.ui.model.error.* import net.codinux.banking.ui.state.UiState import net.codinux.csv.reader.CsvReader import net.codinux.log.logger diff --git a/composeApp/src/commonMain/sqldelight/migrations/1.sqm b/composeApp/src/commonMain/sqldelight/migrations/1.sqm new file mode 100644 index 0000000..7e85f37 --- /dev/null +++ b/composeApp/src/commonMain/sqldelight/migrations/1.sqm @@ -0,0 +1,2 @@ +ALTER TABLE AccountTransaction +RENAME COLUMN reference TO unparsedReference; \ No newline at end of file diff --git a/composeApp/src/commonMain/sqldelight/net/codinux/banking/ui/AccountTransaction.sq b/composeApp/src/commonMain/sqldelight/net/codinux/banking/ui/AccountTransaction.sq index 40aa1e8..d3b8970 100644 --- a/composeApp/src/commonMain/sqldelight/net/codinux/banking/ui/AccountTransaction.sq +++ b/composeApp/src/commonMain/sqldelight/net/codinux/banking/ui/AccountTransaction.sq @@ -6,7 +6,7 @@ CREATE TABLE IF NOT EXISTS AccountTransaction ( amount TEXT NOT NULL, currency TEXT NOT NULL, - reference TEXT NOT NULL, + unparsedReference TEXT NOT NULL, bookingDate TEXT NOT NULL, valueDate TEXT NOT NULL, @@ -58,7 +58,7 @@ insertTransaction: INSERT INTO AccountTransaction( userAccountId, bankAccountId, - amount, currency, reference, + amount, currency, unparsedReference, bookingDate, valueDate, otherPartyName, otherPartyBankCode, otherPartyAccountId, bookingText, @@ -118,5 +118,5 @@ SELECT AccountTransaction.* FROM AccountTransaction; selectAllTransactionsAsViewModel: -SELECT id, userAccountId, bankAccountId, amount, currency, reference, valueDate, otherPartyName, bookingText, sepaReference, userSetDisplayName, category +SELECT id, userAccountId, bankAccountId, amount, currency, unparsedReference, valueDate, otherPartyName, bookingText, sepaReference, userSetDisplayName, category FROM AccountTransaction; \ No newline at end of file diff --git a/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt b/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt index 119fc01..992f5a4 100644 --- a/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt +++ b/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt @@ -16,7 +16,6 @@ import net.codinux.banking.client.model.Amount import net.codinux.banking.dataaccess.BankmeisterDb import net.codinux.banking.dataaccess.InMemoryBankingRepository import net.codinux.banking.ui.config.DI -import net.codinux.log.Log import org.jetbrains.compose.resources.painterResource import java.io.File @@ -29,7 +28,7 @@ fun main() = application { ) { File("data/db").mkdirs() DI.setRepository(JdbcSqliteDriver("jdbc:sqlite:data/db/Bankmeister.db").apply { - val schema = BankmeisterDb.Schema.synchronous().create(this) + val schema = BankmeisterDb.Schema.synchronous().migrate(this, 1, 2) }) App() diff --git a/composeApp/src/desktopTest/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepositoryTest.kt b/composeApp/src/desktopTest/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepositoryTest.kt index 5ef3312..f412c66 100644 --- a/composeApp/src/desktopTest/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepositoryTest.kt +++ b/composeApp/src/desktopTest/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepositoryTest.kt @@ -88,7 +88,7 @@ class SqliteBankingRepositoryTest { assertEquals(transaction.amount, persisted.amount) assertEquals(transaction.currency, persisted.currency) - assertEquals(transaction.reference, persisted.reference) + assertEquals(transaction.unparsedReference, persisted.unparsedReference) assertEquals(transaction.bookingDate, persisted.bookingDate) assertEquals(transaction.valueDate, persisted.valueDate) assertEquals(transaction.otherPartyName, persisted.otherPartyName) @@ -109,7 +109,7 @@ class SqliteBankingRepositoryTest { assertEquals(transaction.amount, persisted.amount) assertEquals(transaction.currency, persisted.currency) - assertEquals(transaction.reference, persisted.reference) + assertEquals(transaction.unparsedReference, persisted.reference) assertEquals(transaction.valueDate, persisted.valueDate) assertEquals(transaction.otherPartyName, persisted.otherPartyName) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index efabc69..6718632 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ kotlin = "2.0.10" kotlinx-coroutines = "1.8.1" -banking-client = "0.5.1" +banking-client = "0.5.2-SNAPSHOT" kcsv = "2.2.0" kotlinx-serializable = "1.7.1"