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 9d4039c..a0ca67a 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/SqliteBankingRepository.kt @@ -48,7 +48,7 @@ open class SqliteBankingRepository( - fun getAllBankAccounts(): List = userAccountQueries.selectAllBankAccounts { id, userAccountId, identifier, accountHolderName, type, iban, subAccountNumber, productName, currency, accountLimit, isAccountTypeSupportedByApplication, features, balance, retrievedTransactionsFrom, retrievedTransactionsTo, countDaysForWhichTransactionsAreKept, userSetDisplayName, displayIndex, hideAccount, includeInAutomaticAccountsUpdate -> + fun getAllBankAccounts(): List = userAccountQueries.selectAllBankAccounts { id, userAccountId, identifier, accountHolderName, type, iban, subAccountNumber, productName, currency, accountLimit, isAccountTypeSupportedByApplication, features, balance, retrievedTransactionsFrom, retrievedTransactionsTo, haveAllTransactionsBeenRetrieved, countDaysForWhichTransactionsAreKept, userSetDisplayName, displayIndex, hideAccount, includeInAutomaticAccountsUpdate -> BankAccountEntity( id, userAccountId, identifier, accountHolderName, BankAccountType.valueOf(type), @@ -56,7 +56,7 @@ open class SqliteBankingRepository( isAccountTypeSupportedByApplication, mapEnumSet(features, BankAccountFeatures.entries), mapToAmount(balance), mapToDate(retrievedTransactionsFrom), mapToDate(retrievedTransactionsTo), - mapToInt(countDaysForWhichTransactionsAreKept), + haveAllTransactionsBeenRetrieved, mapToInt(countDaysForWhichTransactionsAreKept), mutableListOf(), mutableListOf(), @@ -82,7 +82,7 @@ open class SqliteBankingRepository( mapAmount(account.balance), mapDate(account.retrievedTransactionsFrom), mapDate(account.retrievedTransactionsTo), - mapInt(account.countDaysForWhichTransactionsAreKept), + account.haveAllTransactionsBeenRetrieved, mapInt(account.countDaysForWhichTransactionsAreKept), account.userSetDisplayName, mapInt(account.displayIndex), account.hideAccount, account.includeInAutomaticAccountsUpdate diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/BankAccountEntity.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/BankAccountEntity.kt index b81a79a..c023996 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/BankAccountEntity.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/dataaccess/entities/BankAccountEntity.kt @@ -23,6 +23,7 @@ class BankAccountEntity( retrievedTransactionsFrom: LocalDate? = null, retrievedTransactionsTo: LocalDate? = null, + haveAllTransactionsBeenRetrieved: Boolean = false, countDaysForWhichTransactionsAreKept: Int? = null, bookedTransactions: MutableList = mutableListOf(), @@ -36,7 +37,7 @@ class BankAccountEntity( ) : BankAccount( identifier, accountHolderName, type, iban, subAccountNumber, productName, currency, accountLimit, isAccountTypeSupportedByApplication, features, balance, - retrievedTransactionsFrom, retrievedTransactionsTo, false, countDaysForWhichTransactionsAreKept, + retrievedTransactionsFrom, retrievedTransactionsTo, haveAllTransactionsBeenRetrieved, countDaysForWhichTransactionsAreKept, bookedTransactions as MutableList, unbookedTransactions, userSetDisplayName, displayIndex, hideAccount, includeInAutomaticAccountsUpdate ) { @@ -45,7 +46,8 @@ class BankAccountEntity( account.identifier, account.accountHolderName, account.type, account.iban, account.subAccountNumber, account.productName, account.currency, account.accountLimit, account.isAccountTypeSupportedByApplication, account.features, account.balance, - account.retrievedTransactionsFrom, account.retrievedTransactionsTo, account.countDaysForWhichTransactionsAreKept, + account.retrievedTransactionsFrom, account.retrievedTransactionsTo, + account.haveAllTransactionsBeenRetrieved, account.countDaysForWhichTransactionsAreKept, transactions.toMutableList(), mutableListOf(), account.userSetDisplayName, account.displayIndex, account.hideAccount, account.includeInAutomaticAccountsUpdate ) diff --git a/composeApp/src/commonMain/sqldelight/migrations/2.sqm b/composeApp/src/commonMain/sqldelight/migrations/2.sqm new file mode 100644 index 0000000..0604a50 --- /dev/null +++ b/composeApp/src/commonMain/sqldelight/migrations/2.sqm @@ -0,0 +1,2 @@ +ALTER TABLE BankAccount +ADD COLUMN haveAllTransactionsBeenRetrieved INTEGER AS Boolean NOT NULL DEFAULT 0; \ No newline at end of file diff --git a/composeApp/src/commonMain/sqldelight/net/codinux/banking/ui/UserAccount.sq b/composeApp/src/commonMain/sqldelight/net/codinux/banking/ui/UserAccount.sq index 93826d8..19bd4c5 100644 --- a/composeApp/src/commonMain/sqldelight/net/codinux/banking/ui/UserAccount.sq +++ b/composeApp/src/commonMain/sqldelight/net/codinux/banking/ui/UserAccount.sq @@ -85,6 +85,7 @@ CREATE TABLE IF NOT EXISTS BankAccount ( retrievedTransactionsFrom TEXT, retrievedTransactionsTo TEXT, + haveAllTransactionsBeenRetrieved INTEGER AS Boolean NOT NULL, countDaysForWhichTransactionsAreKept INTEGER, userSetDisplayName TEXT, @@ -106,7 +107,7 @@ INSERT INTO BankAccount( balance, retrievedTransactionsFrom, retrievedTransactionsTo, - countDaysForWhichTransactionsAreKept, + haveAllTransactionsBeenRetrieved, countDaysForWhichTransactionsAreKept, userSetDisplayName, displayIndex, @@ -122,7 +123,7 @@ VALUES( ?, ?, ?, - ?, + ?, ?, ?, ?, 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 992f5a4..9dc2a79 100644 --- a/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt +++ b/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt @@ -28,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().migrate(this, 1, 2) + val schema = BankmeisterDb.Schema.synchronous().migrate(this, BankmeisterDb.Schema.version, 3) }) App()