From 5c3abc449dfbc8435a1e6cd500236e403d3594fc Mon Sep 17 00:00:00 2001 From: Iliyan Germanov Date: Sun, 24 Apr 2022 21:12:19 +0300 Subject: [PATCH] Make the project builds! (certainly it's unstable) --- .../wallet/domain/data/core/Transaction.kt | 2 +- .../logic/PlannedPaymentsGenerator.kt | 4 +- .../deprecated/logic/PlannedPaymentsLogic.kt | 20 +-- .../deprecated/logic/PreloadDataLogic.kt | 10 +- .../deprecated/logic/WalletAccountLogic.kt | 30 +---- .../deprecated/logic/WalletCategoryLogic.kt | 52 ++++---- .../deprecated/logic/csv/CSVImporter.kt | 24 ++-- .../domain/deprecated/logic/csv/CSVMapper.kt | 7 +- .../deprecated/logic/csv/CSVNormalizer.kt | 2 +- .../deprecated/logic/csv/ExportCSVLogic.kt | 4 +- .../logic/currency/ExchangeRatesLogic.kt | 12 +- .../logic/loantrasactions/LTLoanMapper.kt | 40 +++--- .../loantrasactions/LTLoanRecordMapper.kt | 14 +-- .../loantrasactions/LoanTransactionsCore.kt | 27 ++-- .../deprecated/logic/zip/ExportZipLogic.kt | 41 ++++--- .../wallet/domain/pure/charts/WalletCharts.kt | 14 +-- .../pure/transaction/TrnDateDividers.kt | 26 ++++ .../com/ivy/wallet/io/network/IvySession.kt | 2 +- .../com/ivy/wallet/io/network/RestClient.kt | 3 - .../service/BankIntegrationsService.kt | 26 ---- .../ivy/wallet/ui/csvimport/ImportScreen.kt | 4 +- .../wallet/ui/csvimport/flow/ImportFrom.kt | 7 +- .../ui/csvimport/flow/ImportResultUI.kt | 4 +- .../flow/instructions/ImportInstructions.kt | 3 +- .../com/ivy/wallet/ui/home/CustomerJourney.kt | 4 +- .../ui/loandetails/LoanDetailsScreen.kt | 6 +- .../java/com/ivy/wallet/ui/main/MainScreen.kt | 2 +- .../wallet/ui/onboarding/OnboardingScreen.kt | 4 +- .../ui/onboarding/components/Suggestions.kt | 4 +- .../ui/onboarding/steps/OnboardingAccounts.kt | 2 +- .../onboarding/steps/OnboardingCategories.kt | 2 +- .../onboarding/viewmodel/OnboardingRouter.kt | 16 +-- .../ui/planned/edit/EditPlannedScreen.kt | 4 +- .../level2/ItemStatisticViewModel.kt | 116 +++++++++++------- .../ivy/wallet/ui/theme/modal/BudgetModal.kt | 2 +- .../ivy/wallet/ui/theme/modal/LoanModal.kt | 4 +- .../wallet/ui/theme/modal/LoanRecordModal.kt | 6 +- .../ui/theme/transaction/TransactionCard.kt | 14 +-- 38 files changed, 280 insertions(+), 284 deletions(-) delete mode 100644 app/src/main/java/com/ivy/wallet/io/network/service/BankIntegrationsService.kt diff --git a/app/src/main/java/com/ivy/wallet/domain/data/core/Transaction.kt b/app/src/main/java/com/ivy/wallet/domain/data/core/Transaction.kt index 86d2734698..28b810756c 100644 --- a/app/src/main/java/com/ivy/wallet/domain/data/core/Transaction.kt +++ b/app/src/main/java/com/ivy/wallet/domain/data/core/Transaction.kt @@ -14,7 +14,7 @@ data class Transaction( val type: TransactionType, val amount: BigDecimal, val toAccountId: UUID? = null, - val toAmount: BigDecimal, + val toAmount: BigDecimal = amount, val title: String? = null, val description: String? = null, val dateTime: LocalDateTime? = null, diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/PlannedPaymentsGenerator.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/PlannedPaymentsGenerator.kt index b89bc936fe..3f028b636f 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/PlannedPaymentsGenerator.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/PlannedPaymentsGenerator.kt @@ -76,7 +76,7 @@ class PlannedPaymentsGenerator( accountId = rule.accountId, recurringRuleId = rule.id, categoryId = rule.categoryId, - amount = rule.amount, + amount = rule.amount.toBigDecimal(), title = rule.title, description = rule.description, dueDate = dueDate, @@ -84,7 +84,7 @@ class PlannedPaymentsGenerator( toAccountId = null, isSynced = false - ) + ).toEntity() ) } diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/PlannedPaymentsLogic.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/PlannedPaymentsLogic.kt index 8ff123dabe..9be79816a1 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/PlannedPaymentsLogic.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/PlannedPaymentsLogic.kt @@ -5,10 +5,10 @@ import com.ivy.wallet.domain.data.TransactionType import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.PlannedPaymentRule import com.ivy.wallet.domain.data.core.Transaction -import com.ivy.wallet.domain.logic.currency.ExchangeRatesLogic -import com.ivy.wallet.domain.logic.currency.sumByDoublePlannedInBaseCurrency -import com.ivy.wallet.domain.sync.uploader.PlannedPaymentRuleUploader -import com.ivy.wallet.domain.sync.uploader.TransactionUploader +import com.ivy.wallet.domain.deprecated.logic.currency.ExchangeRatesLogic +import com.ivy.wallet.domain.deprecated.logic.currency.sumByDoublePlannedInBaseCurrency +import com.ivy.wallet.domain.deprecated.sync.uploader.PlannedPaymentRuleUploader +import com.ivy.wallet.domain.deprecated.sync.uploader.TransactionUploader import com.ivy.wallet.io.persistence.dao.AccountDao import com.ivy.wallet.io.persistence.dao.PlannedPaymentRuleDao import com.ivy.wallet.io.persistence.dao.SettingsDao @@ -40,9 +40,9 @@ class PlannedPaymentsLogic( endDate = range.to() ).sumOf { val amount = exchangeRatesLogic.amountBaseCurrency( - transaction = it, + transaction = it.toDomain(), baseCurrency = baseCurrency, - accounts = accounts + accounts = accounts.map { it.toDomain() } ) when (it.type) { @@ -54,7 +54,7 @@ class PlannedPaymentsLogic( } fun oneTime(): List { - return plannedPaymentRuleDao.findAllByOneTime(oneTime = true) + return plannedPaymentRuleDao.findAllByOneTime(oneTime = true).map { it.toDomain() } } fun oneTimeIncome(): Double { @@ -78,7 +78,7 @@ class PlannedPaymentsLogic( } fun recurring(): List = - plannedPaymentRuleDao.findAllByOneTime(oneTime = false) + plannedPaymentRuleDao.findAllByOneTime(oneTime = false).map { it.toDomain() } fun recurringIncome(): Double { return recurring() @@ -100,7 +100,7 @@ class PlannedPaymentsLogic( amountForMonthInBaseCurrency( plannedPayment = it, baseCurrency = baseCurrency, - accounts = accounts + accounts = accounts.map { it.toDomain() } ) } } @@ -166,7 +166,7 @@ class PlannedPaymentsLogic( } ioThread { - transactionDao.save(paidTransaction) + transactionDao.save(paidTransaction.toEntity()) if (plannedPaymentRule != null && plannedPaymentRule.oneTime) { //delete paid oneTime planned payment rules diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/PreloadDataLogic.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/PreloadDataLogic.kt index da2d9c289f..2ebd1831f5 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/PreloadDataLogic.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/PreloadDataLogic.kt @@ -3,8 +3,8 @@ package com.ivy.wallet.domain.deprecated.logic import androidx.compose.ui.graphics.toArgb import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.Category -import com.ivy.wallet.domain.logic.model.CreateAccountData -import com.ivy.wallet.domain.logic.model.CreateCategoryData +import com.ivy.wallet.domain.deprecated.logic.model.CreateAccountData +import com.ivy.wallet.domain.deprecated.logic.model.CreateCategoryData import com.ivy.wallet.io.persistence.dao.AccountDao import com.ivy.wallet.io.persistence.dao.CategoryDao import com.ivy.wallet.ui.onboarding.model.AccountBalance @@ -41,8 +41,8 @@ class PreloadDataLogic( isSynced = false ) - accountsDao.save(cash) - accountsDao.save(bank) + accountsDao.save(cash.toEntity()) + accountsDao.save(bank.toEntity()) } fun accountSuggestions(baseCurrency: String): List = listOf( @@ -152,7 +152,7 @@ class PreloadDataLogic( isSynced = false ) - categoryDao.save(category) + categoryDao.save(category.toEntity()) } fun categorySuggestions(): List = preloadCategoriesCreateData() diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/WalletAccountLogic.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/WalletAccountLogic.kt index 6c090c0a00..453d65b76f 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/WalletAccountLogic.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/WalletAccountLogic.kt @@ -1,7 +1,5 @@ package com.ivy.wallet.domain.deprecated.logic -import com.ivy.wallet.R -import com.ivy.wallet.domain.data.TransactionHistoryItem import com.ivy.wallet.domain.data.TransactionType import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.Transaction @@ -9,7 +7,6 @@ import com.ivy.wallet.domain.deprecated.logic.currency.ExchangeRatesLogic import com.ivy.wallet.io.persistence.dao.AccountDao import com.ivy.wallet.io.persistence.dao.SettingsDao import com.ivy.wallet.io.persistence.dao.TransactionDao -import com.ivy.wallet.stringRes import com.ivy.wallet.ui.onboarding.model.FromToTimeRange import com.ivy.wallet.ui.onboarding.model.filterOverdue import com.ivy.wallet.ui.onboarding.model.filterUpcoming @@ -31,7 +28,7 @@ class WalletAccountLogic( actualBalance: Double = calculateAccountBalance(account), newBalance: Double, - adjustTransactionTitle: String = stringRes(R.string.adjust_balance), + adjustTransactionTitle: String = "Adjust balance", isFiat: Boolean? = null, trnIsSyncedFlag: Boolean = false, //TODO: Remove this once Bank Integration trn sync is properly implemented @@ -71,31 +68,6 @@ class WalletAccountLogic( } } - fun historyForAccount(account: Account, range: FromToTimeRange): List { - val startDate = range.from() - val endDate = range.to() - - return transactionDao - .findAllByAccountAndBetween( - accountId = account.id, - startDate = startDate, - endDate = endDate - ) - .plus( - transactionDao.findAllToAccountAndBetween( - toAccountId = account.id, - startDate = startDate, - endDate = endDate - ) - ) - .sortedByDescending { it.dateTime } - .withDateDividers( - exchangeRatesLogic = exchangeRatesLogic, - accountDao = accountDao, - settingsDao = settingsDao - ) - } - fun calculateAccountBalance( account: Account, before: LocalDateTime? = null diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/WalletCategoryLogic.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/WalletCategoryLogic.kt index 292d08698f..e17d498e3c 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/WalletCategoryLogic.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/WalletCategoryLogic.kt @@ -4,12 +4,15 @@ import com.ivy.wallet.domain.data.TransactionHistoryItem import com.ivy.wallet.domain.data.TransactionType import com.ivy.wallet.domain.data.core.Category import com.ivy.wallet.domain.data.core.Transaction -import com.ivy.wallet.domain.logic.currency.ExchangeRatesLogic -import com.ivy.wallet.domain.logic.currency.sumInBaseCurrency +import com.ivy.wallet.domain.deprecated.logic.currency.ExchangeRatesLogic +import com.ivy.wallet.domain.deprecated.logic.currency.sumInBaseCurrency +import com.ivy.wallet.domain.pure.transaction.withDateDividers import com.ivy.wallet.io.persistence.dao.AccountDao import com.ivy.wallet.io.persistence.dao.SettingsDao import com.ivy.wallet.io.persistence.dao.TransactionDao import com.ivy.wallet.ui.onboarding.model.FromToTimeRange +import com.ivy.wallet.ui.onboarding.model.filterOverdue +import com.ivy.wallet.ui.onboarding.model.filterUpcoming import java.util.* @Deprecated("Migrate to FP Style") @@ -27,7 +30,7 @@ class WalletCategoryLogic( transactions: List = emptyList() ): Double { val baseCurrency = settingsDao.findFirst().currency - val accounts = accountDao.findAll() + val accounts = accountDao.findAll().map { it.toDomain() } return historyByCategory( category, @@ -61,7 +64,7 @@ class WalletCategoryLogic( type = TransactionType.INCOME, startDate = range.from(), endDate = range.to() - ) + ).map { it.toDomain() } .filter { accountFilterSet.isEmpty() || accountFilterSet.contains(it.accountId) } @@ -101,7 +104,7 @@ class WalletCategoryLogic( ) .filter { accountFilterSet.isEmpty() || accountFilterSet.contains(it.accountId) - } + }.map { it.toDomain() } .sumInBaseCurrency( exchangeRatesLogic = exchangeRatesLogic, settingsDao = settingsDao, @@ -135,7 +138,7 @@ class WalletCategoryLogic( type = TransactionType.INCOME, startDate = range.from(), endDate = range.to() - ) + ).map { it.toDomain() } .sumInBaseCurrency( exchangeRatesLogic = exchangeRatesLogic, settingsDao = settingsDao, @@ -149,7 +152,7 @@ class WalletCategoryLogic( type = TransactionType.EXPENSE, startDate = range.from(), endDate = range.to() - ) + ).map { it.toDomain() } .sumInBaseCurrency( exchangeRatesLogic = exchangeRatesLogic, settingsDao = settingsDao, @@ -157,19 +160,8 @@ class WalletCategoryLogic( ) } - fun historyByCategoryWithDateDividers( - category: Category, - range: FromToTimeRange - ): List { - return historyByCategory(category, range) - .withDateDividers( - exchangeRatesLogic = exchangeRatesLogic, - settingsDao = settingsDao, - accountDao = accountDao - ) - } - fun historyByCategoryAccountWithDateDividers( + suspend fun historyByCategoryAccountWithDateDividers( category: Category, range: FromToTimeRange, accountFilterSet: Set, @@ -199,7 +191,7 @@ class WalletCategoryLogic( categoryId = category.id, startDate = range.from(), endDate = range.to() - ) + ).map { it.toDomain() } } return trans.filter { @@ -207,12 +199,12 @@ class WalletCategoryLogic( } } - fun historyUnspecified(range: FromToTimeRange): List { + suspend fun historyUnspecified(range: FromToTimeRange): List { return transactionDao .findAllUnspecifiedAndBetween( startDate = range.from(), endDate = range.to() - ) + ).map { it.toDomain() } .withDateDividers( exchangeRatesLogic = exchangeRatesLogic, settingsDao = settingsDao, @@ -266,14 +258,18 @@ class WalletCategoryLogic( categoryId = category.id, startDate = range.upcomingFrom(), endDate = range.to() - ).filterUpcoming() + ) + .map { it.toDomain() } + .filterUpcoming() } fun upcomingUnspecified(range: FromToTimeRange): List { return transactionDao.findAllDueToBetweenByCategoryUnspecified( startDate = range.upcomingFrom(), endDate = range.to() - ).filterUpcoming() + ) + .map { it.toDomain() } + .filterUpcoming() } fun calculateOverdueIncomeByCategory(category: Category, range: FromToTimeRange): Double { @@ -322,14 +318,18 @@ class WalletCategoryLogic( categoryId = category.id, startDate = range.from(), endDate = range.overdueTo() - ).filterOverdue() + ) + .map { it.toDomain() } + .filterOverdue() } fun overdueUnspecified(range: FromToTimeRange): List { return transactionDao.findAllDueToBetweenByCategoryUnspecified( startDate = range.from(), endDate = range.overdueTo() - ).filterOverdue() + ) + .map { it.toDomain() } + .filterOverdue() } } \ No newline at end of file diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/CSVImporter.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/CSVImporter.kt index 6dadc36b44..cd36a3f8e9 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/CSVImporter.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/CSVImporter.kt @@ -6,9 +6,9 @@ import com.ivy.wallet.domain.data.TransactionType import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.Category import com.ivy.wallet.domain.data.core.Transaction -import com.ivy.wallet.domain.logic.csv.model.CSVRow -import com.ivy.wallet.domain.logic.csv.model.ImportResult -import com.ivy.wallet.domain.logic.csv.model.RowMapping +import com.ivy.wallet.domain.deprecated.logic.csv.model.CSVRow +import com.ivy.wallet.domain.deprecated.logic.csv.model.ImportResult +import com.ivy.wallet.domain.deprecated.logic.csv.model.RowMapping import com.ivy.wallet.io.persistence.dao.AccountDao import com.ivy.wallet.io.persistence.dao.CategoryDao import com.ivy.wallet.io.persistence.dao.SettingsDao @@ -78,10 +78,10 @@ class CSVImporter( newCategoryColorIndex = 0 newAccountColorIndex = 0 - accounts = accountDao.findAll() + accounts = accountDao.findAll().map { it.toDomain() } val initialAccountsCount = accounts.size - categories = categoryDao.findAll() + categories = categoryDao.findAll().map { it.toDomain() } val initialCategoriesCount = categories.size val baseCurrency = settingsDao.findFirst().currency @@ -120,7 +120,7 @@ class CSVImporter( val progressPercent = if (rowsCount > 0) index / transactions.size.toDouble() else 0.0 onProgress(0.5 + progressPercent / 2) - transactionDao.save(transaction) + transactionDao.save(transaction.toEntity()) } return ImportResult( @@ -212,10 +212,10 @@ class CSVImporter( Transaction( id = id, type = type, - amount = amount, + amount = amount.toBigDecimal(), accountId = account.id, toAccountId = toAccount?.id, - toAmount = toAmount, + toAmount = toAmount?.toBigDecimal() ?: amount.toBigDecimal(), dateTime = dateTime, dueDate = dueDate, categoryId = category?.id, @@ -444,8 +444,8 @@ class CSVImporter( icon = icon, orderNum = orderNum ?: accountDao.findMaxOrderNum() + 1 ) - accountDao.save(newAccount) - accounts = accountDao.findAll() + accountDao.save(newAccount.toEntity()) + accounts = accountDao.findAll().map { it.toDomain() } return newAccount } @@ -493,8 +493,8 @@ class CSVImporter( icon = icon, orderNum = orderNum ?: categoryDao.findMaxOrderNum() + 1 ) - categoryDao.save(newCategory) - categories = categoryDao.findAll() + categoryDao.save(newCategory.toEntity()) + categories = categoryDao.findAll().map { it.toDomain() } return newCategory } diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/CSVMapper.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/CSVMapper.kt index 61ddd35155..98c35a0015 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/CSVMapper.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/CSVMapper.kt @@ -2,9 +2,10 @@ package com.ivy.wallet.domain.deprecated.logic.csv import com.ivy.wallet.domain.data.TransactionType import com.ivy.wallet.domain.data.core.Transaction -import com.ivy.wallet.domain.logic.csv.model.ImportType -import com.ivy.wallet.domain.logic.csv.model.JoinResult -import com.ivy.wallet.domain.logic.csv.model.RowMapping +import com.ivy.wallet.domain.deprecated.logic.csv.model.ImportType +import com.ivy.wallet.domain.deprecated.logic.csv.model.JoinResult +import com.ivy.wallet.domain.deprecated.logic.csv.model.RowMapping +import com.ivy.wallet.utils.toLowerCaseLocal class CSVMapper { diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/CSVNormalizer.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/CSVNormalizer.kt index 3b96b1a64f..4f1b4389c3 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/CSVNormalizer.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/CSVNormalizer.kt @@ -1,6 +1,6 @@ package com.ivy.wallet.domain.deprecated.logic.csv -import com.ivy.wallet.domain.logic.csv.model.ImportType +import com.ivy.wallet.domain.deprecated.logic.csv.model.ImportType class CSVNormalizer { diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/ExportCSVLogic.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/ExportCSVLogic.kt index a0c366f698..2c80a97bcc 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/ExportCSVLogic.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/csv/ExportCSVLogic.kt @@ -31,7 +31,7 @@ class ExportCSVLogic( suspend fun exportToFile( context: Context, fileUri: Uri, - exportScope: () -> List = { + exportScope: suspend () -> List = { transactionDao.findAll().map { it.toDomain() } } ) { @@ -49,7 +49,7 @@ class ExportCSVLogic( } private suspend fun generateCSV( - exportScope: () -> List + exportScope: suspend () -> List ): String { return ioThread { val accountMap = accountDao diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/currency/ExchangeRatesLogic.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/currency/ExchangeRatesLogic.kt index 831fbc3714..374110e9bc 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/currency/ExchangeRatesLogic.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/currency/ExchangeRatesLogic.kt @@ -37,7 +37,7 @@ class ExchangeRatesLogic( baseCurrency = baseCurrency, currency = currency, rate = rate - ) + ).toEntity() ) } } catch (e: Exception) { @@ -65,7 +65,7 @@ class ExchangeRatesLogic( accounts: List //helper ): Double { return amountBaseCurrency( - amount = transaction.amount, + amount = transaction.amount.toDouble(), accountId = transaction.accountId, baseCurrency = baseCurrency, accounts = accounts @@ -79,10 +79,10 @@ class ExchangeRatesLogic( ): Double { val amount = transaction.toAmount ?: transaction.amount val toCurrency = accounts.find { it.id == transaction.toAccountId }?.currency - ?: return amount // no conversion + ?: return amount.toDouble() // no conversion return amountBaseCurrency( - amount = amount, + amount = amount.toDouble(), amountCurrency = toCurrency, baseCurrency = baseCurrency ) @@ -162,7 +162,7 @@ fun Iterable.sumInBaseCurrency( exchangeRatesLogic.amountBaseCurrency( transaction = it, baseCurrency = baseCurrency, - accounts = accounts + accounts = accounts.map { it.toDomain() } ) } } @@ -180,7 +180,7 @@ fun Iterable.sumByDoublePlannedInBaseCurrency( exchangeRatesLogic.amountBaseCurrency( plannedPayment = it, baseCurrency = baseCurrency, - accounts = accounts + accounts = accounts.map { it.toDomain() } ) } } \ No newline at end of file diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/loantrasactions/LTLoanMapper.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/loantrasactions/LTLoanMapper.kt index ba088576e7..170336fe36 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/loantrasactions/LTLoanMapper.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/loantrasactions/LTLoanMapper.kt @@ -6,7 +6,7 @@ import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.Loan import com.ivy.wallet.domain.data.core.LoanRecord import com.ivy.wallet.domain.data.core.Transaction -import com.ivy.wallet.domain.logic.model.CreateLoanData +import com.ivy.wallet.domain.deprecated.logic.model.CreateLoanData import com.ivy.wallet.utils.computationThread import com.ivy.wallet.utils.scopedIOThread import kotlinx.coroutines.async @@ -60,7 +60,7 @@ class LTLoanMapper( newLoanAccountId: UUID?, loanId: UUID ) { - val accounts = ltCore.fetchAccounts() + val accounts = ltCore.fetchAccounts().map { it.toDomain() } computationThread { if (oldLoanAccountId == newLoanAccountId || oldLoanAccountId.fetchAssociatedCurrencyCode( @@ -100,13 +100,13 @@ class LTLoanMapper( } val modifiedLoan = loan.copy( - amount = transaction.amount, + amount = transaction.amount.toDouble(), name = if (transaction.title.isNullOrEmpty()) loan.name else transaction.title, type = if (transaction.type == TransactionType.INCOME) LoanType.BORROW else LoanType.LEND, accountId = transaction.accountId ) - ltCore.saveLoan(modifiedLoan) + ltCore.saveLoan(modifiedLoan.toDomain()) } onBackgroundProcessingEnd() } @@ -117,21 +117,23 @@ class LTLoanMapper( ): List { return scopedIOThread { scope -> val loanRecords = - ltCore.fetchAllLoanRecords(loanId = loanId).map { loanRecord -> - scope.async { - val convertedAmount: Double? = - ltCore.computeConvertedAmount( - oldLoanRecordAccountId = loanRecord.accountId, - oldLonRecordConvertedAmount = loanRecord.convertedAmount, - oldLoanRecordAmount = loanRecord.amount, - newLoanRecordAccountID = loanRecord.accountId, - newLoanRecordAmount = loanRecord.amount, - loanAccountId = newAccountId, - accounts = ltCore.fetchAccounts(), - ) - loanRecord.copy(convertedAmount = convertedAmount) - } - }.awaitAll() + ltCore.fetchAllLoanRecords(loanId = loanId) + .map { it.toDomain() } + .map { loanRecord -> + scope.async { + val convertedAmount: Double? = + ltCore.computeConvertedAmount( + oldLoanRecordAccountId = loanRecord.accountId, + oldLonRecordConvertedAmount = loanRecord.convertedAmount, + oldLoanRecordAmount = loanRecord.amount, + newLoanRecordAccountID = loanRecord.accountId, + newLoanRecordAmount = loanRecord.amount, + loanAccountId = newAccountId, + accounts = ltCore.fetchAccounts().map { it.toDomain() }, + ) + loanRecord.copy(convertedAmount = convertedAmount) + } + }.awaitAll() loanRecords } } diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/loantrasactions/LTLoanRecordMapper.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/loantrasactions/LTLoanRecordMapper.kt index fe7c9c25c1..88cc9ba82a 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/loantrasactions/LTLoanRecordMapper.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/loantrasactions/LTLoanRecordMapper.kt @@ -3,7 +3,7 @@ package com.ivy.wallet.domain.deprecated.logic.loantrasactions import com.ivy.wallet.domain.data.core.Loan import com.ivy.wallet.domain.data.core.LoanRecord import com.ivy.wallet.domain.data.core.Transaction -import com.ivy.wallet.domain.logic.model.CreateLoanRecordData +import com.ivy.wallet.domain.deprecated.logic.model.CreateLoanRecordData import com.ivy.wallet.utils.computationThread import java.util.* @@ -75,19 +75,19 @@ class LTLoanRecordMapper( oldLonRecordConvertedAmount = loanRecord.convertedAmount, oldLoanRecordAmount = loanRecord.amount, newLoanRecordAccountID = transaction.accountId, - newLoanRecordAmount = transaction.amount, + newLoanRecordAmount = transaction.amount.toDouble(), loanAccountId = loan.accountId, - accounts = ltCore.fetchAccounts() + accounts = ltCore.fetchAccounts().map { it.toDomain() } ) val modifiedLoanRecord = loanRecord.copy( - amount = transaction.amount, + amount = transaction.amount.toDouble(), note = transaction.title, dateTime = transaction.dateTime ?: loanRecord.dateTime, accountId = transaction.accountId, convertedAmount = convertedAmount ) - ltCore.saveLoanRecords(modifiedLoanRecord) + ltCore.saveLoanRecords(modifiedLoanRecord.toDomain()) } onBackgroundProcessingEnd() } @@ -105,7 +105,7 @@ class LTLoanRecordMapper( newLoanRecordAccountID = newLoanRecord.accountId, newLoanRecordAmount = newLoanRecord.amount, loanAccountId = loanAccountId, - accounts = ltCore.fetchAccounts(), + accounts = ltCore.fetchAccounts().map { it.toDomain() }, reCalculateLoanAmount = reCalculateLoanAmount ) } @@ -121,7 +121,7 @@ class LTLoanRecordMapper( newLoanRecordAccountID = data.account?.id, newLoanRecordAmount = data.amount, loanAccountId = loanAccountId, - accounts = ltCore.fetchAccounts(), + accounts = ltCore.fetchAccounts().map { it.toDomain() }, ) } } \ No newline at end of file diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/loantrasactions/LoanTransactionsCore.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/loantrasactions/LoanTransactionsCore.kt index cb89056747..82d4efe386 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/loantrasactions/LoanTransactionsCore.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/loantrasactions/LoanTransactionsCore.kt @@ -5,8 +5,8 @@ import com.ivy.wallet.R import com.ivy.wallet.domain.data.LoanType import com.ivy.wallet.domain.data.TransactionType import com.ivy.wallet.domain.data.core.* -import com.ivy.wallet.domain.logic.currency.ExchangeRatesLogic -import com.ivy.wallet.domain.sync.uploader.TransactionUploader +import com.ivy.wallet.domain.deprecated.logic.currency.ExchangeRatesLogic +import com.ivy.wallet.domain.deprecated.sync.uploader.TransactionUploader import com.ivy.wallet.io.persistence.dao.* import com.ivy.wallet.stringRes import com.ivy.wallet.ui.IvyWalletCtx @@ -48,8 +48,9 @@ class LoanTransactionsCore( ioThread { val transactions: List = - if (loanId != null) transactionDao.findAllByLoanId(loanId = loanId) else - listOf(transactionDao.findLoanRecordTransaction(loanRecordId!!)) + if (loanId != null) transactionDao.findAllByLoanId(loanId = loanId) + .map { it.toDomain() } else + listOf(transactionDao.findLoanRecordTransaction(loanRecordId!!)).map { it?.toDomain() } transactions.forEach { trans -> deleteTransaction(trans) @@ -144,7 +145,7 @@ class LoanTransactionsCore( val modifiedTransaction: Transaction = transaction?.copy( loanId = loanId, loanRecordId = if (isLoanRecord) loanRecordId else null, - amount = amount, + amount = amount.toBigDecimal(), type = transType, accountId = selectedAccountId, title = title, @@ -154,7 +155,7 @@ class LoanTransactionsCore( ?: Transaction( accountId = selectedAccountId, type = transType, - amount = amount, + amount = amount.toBigDecimal(), dateTime = time, categoryId = transCategoryId, title = title, @@ -163,7 +164,7 @@ class LoanTransactionsCore( ) ioThread { - transactionDao.save(modifiedTransaction) + transactionDao.save(modifiedTransaction.toEntity()) } } @@ -184,7 +185,7 @@ class LoanTransactionsCore( return existingCategoryId val categoryList = ioThread { - categoryDao.findAll() + categoryDao.findAll().map { it.toDomain() } } var addCategoryToDb = false @@ -203,7 +204,7 @@ class LoanTransactionsCore( if (addCategoryToDb) ioThread { loanCategory?.let { - categoryDao.save(it) + categoryDao.save(it.toEntity()) } } @@ -270,15 +271,15 @@ class LoanTransactionsCore( } suspend fun saveLoanRecords(loanRecords: List) = ioThread { - loanRecordDao.save(loanRecords) + loanRecordDao.save(loanRecords.map { it.toEntity() }) } suspend fun saveLoanRecords(loanRecord: LoanRecord) = ioThread { - loanRecordDao.save(loanRecord) + loanRecordDao.save(loanRecord.toEntity()) } suspend fun saveLoan(loan: Loan) = ioThread { - loanDao.save(loan) + loanDao.save(loan.toEntity()) } suspend fun fetchLoanRecord(loanRecordId: UUID) = ioThread { @@ -296,7 +297,7 @@ class LoanTransactionsCore( suspend fun fetchLoanRecordTransaction(loanRecordId: UUID?): Transaction? { return loanRecordId?.let { ioThread { - transactionDao.findLoanRecordTransaction(it) + transactionDao.findLoanRecordTransaction(it)?.toDomain() } } } diff --git a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/zip/ExportZipLogic.kt b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/zip/ExportZipLogic.kt index 9714533e2d..a692259b5e 100644 --- a/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/zip/ExportZipLogic.kt +++ b/app/src/main/java/com/ivy/wallet/domain/deprecated/logic/zip/ExportZipLogic.kt @@ -6,7 +6,7 @@ import androidx.core.net.toUri import com.google.gson.* import com.google.gson.reflect.TypeToken import com.ivy.wallet.domain.data.IvyWalletCompleteData -import com.ivy.wallet.domain.logic.csv.model.ImportResult +import com.ivy.wallet.domain.deprecated.logic.csv.model.ImportResult import com.ivy.wallet.io.persistence.SharedPrefs import com.ivy.wallet.io.persistence.dao.* import com.ivy.wallet.utils.ioThread @@ -56,14 +56,15 @@ class ExportZipLogic( private suspend fun generateJsonString(): String { return scopedIOThread { - val accounts = it.async { accountDao.findAll() } - val budgets = it.async { budgetDao.findAll() } - val categories = it.async { categoryDao.findAll() } - val loanRecords = it.async { loanRecordDao.findAll() } - val loans = it.async { loanDao.findAll() } - val plannedPaymentRules = it.async { plannedPaymentRuleDao.findAll() } - val settings = it.async { settingsDao.findAll() } - val transactions = it.async { transactionDao.findAll() } + val accounts = it.async { accountDao.findAll().map { it.toDomain() } } + val budgets = it.async { budgetDao.findAll().map { it.toDomain() } } + val categories = it.async { categoryDao.findAll().map { it.toDomain() } } + val loanRecords = it.async { loanRecordDao.findAll().map { it.toDomain() } } + val loans = it.async { loanDao.findAll().map { it.toDomain() } } + val plannedPaymentRules = + it.async { plannedPaymentRuleDao.findAll().map { it.toDomain() } } + val settings = it.async { settingsDao.findAll().map { it.toDomain() } } + val transactions = it.async { transactionDao.findAll().map { it.toDomain() } } val sharedPrefs = it.async { getSharedPrefsData() } val gson = GsonBuilder().registerTypeAdapter( @@ -216,20 +217,22 @@ class ExportZipLogic( onProgress: suspend (progressPercent: Double) -> Unit = {} ) { scopedIOThread { - transactionDao.save(completeData.transactions) + transactionDao.save(completeData.transactions.map { it.toEntity() }) onProgress(0.6) - val accounts = it.async { accountDao.save(completeData.accounts) } - val budgets = it.async { budgetDao.save(completeData.budgets) } - val categories = it.async { categoryDao.save(completeData.categories) } + val accounts = it.async { accountDao.save(completeData.accounts.map { it.toEntity() }) } + val budgets = it.async { budgetDao.save(completeData.budgets.map { it.toEntity() }) } + val categories = + it.async { categoryDao.save(completeData.categories.map { it.toEntity() }) } accounts.await() budgets.await() categories.await() onProgress(0.7) - val loans = it.async { loanDao.save(completeData.loans) } - val loanRecords = it.async { loanRecordDao.save(completeData.loanRecords) } + val loans = it.async { loanDao.save(completeData.loans.map { it.toEntity() }) } + val loanRecords = + it.async { loanRecordDao.save(completeData.loanRecords.map { it.toEntity() }) } loans.await() loanRecords.await() @@ -237,10 +240,10 @@ class ExportZipLogic( onProgress(0.8) val plannedPayments = - it.async { plannedPaymentRuleDao.save(completeData.plannedPaymentRules) } + it.async { plannedPaymentRuleDao.save(completeData.plannedPaymentRules.map { it.toEntity() }) } val settings = it.async { settingsDao.deleteAll() - settingsDao.save(completeData.settings) + settingsDao.save(completeData.settings.map { it.toEntity() }) } sharedPrefs.putBoolean( @@ -274,8 +277,8 @@ class ExportZipLogic( completeData: IvyWalletCompleteData ): List> { return scopedIOThread { scope -> - val existingAccountsList = accountDao.findAll() - val existingCategoryList = categoryDao.findAll() + val existingAccountsList = accountDao.findAll().map { it.toDomain() } + val existingCategoryList = categoryDao.findAll().map { it.toDomain() } val backupAccountsList = completeData.accounts val backupCategoryList = completeData.categories diff --git a/app/src/main/java/com/ivy/wallet/domain/pure/charts/WalletCharts.kt b/app/src/main/java/com/ivy/wallet/domain/pure/charts/WalletCharts.kt index e32e1a0cda..633f0fdcc5 100644 --- a/app/src/main/java/com/ivy/wallet/domain/pure/charts/WalletCharts.kt +++ b/app/src/main/java/com/ivy/wallet/domain/pure/charts/WalletCharts.kt @@ -5,7 +5,6 @@ import com.ivy.fp.SideEffect import com.ivy.wallet.domain.pure.data.ClosedTimeRange import com.ivy.wallet.domain.pure.data.IncomeExpensePair import com.ivy.wallet.domain.pure.data.WalletDAOs -import com.ivy.wallet.domain.pure.wallet.calculateWalletIncomeExpense import com.ivy.wallet.utils.beginningOfIvyTime import com.ivy.wallet.utils.toEpochSeconds import java.math.BigDecimal @@ -76,12 +75,13 @@ suspend fun incomeExpenseChart( return generateIncomeExpenseChart( orderedPeriod = orderedPeriod, calculateWalletIncomeExpense = { range -> - calculateWalletIncomeExpense( - walletDAOs = walletDAOs, - baseCurrencyCode = baseCurrencyCode, - range = range, - filterExcluded = true - ).value + TODO() +// calculateWalletIncomeExpense( +// walletDAOs = walletDAOs, +// baseCurrencyCode = baseCurrencyCode, +// range = range, +// filterExcluded = true +// ).value } ) } diff --git a/app/src/main/java/com/ivy/wallet/domain/pure/transaction/TrnDateDividers.kt b/app/src/main/java/com/ivy/wallet/domain/pure/transaction/TrnDateDividers.kt index a8d65c25df..2d34d59d5a 100644 --- a/app/src/main/java/com/ivy/wallet/domain/pure/transaction/TrnDateDividers.kt +++ b/app/src/main/java/com/ivy/wallet/domain/pure/transaction/TrnDateDividers.kt @@ -1,20 +1,46 @@ package com.ivy.wallet.domain.pure.transaction import arrow.core.Option +import arrow.core.toOption import com.ivy.fp.Pure import com.ivy.fp.SideEffect +import com.ivy.fp.then import com.ivy.wallet.domain.data.TransactionHistoryDateDivider import com.ivy.wallet.domain.data.TransactionHistoryItem import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.Transaction +import com.ivy.wallet.domain.deprecated.logic.currency.ExchangeRatesLogic import com.ivy.wallet.domain.pure.exchange.ExchangeData import com.ivy.wallet.domain.pure.exchange.ExchangeTrnArgument import com.ivy.wallet.domain.pure.exchange.exchangeInBaseCurrency +import com.ivy.wallet.io.persistence.dao.AccountDao +import com.ivy.wallet.io.persistence.dao.SettingsDao import com.ivy.wallet.utils.convertUTCtoLocal import com.ivy.wallet.utils.toEpochSeconds import java.math.BigDecimal import java.util.* +@Deprecated("Migrate to actions") +suspend fun List.withDateDividers( + exchangeRatesLogic: ExchangeRatesLogic, + settingsDao: SettingsDao, + accountDao: AccountDao +): List { + return transactionsWithDateDividers( + transactions = this, + baseCurrencyCode = settingsDao.findFirst().currency, + getAccount = accountDao::findById then { it?.toDomain() }, + exchange = { data, amount -> + exchangeRatesLogic.convertAmount( + baseCurrency = data.baseCurrency, + fromCurrency = data.fromCurrency.orNull() ?: "", + toCurrency = data.toCurrency, + amount = amount.toDouble() + ).toBigDecimal().toOption() + } + ) +} + @Pure suspend fun transactionsWithDateDividers( transactions: List, diff --git a/app/src/main/java/com/ivy/wallet/io/network/IvySession.kt b/app/src/main/java/com/ivy/wallet/io/network/IvySession.kt index 5a4da91126..c34c322c24 100644 --- a/app/src/main/java/com/ivy/wallet/io/network/IvySession.kt +++ b/app/src/main/java/com/ivy/wallet/io/network/IvySession.kt @@ -30,7 +30,7 @@ class IvySession( fun initiate(authResponse: AuthResponse) { val user = authResponse.user - userDao.save(user) + userDao.save(user.toEntity()) sharedPrefs.putString(SharedPrefs.SESSION_USER_ID, user.id.toString()) sharedPrefs.putString(SharedPrefs.SESSION_AUTH_TOKEN, authResponse.sessionToken) diff --git a/app/src/main/java/com/ivy/wallet/io/network/RestClient.kt b/app/src/main/java/com/ivy/wallet/io/network/RestClient.kt index 60dc6236f8..5bd80f9e06 100644 --- a/app/src/main/java/com/ivy/wallet/io/network/RestClient.kt +++ b/app/src/main/java/com/ivy/wallet/io/network/RestClient.kt @@ -205,9 +205,6 @@ class RestClient private constructor( } val analyticsService: AnalyticsService by lazy { retrofit.create(AnalyticsService::class.java) } val coinbaseService: CoinbaseService by lazy { retrofit.create(CoinbaseService::class.java) } - val bankIntegrationsService: BankIntegrationsService by lazy { - retrofit.create(BankIntegrationsService::class.java) - } val githubService: GithubService by lazy { retrofit.create(GithubService::class.java) } val nukeService: NukeService by lazy { retrofit.create(NukeService::class.java) } } \ No newline at end of file diff --git a/app/src/main/java/com/ivy/wallet/io/network/service/BankIntegrationsService.kt b/app/src/main/java/com/ivy/wallet/io/network/service/BankIntegrationsService.kt deleted file mode 100644 index b2dbcdb296..0000000000 --- a/app/src/main/java/com/ivy/wallet/io/network/service/BankIntegrationsService.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.ivy.wallet.io.network.service - -import com.ivy.wallet.io.network.request.bankintegrations.BankAccountsResponse -import com.ivy.wallet.io.network.request.bankintegrations.BankConnectionSessionResponse -import com.ivy.wallet.io.network.request.bankintegrations.BankConnectionsResponse -import com.ivy.wallet.io.network.request.bankintegrations.BankTransactionsResponse -import retrofit2.http.DELETE -import retrofit2.http.GET -import retrofit2.http.POST - -interface BankIntegrationsService { - @POST("wallet/bank-integrations/connect") - suspend fun connectSession(): BankConnectionSessionResponse - - @GET("wallet/bank-integrations/connections") - suspend fun getConnections(): BankConnectionsResponse - - @GET("wallet/bank-integrations/accounts") - suspend fun getAccounts(): BankAccountsResponse - - @GET("wallet/bank-integrations/transactions") - suspend fun getTransactions(): BankTransactionsResponse - - @DELETE("wallet/bank-integrations/remove-customer") - suspend fun removeCustomer() -} \ No newline at end of file diff --git a/app/src/main/java/com/ivy/wallet/ui/csvimport/ImportScreen.kt b/app/src/main/java/com/ivy/wallet/ui/csvimport/ImportScreen.kt index da82d745f5..fa7a30423e 100644 --- a/app/src/main/java/com/ivy/wallet/ui/csvimport/ImportScreen.kt +++ b/app/src/main/java/com/ivy/wallet/ui/csvimport/ImportScreen.kt @@ -8,8 +8,8 @@ import androidx.compose.runtime.livedata.observeAsState import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.viewmodel.compose.viewModel -import com.ivy.wallet.domain.logic.csv.model.ImportResult -import com.ivy.wallet.domain.logic.csv.model.ImportType +import com.ivy.wallet.domain.deprecated.logic.csv.model.ImportResult +import com.ivy.wallet.domain.deprecated.logic.csv.model.ImportType import com.ivy.wallet.ui.Import import com.ivy.wallet.ui.IvyWalletPreview import com.ivy.wallet.ui.csvimport.flow.ImportFrom diff --git a/app/src/main/java/com/ivy/wallet/ui/csvimport/flow/ImportFrom.kt b/app/src/main/java/com/ivy/wallet/ui/csvimport/flow/ImportFrom.kt index 560860a1e3..5666223427 100644 --- a/app/src/main/java/com/ivy/wallet/ui/csvimport/flow/ImportFrom.kt +++ b/app/src/main/java/com/ivy/wallet/ui/csvimport/flow/ImportFrom.kt @@ -1,5 +1,6 @@ package com.ivy.wallet.ui.csvimport.flow + import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -21,12 +22,10 @@ import com.google.accompanist.insets.statusBarsPadding import com.ivy.design.api.navigation import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style -import com.ivy.wallet.domain.logic.csv.model.ImportType +import com.ivy.wallet.R +import com.ivy.wallet.domain.deprecated.logic.csv.model.ImportType import com.ivy.wallet.ui.IvyWalletPreview import com.ivy.wallet.ui.onboarding.components.OnboardingToolbar -import com.ivy.wallet.R - - import com.ivy.wallet.ui.theme.components.GradientCutBottom import com.ivy.wallet.ui.theme.components.IvyIcon diff --git a/app/src/main/java/com/ivy/wallet/ui/csvimport/flow/ImportResultUI.kt b/app/src/main/java/com/ivy/wallet/ui/csvimport/flow/ImportResultUI.kt index dd671f5679..8e90c0bb68 100644 --- a/app/src/main/java/com/ivy/wallet/ui/csvimport/flow/ImportResultUI.kt +++ b/app/src/main/java/com/ivy/wallet/ui/csvimport/flow/ImportResultUI.kt @@ -12,14 +12,14 @@ import com.google.accompanist.insets.systemBarsPadding import com.ivy.design.api.navigation import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style -import com.ivy.wallet.domain.logic.csv.model.ImportResult +import com.ivy.wallet.R +import com.ivy.wallet.domain.deprecated.logic.csv.model.ImportResult import com.ivy.wallet.ui.IvyWalletPreview import com.ivy.wallet.ui.theme.* import com.ivy.wallet.ui.theme.components.BackButton import com.ivy.wallet.ui.theme.components.IvyDividerLine import com.ivy.wallet.ui.theme.components.OnboardingButton import com.ivy.wallet.utils.format -import com.ivy.wallet.R @Composable fun ImportResultUI( diff --git a/app/src/main/java/com/ivy/wallet/ui/csvimport/flow/instructions/ImportInstructions.kt b/app/src/main/java/com/ivy/wallet/ui/csvimport/flow/instructions/ImportInstructions.kt index 7c345b65ac..d17772e14d 100644 --- a/app/src/main/java/com/ivy/wallet/ui/csvimport/flow/instructions/ImportInstructions.kt +++ b/app/src/main/java/com/ivy/wallet/ui/csvimport/flow/instructions/ImportInstructions.kt @@ -26,8 +26,7 @@ import com.ivy.design.api.navigation import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style import com.ivy.wallet.R -import com.ivy.wallet.domain.logic.csv.model.ImportType -import com.ivy.wallet.stringRes +import com.ivy.wallet.domain.deprecated.logic.csv.model.ImportType import com.ivy.wallet.ui.IvyWalletPreview import com.ivy.wallet.ui.RootActivity import com.ivy.wallet.ui.onboarding.components.OnboardingToolbar diff --git a/app/src/main/java/com/ivy/wallet/ui/home/CustomerJourney.kt b/app/src/main/java/com/ivy/wallet/ui/home/CustomerJourney.kt index 2579bb6d15..9ffc97c915 100644 --- a/app/src/main/java/com/ivy/wallet/ui/home/CustomerJourney.kt +++ b/app/src/main/java/com/ivy/wallet/ui/home/CustomerJourney.kt @@ -17,8 +17,8 @@ import com.ivy.design.api.navigation import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style import com.ivy.wallet.R -import com.ivy.wallet.domain.logic.CustomerJourneyLogic -import com.ivy.wallet.domain.logic.model.CustomerJourneyCardData +import com.ivy.wallet.domain.deprecated.logic.CustomerJourneyLogic +import com.ivy.wallet.domain.deprecated.logic.model.CustomerJourneyCardData import com.ivy.wallet.ui.IvyWalletComponentPreview import com.ivy.wallet.ui.RootActivity import com.ivy.wallet.ui.ivyWalletCtx diff --git a/app/src/main/java/com/ivy/wallet/ui/loandetails/LoanDetailsScreen.kt b/app/src/main/java/com/ivy/wallet/ui/loandetails/LoanDetailsScreen.kt index 8c80072b46..26c9b9a328 100644 --- a/app/src/main/java/com/ivy/wallet/ui/loandetails/LoanDetailsScreen.kt +++ b/app/src/main/java/com/ivy/wallet/ui/loandetails/LoanDetailsScreen.kt @@ -33,9 +33,9 @@ import com.ivy.wallet.domain.data.TransactionType import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.Loan import com.ivy.wallet.domain.data.core.LoanRecord -import com.ivy.wallet.domain.logic.model.CreateAccountData -import com.ivy.wallet.domain.logic.model.CreateLoanRecordData -import com.ivy.wallet.domain.logic.model.EditLoanRecordData +import com.ivy.wallet.domain.deprecated.logic.model.CreateAccountData +import com.ivy.wallet.domain.deprecated.logic.model.CreateLoanRecordData +import com.ivy.wallet.domain.deprecated.logic.model.EditLoanRecordData import com.ivy.wallet.ui.ItemStatistic import com.ivy.wallet.ui.IvyWalletPreview import com.ivy.wallet.ui.LoanDetails diff --git a/app/src/main/java/com/ivy/wallet/ui/main/MainScreen.kt b/app/src/main/java/com/ivy/wallet/ui/main/MainScreen.kt index beb290d435..c56d23df65 100644 --- a/app/src/main/java/com/ivy/wallet/ui/main/MainScreen.kt +++ b/app/src/main/java/com/ivy/wallet/ui/main/MainScreen.kt @@ -9,7 +9,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.viewmodel.compose.viewModel import com.ivy.design.api.navigation import com.ivy.wallet.domain.data.TransactionType -import com.ivy.wallet.domain.logic.model.CreateAccountData +import com.ivy.wallet.domain.deprecated.logic.model.CreateAccountData import com.ivy.wallet.ui.* import com.ivy.wallet.ui.accounts.AccountsTab import com.ivy.wallet.ui.home.HomeTab diff --git a/app/src/main/java/com/ivy/wallet/ui/onboarding/OnboardingScreen.kt b/app/src/main/java/com/ivy/wallet/ui/onboarding/OnboardingScreen.kt index 458fcd6d93..05cced0598 100644 --- a/app/src/main/java/com/ivy/wallet/ui/onboarding/OnboardingScreen.kt +++ b/app/src/main/java/com/ivy/wallet/ui/onboarding/OnboardingScreen.kt @@ -11,8 +11,8 @@ import androidx.lifecycle.viewmodel.compose.viewModel import com.ivy.wallet.domain.data.IvyCurrency import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.Category -import com.ivy.wallet.domain.logic.model.CreateAccountData -import com.ivy.wallet.domain.logic.model.CreateCategoryData +import com.ivy.wallet.domain.deprecated.logic.model.CreateAccountData +import com.ivy.wallet.domain.deprecated.logic.model.CreateCategoryData import com.ivy.wallet.ui.IvyWalletPreview import com.ivy.wallet.ui.Onboarding import com.ivy.wallet.ui.onboarding.model.AccountBalance diff --git a/app/src/main/java/com/ivy/wallet/ui/onboarding/components/Suggestions.kt b/app/src/main/java/com/ivy/wallet/ui/onboarding/components/Suggestions.kt index 42bd0ace25..01239cf54b 100644 --- a/app/src/main/java/com/ivy/wallet/ui/onboarding/components/Suggestions.kt +++ b/app/src/main/java/com/ivy/wallet/ui/onboarding/components/Suggestions.kt @@ -17,8 +17,8 @@ import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style import com.ivy.wallet.R import com.ivy.wallet.domain.data.core.Account -import com.ivy.wallet.domain.logic.model.CreateAccountData -import com.ivy.wallet.domain.logic.model.CreateCategoryData +import com.ivy.wallet.domain.deprecated.logic.model.CreateAccountData +import com.ivy.wallet.domain.deprecated.logic.model.CreateCategoryData import com.ivy.wallet.ui.IvyWalletComponentPreview import com.ivy.wallet.ui.theme.components.IvyIcon import com.ivy.wallet.ui.theme.components.WrapContentRow diff --git a/app/src/main/java/com/ivy/wallet/ui/onboarding/steps/OnboardingAccounts.kt b/app/src/main/java/com/ivy/wallet/ui/onboarding/steps/OnboardingAccounts.kt index 20b4cba285..cb68f637ad 100644 --- a/app/src/main/java/com/ivy/wallet/ui/onboarding/steps/OnboardingAccounts.kt +++ b/app/src/main/java/com/ivy/wallet/ui/onboarding/steps/OnboardingAccounts.kt @@ -23,7 +23,7 @@ import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style import com.ivy.wallet.R import com.ivy.wallet.domain.data.core.Account -import com.ivy.wallet.domain.logic.model.CreateAccountData +import com.ivy.wallet.domain.deprecated.logic.model.CreateAccountData import com.ivy.wallet.ui.IvyWalletPreview import com.ivy.wallet.ui.Paywall import com.ivy.wallet.ui.ivyWalletCtx diff --git a/app/src/main/java/com/ivy/wallet/ui/onboarding/steps/OnboardingCategories.kt b/app/src/main/java/com/ivy/wallet/ui/onboarding/steps/OnboardingCategories.kt index f54d41288e..345e4ed417 100644 --- a/app/src/main/java/com/ivy/wallet/ui/onboarding/steps/OnboardingCategories.kt +++ b/app/src/main/java/com/ivy/wallet/ui/onboarding/steps/OnboardingCategories.kt @@ -26,7 +26,7 @@ import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style import com.ivy.wallet.R import com.ivy.wallet.domain.data.core.Category -import com.ivy.wallet.domain.logic.model.CreateCategoryData +import com.ivy.wallet.domain.deprecated.logic.model.CreateCategoryData import com.ivy.wallet.ui.IvyWalletPreview import com.ivy.wallet.ui.onboarding.components.OnboardingProgressSlider import com.ivy.wallet.ui.onboarding.components.OnboardingToolbar diff --git a/app/src/main/java/com/ivy/wallet/ui/onboarding/viewmodel/OnboardingRouter.kt b/app/src/main/java/com/ivy/wallet/ui/onboarding/viewmodel/OnboardingRouter.kt index d1a1b86fb7..0c24b9a501 100644 --- a/app/src/main/java/com/ivy/wallet/ui/onboarding/viewmodel/OnboardingRouter.kt +++ b/app/src/main/java/com/ivy/wallet/ui/onboarding/viewmodel/OnboardingRouter.kt @@ -5,13 +5,13 @@ import com.ivy.design.navigation.Navigation import com.ivy.wallet.domain.data.IvyCurrency import com.ivy.wallet.domain.data.analytics.AnalyticsEvent import com.ivy.wallet.domain.data.core.Category -import com.ivy.wallet.domain.logic.LogoutLogic -import com.ivy.wallet.domain.logic.PreloadDataLogic -import com.ivy.wallet.domain.logic.currency.ExchangeRatesLogic -import com.ivy.wallet.domain.logic.model.CreateAccountData -import com.ivy.wallet.domain.logic.model.CreateCategoryData -import com.ivy.wallet.domain.logic.notification.TransactionReminderLogic -import com.ivy.wallet.domain.sync.IvySync +import com.ivy.wallet.domain.deprecated.logic.LogoutLogic +import com.ivy.wallet.domain.deprecated.logic.PreloadDataLogic +import com.ivy.wallet.domain.deprecated.logic.currency.ExchangeRatesLogic +import com.ivy.wallet.domain.deprecated.logic.model.CreateAccountData +import com.ivy.wallet.domain.deprecated.logic.model.CreateCategoryData +import com.ivy.wallet.domain.deprecated.logic.notification.TransactionReminderLogic +import com.ivy.wallet.domain.deprecated.sync.IvySync import com.ivy.wallet.io.network.IvyAnalytics import com.ivy.wallet.io.persistence.SharedPrefs import com.ivy.wallet.io.persistence.dao.AccountDao @@ -246,7 +246,7 @@ class OnboardingRouter( } private suspend fun routeToCategories() { - _categories.value = ioThread { categoryDao.findAll() }!! + _categories.value = ioThread { categoryDao.findAll().map { it.toDomain() } }!! _categorySuggestions.value = preloadDataLogic.categorySuggestions() _state.value = OnboardingState.CATEGORIES diff --git a/app/src/main/java/com/ivy/wallet/ui/planned/edit/EditPlannedScreen.kt b/app/src/main/java/com/ivy/wallet/ui/planned/edit/EditPlannedScreen.kt index f4bcd457dd..5c59e1b4d1 100644 --- a/app/src/main/java/com/ivy/wallet/ui/planned/edit/EditPlannedScreen.kt +++ b/app/src/main/java/com/ivy/wallet/ui/planned/edit/EditPlannedScreen.kt @@ -21,8 +21,8 @@ import com.ivy.wallet.domain.data.IntervalType import com.ivy.wallet.domain.data.TransactionType import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.Category -import com.ivy.wallet.domain.logic.model.CreateAccountData -import com.ivy.wallet.domain.logic.model.CreateCategoryData +import com.ivy.wallet.domain.deprecated.logic.model.CreateAccountData +import com.ivy.wallet.domain.deprecated.logic.model.CreateCategoryData import com.ivy.wallet.ui.EditPlanned import com.ivy.wallet.ui.IvyWalletPreview import com.ivy.wallet.ui.edit.core.* diff --git a/app/src/main/java/com/ivy/wallet/ui/statistic/level2/ItemStatisticViewModel.kt b/app/src/main/java/com/ivy/wallet/ui/statistic/level2/ItemStatisticViewModel.kt index ff90c17f5d..82f18a1d65 100644 --- a/app/src/main/java/com/ivy/wallet/ui/statistic/level2/ItemStatisticViewModel.kt +++ b/app/src/main/java/com/ivy/wallet/ui/statistic/level2/ItemStatisticViewModel.kt @@ -4,7 +4,16 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import arrow.core.toOption import com.ivy.design.navigation.Navigation +import com.ivy.fp.action.then import com.ivy.wallet.R +import com.ivy.wallet.domain.action.account.AccTrnsAct +import com.ivy.wallet.domain.action.account.AccountsAct +import com.ivy.wallet.domain.action.account.CalcAccBalanceAct +import com.ivy.wallet.domain.action.account.CalcAccIncomeExpenseAct +import com.ivy.wallet.domain.action.category.CategoriesAct +import com.ivy.wallet.domain.action.exchange.ExchangeAct +import com.ivy.wallet.domain.action.settings.BaseCurrencyAct +import com.ivy.wallet.domain.action.transaction.TrnsWithDateDivsAct import com.ivy.wallet.domain.data.TransactionHistoryItem import com.ivy.wallet.domain.data.TransactionType import com.ivy.wallet.domain.data.core.Account @@ -14,11 +23,8 @@ import com.ivy.wallet.domain.deprecated.logic.* import com.ivy.wallet.domain.deprecated.logic.currency.ExchangeRatesLogic import com.ivy.wallet.domain.deprecated.sync.uploader.AccountUploader import com.ivy.wallet.domain.deprecated.sync.uploader.CategoryUploader -import com.ivy.wallet.domain.pure.account.calculateAccountBalance -import com.ivy.wallet.domain.pure.account.calculateAccountIncomeExpense import com.ivy.wallet.domain.pure.data.WalletDAOs -import com.ivy.wallet.domain.pure.wallet.baseCurrencyCode -import com.ivy.wallet.domain.pure.wallet.withDateDividers +import com.ivy.wallet.domain.pure.exchange.ExchangeData import com.ivy.wallet.io.persistence.dao.* import com.ivy.wallet.stringRes import com.ivy.wallet.ui.ItemStatistic @@ -51,6 +57,14 @@ class ItemStatisticViewModel @Inject constructor( private val accountCreator: AccountCreator, private val plannedPaymentsLogic: PlannedPaymentsLogic, private val exchangeRatesLogic: ExchangeRatesLogic, + private val categoriesAct: CategoriesAct, + private val accountsAct: AccountsAct, + private val accTrnsAct: AccTrnsAct, + private val trnsWithDateDivsAct: TrnsWithDateDivsAct, + private val baseCurrencyAct: BaseCurrencyAct, + private val calcAccBalanceAct: CalcAccBalanceAct, + private val calcAccIncomeExpenseAct: CalcAccIncomeExpenseAct, + private val exchangeAct: ExchangeAct ) : ViewModel() { private val _period = MutableStateFlow(ivyContext.selectedPeriod) @@ -133,12 +147,12 @@ class ItemStatisticViewModel @Inject constructor( viewModelScope.launch { _period.value = period ?: ivyContext.selectedPeriod - val baseCurrency = ioThread { baseCurrencyCode(settingsDao) } + val baseCurrency = baseCurrencyAct(Unit) _baseCurrency.value = baseCurrency _currency.value = baseCurrency - _categories.value = ioThread { categoryDao.findAll() } - _accounts.value = ioThread { accountDao.findAll() } + _categories.value = categoriesAct(Unit) + _accounts.value = accountsAct(Unit) _initWithTransactions.value = false when { @@ -176,7 +190,7 @@ class ItemStatisticViewModel @Inject constructor( private suspend fun initForAccount(accountId: UUID) { val account = ioThread { - accountDao.findById(accountId) ?: error("account not found") + accountDao.findById(accountId)?.toDomain() ?: error("account not found") } _account.value = account val range = period.value.toRange(ivyContext.startDayOfMonth) @@ -185,37 +199,46 @@ class ItemStatisticViewModel @Inject constructor( _currency.value = account.currency!! } - val balance = ioThread { - calculateAccountBalance( - transactionDao = walletDAOs.transactionDao, - accountId = accountId - ).toDouble() - } + val balance = calcAccBalanceAct( + CalcAccBalanceAct.Input( + account = account + ) + ).balance.toDouble() _balance.value = balance if (baseCurrency.value != currency.value) { - _balanceBaseCurrency.value = ioThread { - exchangeToBaseCurrency( - exchangeRateDao = exchangeRateDao, - baseCurrencyCode = baseCurrency.value, - fromCurrencyCode = currency.value.toOption(), - fromAmount = balance.toBigDecimal() - ).orNull()?.toDouble() - } + _balanceBaseCurrency.value = exchangeAct( + ExchangeAct.Input( + data = ExchangeData( + baseCurrency = baseCurrency.value, + fromCurrency = currency.value.toOption() + ), + amount = balance.toBigDecimal() + ) + ).orNull()?.toDouble() } - val incomeExpensePair = ioThread { - calculateAccountIncomeExpense( - transactionDao = transactionDao, - accountId = accountId, + val incomeExpensePair = calcAccIncomeExpenseAct( + CalcAccIncomeExpenseAct.Input( + account = account, range = range.toCloseTimeRange() ) - } + ).incomeExpensePair _income.value = incomeExpensePair.income.toDouble() _expenses.value = incomeExpensePair.expense.toDouble() - _history.value = ioThread { - accountLogic.historyForAccount(account, range) - } + _history.value = (accTrnsAct then { + trnsWithDateDivsAct( + TrnsWithDateDivsAct.Input( + baseCurrency = baseCurrency.value, + transactions = it + ) + ) + })( + AccTrnsAct.Input( + accountId = account.id, + range = range.toCloseTimeRange() + ) + ) //Upcoming _upcomingIncome.value = ioThread { @@ -243,7 +266,7 @@ class ItemStatisticViewModel @Inject constructor( private suspend fun initForCategory(categoryId: UUID, accountFilterList: List) { val accountFilterSet = accountFilterList.toSet() val category = ioThread { - categoryDao.findById(categoryId) ?: error("category not found") + categoryDao.findById(categoryId)?.toDomain() ?: error("category not found") } _category.value = category val range = period.value.toRange(ivyContext.startDayOfMonth) @@ -307,7 +330,7 @@ class ItemStatisticViewModel @Inject constructor( val accountFilterSet = accountFilterList.toSet() val category = ioThread { - categoryDao.findById(categoryId) ?: error("category not found") + categoryDao.findById(categoryId)?.toDomain() ?: error("category not found") } _category.value = category val range = period.value.toRange(ivyContext.startDayOfMonth) @@ -464,22 +487,21 @@ class ItemStatisticViewModel @Inject constructor( _income.value - _expenses.value + if (accountTransferCategoryEnabled) trans.filter { it.type == TransactionType.TRANSFER } - .sumOf { - exchangeRatesLogic.toAmountBaseCurrency( - transaction = it, - baseCurrency = baseCurrency.value, - accounts = walletDAOs.accountDao.findAll() - ) - } else 0.0 - } - - _history.value = ioThread { - trans.withDateDividers( - exchangeRateDao = exchangeRateDao, - accountDao = walletDAOs.accountDao, - baseCurrencyCode = baseCurrency.value + .sumOf { + exchangeRatesLogic.toAmountBaseCurrency( + transaction = it, + baseCurrency = baseCurrency.value, + accounts = accountsAct(Unit) + ) + } else 0.0 + } + + _history.value = trnsWithDateDivsAct( + TrnsWithDateDivsAct.Input( + baseCurrency = baseCurrency.value, + transactions = transactions ) - } + ) } private fun reset() { diff --git a/app/src/main/java/com/ivy/wallet/ui/theme/modal/BudgetModal.kt b/app/src/main/java/com/ivy/wallet/ui/theme/modal/BudgetModal.kt index c5e9b2d256..53dfa94db7 100644 --- a/app/src/main/java/com/ivy/wallet/ui/theme/modal/BudgetModal.kt +++ b/app/src/main/java/com/ivy/wallet/ui/theme/modal/BudgetModal.kt @@ -26,7 +26,7 @@ import com.ivy.design.l0_system.style import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.Budget import com.ivy.wallet.domain.data.core.Category -import com.ivy.wallet.domain.logic.model.CreateBudgetData +import com.ivy.wallet.domain.deprecated.logic.model.CreateBudgetData import com.ivy.wallet.ui.IvyWalletPreview import com.ivy.wallet.ui.reports.ListItem import com.ivy.wallet.ui.theme.Green diff --git a/app/src/main/java/com/ivy/wallet/ui/theme/modal/LoanModal.kt b/app/src/main/java/com/ivy/wallet/ui/theme/modal/LoanModal.kt index 7427b67ad8..42e88a716b 100644 --- a/app/src/main/java/com/ivy/wallet/ui/theme/modal/LoanModal.kt +++ b/app/src/main/java/com/ivy/wallet/ui/theme/modal/LoanModal.kt @@ -28,8 +28,8 @@ import com.ivy.wallet.domain.data.IvyCurrency import com.ivy.wallet.domain.data.LoanType import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.Loan -import com.ivy.wallet.domain.logic.model.CreateAccountData -import com.ivy.wallet.domain.logic.model.CreateLoanData +import com.ivy.wallet.domain.deprecated.logic.model.CreateAccountData +import com.ivy.wallet.domain.deprecated.logic.model.CreateLoanData import com.ivy.wallet.ui.IvyWalletPreview import com.ivy.wallet.ui.theme.* import com.ivy.wallet.ui.theme.components.ItemIconSDefaultIcon diff --git a/app/src/main/java/com/ivy/wallet/ui/theme/modal/LoanRecordModal.kt b/app/src/main/java/com/ivy/wallet/ui/theme/modal/LoanRecordModal.kt index 7b4836dee7..5c1e38fe50 100644 --- a/app/src/main/java/com/ivy/wallet/ui/theme/modal/LoanRecordModal.kt +++ b/app/src/main/java/com/ivy/wallet/ui/theme/modal/LoanRecordModal.kt @@ -23,9 +23,9 @@ import com.ivy.design.l0_system.style import com.ivy.wallet.R import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.LoanRecord -import com.ivy.wallet.domain.logic.model.CreateAccountData -import com.ivy.wallet.domain.logic.model.CreateLoanRecordData -import com.ivy.wallet.domain.logic.model.EditLoanRecordData +import com.ivy.wallet.domain.deprecated.logic.model.CreateAccountData +import com.ivy.wallet.domain.deprecated.logic.model.CreateLoanRecordData +import com.ivy.wallet.domain.deprecated.logic.model.EditLoanRecordData import com.ivy.wallet.ui.IvyWalletPreview import com.ivy.wallet.ui.ivyWalletCtx import com.ivy.wallet.ui.theme.components.ItemIconSDefaultIcon diff --git a/app/src/main/java/com/ivy/wallet/ui/theme/transaction/TransactionCard.kt b/app/src/main/java/com/ivy/wallet/ui/theme/transaction/TransactionCard.kt index b5cc9acf71..ececf3fe25 100644 --- a/app/src/main/java/com/ivy/wallet/ui/theme/transaction/TransactionCard.kt +++ b/app/src/main/java/com/ivy/wallet/ui/theme/transaction/TransactionCard.kt @@ -140,13 +140,13 @@ fun LazyItemScope.TransactionCard( transactionType = transaction.type, dueDate = transaction.dueDate, currency = transactionCurrency, - amount = transaction.amount + amount = transaction.amount.toDouble() ) if (transaction.type == TransactionType.TRANSFER && transaction.toAmount != null && toAccountCurrency != transactionCurrency) { Text( modifier = Modifier.padding(start = 68.dp), - text = "${transaction.toAmount.format(2)} $toAccountCurrency", + text = "${transaction.toAmount.toDouble().format(2)} $toAccountCurrency", style = UI.typo.nB2.style( color = Gray, fontWeight = FontWeight.Normal @@ -427,7 +427,7 @@ private fun PreviewUpcomingExpense() { accountId = cash.id, title = "Lidl pazar", categoryId = food.id, - amount = 250.75, + amount = 250.75.toBigDecimal(), dueDate = timeNowUTC().plusDays(5), dateTime = null, type = TransactionType.EXPENSE, @@ -458,7 +458,7 @@ private fun PreviewOverdueExpense() { accountId = cash.id, title = "Rent", categoryId = food.id, - amount = 500.0, + amount = 500.0.toBigDecimal(), dueDate = timeNowUTC().minusDays(5), dateTime = null, type = TransactionType.EXPENSE @@ -493,7 +493,7 @@ private fun PreviewNormalExpense() { accountId = cash.id, title = "Близкия магазин", categoryId = food.id, - amount = 32.51, + amount = 32.51.toBigDecimal(), dateTime = timeNowUTC(), type = TransactionType.EXPENSE ), @@ -522,7 +522,7 @@ private fun PreviewIncome() { accountId = cash.id, title = "Qredo Salary May", categoryId = category.id, - amount = 8049.70, + amount = 8049.70.toBigDecimal(), dateTime = timeNowUTC(), type = TransactionType.INCOME ), @@ -552,7 +552,7 @@ private fun PreviewTransfer() { accountId = acc1.id, toAccountId = acc2.id, title = "Top-up revolut", - amount = 1000.0, + amount = 1000.0.toBigDecimal(), dateTime = timeNowUTC(), type = TransactionType.TRANSFER ),