Skip to content

Commit

Permalink
Transfer transaction is missed in the export csv file and added the t…
Browse files Browse the repository at this point in the history
…ransaction type in the export as a separate column
  • Loading branch information
nkuppan committed Jan 26, 2025
1 parent f54d657 commit e2eb40d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.os.Environment
import android.util.Log
import androidx.core.net.toUri
import com.naveenapps.expensemanager.core.common.utils.AppCoroutineDispatchers
import com.naveenapps.expensemanager.core.common.utils.toCapitalize
import com.naveenapps.expensemanager.core.common.utils.toCompleteDate
import com.naveenapps.expensemanager.core.common.utils.toTimeAndMinutes
import com.naveenapps.expensemanager.core.data.R
Expand Down Expand Up @@ -45,6 +46,7 @@ class ExportRepositoryImpl @Inject constructor(
context.getString(R.string.category),
context.getString(R.string.from_account),
context.getString(R.string.to_account),
context.getString(R.string.transaction_type),
context.getString(R.string.notes),
context.getString(R.string.amount),
),
Expand All @@ -58,6 +60,7 @@ class ExportRepositoryImpl @Inject constructor(
transaction.category.name,
transaction.fromAccount.name,
transaction.toAccount?.name ?: "",
transaction.type.toCapitalize(),
transaction.notes,
transaction.amount.amount.toTrimAmount(),
),
Expand Down
1 change: 1 addition & 0 deletions core/data/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<string name="month">Month</string>
<string name="from_account">From Account</string>
<string name="to_account">To Account</string>
<string name="transaction_type">Transaction Type</string>

<string name="light">Light</string>
<string name="dark">Dark</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.naveenapps.expensemanager.core.domain.usecase.transaction

import com.naveenapps.expensemanager.core.domain.usecase.settings.filter.daterange.GetDateRangeByTypeUseCase
import com.naveenapps.expensemanager.core.model.CategoryType
import com.naveenapps.expensemanager.core.model.DateRangeType
import com.naveenapps.expensemanager.core.model.Resource
import com.naveenapps.expensemanager.core.model.Transaction
import com.naveenapps.expensemanager.core.model.TransactionType
import kotlinx.coroutines.flow.firstOrNull
import javax.inject.Inject

Expand All @@ -31,13 +31,21 @@ class GetExportTransactionsUseCase @Inject constructor(

val dateRanges = getDateRangeByTypeUseCase.invoke(dateRangeType)

val transaction = transactionRepository.getFilteredTransaction(
accounts = accounts,
categories = categories,
transactionType = CategoryType.entries.map { it.ordinal }.toList(),
startDate = dateRanges.dateRanges[0],
endDate = dateRanges.dateRanges[1],
).firstOrNull()
val transaction = if (dateRanges.type == DateRangeType.ALL) {
transactionRepository.getAllFilteredTransaction(
accounts = accounts,
categories = categories,
transactionType = TransactionType.entries.map { it.ordinal }.toList(),
).firstOrNull()
} else {
transactionRepository.getFilteredTransaction(
accounts = accounts,
categories = categories,
transactionType = TransactionType.entries.map { it.ordinal }.toList(),
startDate = dateRanges.dateRanges[0],
endDate = dateRanges.dateRanges[1],
).firstOrNull()
}

return Resource.Success(transaction ?: emptyList())
}
Expand Down

0 comments on commit e2eb40d

Please sign in to comment.