Skip to content

Commit

Permalink
refactor: [database.savings] dbflow to room (#2317)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsPronay authored Feb 24, 2025
1 parent 03afe29 commit 8001c33
Show file tree
Hide file tree
Showing 54 changed files with 980 additions and 1,029 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.savings.SavingsAccountTransactionRequest
import com.mifos.core.entity.client.ClientPayload
import com.mifos.room.entities.accounts.loans.LoanRepaymentRequest
import com.mifos.room.entities.accounts.savings.SavingsAccountTransactionRequest
import com.mifos.room.entities.center.CenterPayload
import com.mifos.room.entities.group.GroupPayload
import kotlinx.coroutines.flow.Flow
Expand All @@ -30,5 +30,5 @@ interface OfflineDashboardRepository {

fun databaseLoanRepayments(): Flow<List<LoanRepaymentRequest>>

fun allSavingsAccountTransactions(): Observable<List<SavingsAccountTransactionRequest>>
fun allSavingsAccountTransactions(): Flow<List<SavingsAccountTransactionRequest>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.savings.SavingsAccountWithAssociations
import rx.Observable
import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociations
import kotlinx.coroutines.flow.Flow

/**
* Created by Aditya Gupta on 08/08/23.
Expand All @@ -21,5 +21,5 @@ interface SavingsAccountSummaryRepository {
type: String?,
savingsAccountId: Int,
association: String?,
): Observable<SavingsAccountWithAssociations>
): Flow<SavingsAccountWithAssociations?>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.savings.SavingsAccountTransactionRequest
import com.mifos.core.entity.templates.savings.SavingsAccountTransactionTemplate
import com.mifos.core.objects.account.saving.SavingsAccountTransactionResponse
import rx.Observable
import com.mifos.core.model.objects.account.saving.SavingsAccountTransactionResponse
import com.mifos.room.entities.accounts.savings.SavingsAccountTransactionRequest
import com.mifos.room.entities.templates.savings.SavingsAccountTransactionTemplate
import kotlinx.coroutines.flow.Flow

/**
* Created by Aditya Gupta on 13/08/23.
Expand All @@ -23,16 +23,14 @@ interface SavingsAccountTransactionRepository {
type: String?,
savingsAccountId: Int,
transactionType: String?,
): Observable<SavingsAccountTransactionTemplate>
): Flow<SavingsAccountTransactionTemplate?>

fun processTransaction(
savingsAccountType: String?,
savingsAccountId: Int,
transactionType: String?,
request: SavingsAccountTransactionRequest,
): Observable<SavingsAccountTransactionResponse>
): Flow<SavingsAccountTransactionResponse?>

fun getSavingsAccountTransaction(
savingAccountId: Int,
): Observable<SavingsAccountTransactionRequest>
fun getSavingsAccountTransaction(savingAccountId: Int): Flow<SavingsAccountTransactionRequest?>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.savings.SavingsAccountWithAssociations
import com.mifos.core.entity.client.Client
import com.mifos.core.entity.templates.savings.SavingsAccountTransactionTemplate
import com.mifos.room.entities.accounts.CenterAccounts
import com.mifos.room.entities.accounts.ClientAccounts
import com.mifos.room.entities.accounts.GroupAccounts
import com.mifos.room.entities.accounts.loans.LoanWithAssociations
import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociations
import com.mifos.room.entities.group.Center
import com.mifos.room.entities.group.CenterWithAssociations
import com.mifos.room.entities.group.Group
import com.mifos.room.entities.group.GroupWithAssociations
import com.mifos.room.entities.templates.loans.LoanRepaymentTemplate
import com.mifos.room.entities.templates.savings.SavingsAccountTransactionTemplate
import kotlinx.coroutines.flow.Flow
import rx.Observable

Expand Down Expand Up @@ -53,11 +53,11 @@ interface SyncCentersDialogRepository {
type: String?,
savingsAccountId: Int,
association: String?,
): Observable<SavingsAccountWithAssociations>
): Flow<SavingsAccountWithAssociations>

fun syncSavingsAccountTransactionTemplate(
savingsAccountType: String?,
savingsAccountId: Int,
transactionType: String?,
): Observable<SavingsAccountTransactionTemplate>
): Flow<SavingsAccountTransactionTemplate>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.savings.SavingsAccountWithAssociations
import com.mifos.core.entity.client.Client
import com.mifos.core.entity.templates.savings.SavingsAccountTransactionTemplate
import com.mifos.room.entities.accounts.ClientAccounts
import com.mifos.room.entities.accounts.loans.LoanWithAssociations
import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociations
import com.mifos.room.entities.templates.loans.LoanRepaymentTemplate
import com.mifos.room.entities.templates.savings.SavingsAccountTransactionTemplate
import kotlinx.coroutines.flow.Flow
import rx.Observable

Expand All @@ -33,13 +33,13 @@ interface SyncClientsDialogRepository {
type: String?,
savingsAccountId: Int,
association: String?,
): Observable<SavingsAccountWithAssociations>
): Flow<SavingsAccountWithAssociations>

fun syncSavingsAccountTransactionTemplate(
savingsAccountType: String?,
savingsAccountId: Int,
transactionType: String?,
): Observable<SavingsAccountTransactionTemplate>
): Flow<SavingsAccountTransactionTemplate?>

fun syncClientInDatabase(client: Client): Observable<Client>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.savings.SavingsAccountWithAssociations
import com.mifos.core.entity.client.Client
import com.mifos.core.entity.templates.savings.SavingsAccountTransactionTemplate
import com.mifos.room.entities.accounts.ClientAccounts
import com.mifos.room.entities.accounts.GroupAccounts
import com.mifos.room.entities.accounts.loans.LoanWithAssociations
import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociations
import com.mifos.room.entities.group.Group
import com.mifos.room.entities.group.GroupWithAssociations
import com.mifos.room.entities.templates.loans.LoanRepaymentTemplate
import com.mifos.room.entities.templates.savings.SavingsAccountTransactionTemplate
import kotlinx.coroutines.flow.Flow
import rx.Observable

Expand All @@ -36,13 +36,13 @@ interface SyncGroupsDialogRepository {
type: String?,
savingsAccountId: Int,
association: String?,
): Observable<SavingsAccountWithAssociations>
): Flow<SavingsAccountWithAssociations>

fun syncSavingsAccountTransactionTemplate(
savingsAccountType: String?,
savingsAccountId: Int,
transactionType: String?,
): Observable<SavingsAccountTransactionTemplate>
): Flow<SavingsAccountTransactionTemplate?>

fun getGroupWithAssociations(groupId: Int): Observable<GroupWithAssociations>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.savings.SavingsAccountTransactionRequest
import com.mifos.core.objects.account.saving.SavingsAccountTransactionResponse
import com.mifos.core.model.objects.account.saving.SavingsAccountTransactionResponse
import com.mifos.room.entities.PaymentTypeOption
import com.mifos.room.entities.accounts.savings.SavingsAccountTransactionRequest
import kotlinx.coroutines.flow.Flow
import rx.Observable

/**
* Created by Aditya Gupta on 16/08/23.
*/
interface SyncSavingsAccountTransactionRepository {

fun allSavingsAccountTransactions(): Observable<List<SavingsAccountTransactionRequest>>
fun allSavingsAccountTransactions(): Flow<List<SavingsAccountTransactionRequest>>

fun paymentTypeOption(): Flow<List<PaymentTypeOption>>

Expand All @@ -29,13 +28,9 @@ interface SyncSavingsAccountTransactionRepository {
savingsAccountId: Int,
transactionType: String?,
request: SavingsAccountTransactionRequest,
): Observable<SavingsAccountTransactionResponse>
): Flow<SavingsAccountTransactionResponse?>

fun deleteAndUpdateTransactions(
savingsAccountId: Int,
): Observable<List<SavingsAccountTransactionRequest>>
fun deleteAndUpdateTransactions(savingsAccountId: Int): Flow<List<SavingsAccountTransactionRequest>>

fun updateLoanRepaymentTransaction(
savingsAccountTransactionRequest: SavingsAccountTransactionRequest,
): Observable<SavingsAccountTransactionRequest>
suspend fun updateLoanRepaymentTransaction(savingsAccountTransactionRequest: SavingsAccountTransactionRequest)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.OfflineDashboardRepository
import com.mifos.core.entity.accounts.savings.SavingsAccountTransactionRequest
import com.mifos.core.entity.client.ClientPayload
import com.mifos.core.network.datamanager.DataManagerCenter
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.network.datamanager.DataManagerGroups
import com.mifos.core.network.datamanager.DataManagerLoan
import com.mifos.core.network.datamanager.DataManagerSavings
import com.mifos.room.entities.accounts.loans.LoanRepaymentRequest
import com.mifos.room.entities.accounts.savings.SavingsAccountTransactionRequest
import com.mifos.room.entities.center.CenterPayload
import com.mifos.room.entities.group.GroupPayload
import kotlinx.coroutines.flow.Flow
Expand Down Expand Up @@ -51,7 +51,7 @@ class OfflineDashboardRepositoryImp @Inject constructor(
return dataManagerLoan.databaseLoanRepayments
}

override fun allSavingsAccountTransactions(): Observable<List<SavingsAccountTransactionRequest>> {
override fun allSavingsAccountTransactions(): Flow<List<SavingsAccountTransactionRequest>> {
return dataManagerSavings.allSavingsAccountTransactions
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@
package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.SavingsAccountSummaryRepository
import com.mifos.core.entity.accounts.savings.SavingsAccountWithAssociations
import com.mifos.core.network.datamanager.DataManagerSavings
import rx.Observable
import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociations
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

/**
* Created by Aditya Gupta on 08/08/23.
*/
class SavingsAccountSummaryRepositoryImp @Inject constructor(private val dataManagerSavings: DataManagerSavings) :
SavingsAccountSummaryRepository {
class SavingsAccountSummaryRepositoryImp @Inject constructor(
private val dataManagerSavings: DataManagerSavings,
) : SavingsAccountSummaryRepository {

override fun getSavingsAccount(
type: String?,
savingsAccountId: Int,
association: String?,
): Observable<SavingsAccountWithAssociations> {
): Flow<SavingsAccountWithAssociations?> {
return dataManagerSavings.getSavingsAccount(type, savingsAccountId, association)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@
package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.SavingsAccountTransactionRepository
import com.mifos.core.entity.accounts.savings.SavingsAccountTransactionRequest
import com.mifos.core.entity.templates.savings.SavingsAccountTransactionTemplate
import com.mifos.core.model.objects.account.saving.SavingsAccountTransactionResponse
import com.mifos.core.network.datamanager.DataManagerSavings
import com.mifos.core.objects.account.saving.SavingsAccountTransactionResponse
import rx.Observable
import com.mifos.room.entities.accounts.savings.SavingsAccountTransactionRequest
import com.mifos.room.entities.templates.savings.SavingsAccountTransactionTemplate
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

/**
* Created by Aditya Gupta on 13/08/23.
*/
class SavingsAccountTransactionRepositoryImp @Inject constructor(private val dataManagerSavings: DataManagerSavings) :
SavingsAccountTransactionRepository {
class SavingsAccountTransactionRepositoryImp @Inject constructor(
private val dataManagerSavings: DataManagerSavings,
) : SavingsAccountTransactionRepository {

override fun getSavingsAccountTransactionTemplate(
type: String?,
savingsAccountId: Int,
transactionType: String?,
): Observable<SavingsAccountTransactionTemplate> {
): Flow<SavingsAccountTransactionTemplate?> {
return dataManagerSavings.getSavingsAccountTransactionTemplate(
type,
savingsAccountId,
Expand All @@ -40,7 +41,7 @@ class SavingsAccountTransactionRepositoryImp @Inject constructor(private val dat
savingsAccountId: Int,
transactionType: String?,
request: SavingsAccountTransactionRequest,
): Observable<SavingsAccountTransactionResponse> {
): Flow<SavingsAccountTransactionResponse?> {
return dataManagerSavings.processTransaction(
savingsAccountType,
savingsAccountId,
Expand All @@ -49,7 +50,7 @@ class SavingsAccountTransactionRepositoryImp @Inject constructor(private val dat
)
}

override fun getSavingsAccountTransaction(savingAccountId: Int): Observable<SavingsAccountTransactionRequest> {
override fun getSavingsAccountTransaction(savingAccountId: Int): Flow<SavingsAccountTransactionRequest?> {
return dataManagerSavings.getSavingsAccountTransaction(savingAccountId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.SyncCentersDialogRepository
import com.mifos.core.entity.accounts.savings.SavingsAccountWithAssociations
import com.mifos.core.entity.client.Client
import com.mifos.core.entity.templates.savings.SavingsAccountTransactionTemplate
import com.mifos.core.network.datamanager.DataManagerCenter
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.network.datamanager.DataManagerGroups
Expand All @@ -22,11 +20,13 @@ import com.mifos.room.entities.accounts.CenterAccounts
import com.mifos.room.entities.accounts.ClientAccounts
import com.mifos.room.entities.accounts.GroupAccounts
import com.mifos.room.entities.accounts.loans.LoanWithAssociations
import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociations
import com.mifos.room.entities.group.Center
import com.mifos.room.entities.group.CenterWithAssociations
import com.mifos.room.entities.group.Group
import com.mifos.room.entities.group.GroupWithAssociations
import com.mifos.room.entities.templates.loans.LoanRepaymentTemplate
import com.mifos.room.entities.templates.savings.SavingsAccountTransactionTemplate
import kotlinx.coroutines.flow.Flow
import rx.Observable
import javax.inject.Inject
Expand Down Expand Up @@ -86,15 +86,15 @@ class SyncCentersDialogRepositoryImp @Inject constructor(
type: String?,
savingsAccountId: Int,
association: String?,
): Observable<SavingsAccountWithAssociations> {
): Flow<SavingsAccountWithAssociations> {
return dataManagerSavings.syncSavingsAccount(type, savingsAccountId, association)
}

override fun syncSavingsAccountTransactionTemplate(
savingsAccountType: String?,
savingsAccountId: Int,
transactionType: String?,
): Observable<SavingsAccountTransactionTemplate> {
): Flow<SavingsAccountTransactionTemplate> {
return dataManagerSavings.syncSavingsAccountTransactionTemplate(
savingsAccountType,
savingsAccountId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.SyncClientsDialogRepository
import com.mifos.core.entity.accounts.savings.SavingsAccountWithAssociations
import com.mifos.core.entity.client.Client
import com.mifos.core.entity.templates.savings.SavingsAccountTransactionTemplate
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.network.datamanager.DataManagerLoan
import com.mifos.core.network.datamanager.DataManagerSavings
import com.mifos.room.entities.accounts.ClientAccounts
import com.mifos.room.entities.accounts.loans.LoanWithAssociations
import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociations
import com.mifos.room.entities.templates.loans.LoanRepaymentTemplate
import com.mifos.room.entities.templates.savings.SavingsAccountTransactionTemplate
import kotlinx.coroutines.flow.Flow
import rx.Observable
import javax.inject.Inject
Expand Down Expand Up @@ -48,15 +48,15 @@ class SyncClientsDialogRepositoryImp @Inject constructor(
type: String?,
savingsAccountId: Int,
association: String?,
): Observable<SavingsAccountWithAssociations> {
): Flow<SavingsAccountWithAssociations> {
return dataManagerSavings.syncSavingsAccount(type, savingsAccountId, association)
}

override fun syncSavingsAccountTransactionTemplate(
savingsAccountType: String?,
savingsAccountId: Int,
transactionType: String?,
): Observable<SavingsAccountTransactionTemplate> {
): Flow<SavingsAccountTransactionTemplate?> {
return dataManagerSavings.getSavingsAccountTransactionTemplate(
savingsAccountType,
savingsAccountId,
Expand Down
Loading

0 comments on commit 8001c33

Please sign in to comment.