Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[database-Loan] DBflow to Room migration #2292

Merged
merged 4 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.loan.LoanWithAssociations
import rx.Observable
import com.mifos.room.entities.accounts.loans.LoanWithAssociations
import kotlinx.coroutines.flow.Flow

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

fun getLoanById(loanId: Int): Observable<LoanWithAssociations>
fun getLoanById(loanId: Int): Flow<LoanWithAssociations?>
}
therajanmaurya marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.loan.LoanRepaymentRequest
import com.mifos.core.entity.templates.loans.LoanRepaymentTemplate
import com.mifos.core.objects.account.loan.LoanRepaymentResponse
import rx.Observable
import com.mifos.room.entities.accounts.loans.LoanRepaymentRequest
import com.mifos.room.entities.accounts.loans.LoanRepaymentResponse
import com.mifos.room.entities.templates.loans.LoanRepaymentTemplate
import kotlinx.coroutines.flow.Flow

/**
* Created by Aditya Gupta on 10/08/23.
*/
interface LoanRepaymentRepository {

fun getLoanRepayTemplate(loanId: Int): Observable<LoanRepaymentTemplate>
fun getLoanRepayTemplate(loanId: Int): Flow<LoanRepaymentTemplate?>

fun submitPayment(
suspend fun submitPayment(
loanId: Int,
request: LoanRepaymentRequest,
): Observable<LoanRepaymentResponse>
): LoanRepaymentResponse

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

import com.mifos.core.entity.accounts.loan.LoanWithAssociations
import com.mifos.room.entities.accounts.loans.LoanWithAssociations
import rx.Observable

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

import com.mifos.core.entity.accounts.loan.LoanWithAssociations
import com.mifos.room.entities.accounts.loans.LoanWithAssociations
import rx.Observable

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

import com.mifos.core.entity.accounts.loan.LoanRepaymentRequest
import com.mifos.core.entity.accounts.savings.SavingsAccountTransactionRequest
import com.mifos.core.entity.center.CenterPayload
import com.mifos.core.entity.client.ClientPayload
import com.mifos.core.entity.group.GroupPayload
import com.mifos.room.entities.accounts.loans.LoanRepaymentRequest
import kotlinx.coroutines.flow.Flow
import rx.Observable

/**
Expand All @@ -27,7 +28,7 @@ interface OfflineDashboardRepository {

fun allDatabaseCenterPayload(): Observable<List<CenterPayload>>

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

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

import com.mifos.core.entity.accounts.loan.LoanWithAssociations
import com.mifos.core.entity.accounts.savings.SavingsAccountWithAssociations
import com.mifos.core.entity.client.Client
import com.mifos.core.entity.group.Center
import com.mifos.core.entity.group.Group
import com.mifos.core.entity.templates.loans.LoanRepaymentTemplate
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.group.CenterWithAssociations
import com.mifos.room.entities.group.GroupWithAssociations
import com.mifos.room.entities.templates.loans.LoanRepaymentTemplate
import kotlinx.coroutines.flow.Flow
import rx.Observable

/**
Expand All @@ -30,9 +31,9 @@ interface SyncCentersDialogRepository {

fun syncCenterAccounts(centerId: Int): Observable<CenterAccounts>

fun syncLoanById(loanId: Int): Observable<LoanWithAssociations>
fun syncLoanById(loanId: Int): Flow<LoanWithAssociations>

fun syncLoanRepaymentTemplate(loanId: Int): Observable<LoanRepaymentTemplate>
fun syncLoanRepaymentTemplate(loanId: Int): Flow<LoanRepaymentTemplate>

fun getCenterWithAssociations(centerId: Int): Observable<CenterWithAssociations>

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

import com.mifos.core.entity.accounts.loan.LoanWithAssociations
import com.mifos.core.entity.accounts.savings.SavingsAccountWithAssociations
import com.mifos.core.entity.client.Client
import com.mifos.core.entity.templates.loans.LoanRepaymentTemplate
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.templates.loans.LoanRepaymentTemplate
import kotlinx.coroutines.flow.Flow
import rx.Observable

/**
Expand All @@ -24,9 +25,9 @@ interface SyncClientsDialogRepository {

suspend fun syncClientAccounts(clientId: Int): ClientAccounts

fun syncLoanById(loanId: Int): Observable<LoanWithAssociations>
fun syncLoanById(loanId: Int): Flow<LoanWithAssociations>

fun syncLoanRepaymentTemplate(loanId: Int): Observable<LoanRepaymentTemplate>
fun syncLoanRepaymentTemplate(loanId: Int): Flow<LoanRepaymentTemplate>

fun syncSavingsAccount(
type: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.loan.LoanWithAssociations
import com.mifos.core.entity.accounts.savings.SavingsAccountWithAssociations
import com.mifos.core.entity.client.Client
import com.mifos.core.entity.group.Group
import com.mifos.core.entity.templates.loans.LoanRepaymentTemplate
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.group.GroupWithAssociations
import com.mifos.room.entities.templates.loans.LoanRepaymentTemplate
import kotlinx.coroutines.flow.Flow
import rx.Observable

/**
Expand All @@ -27,9 +28,9 @@ interface SyncGroupsDialogRepository {

fun syncGroupAccounts(groupId: Int): Observable<GroupAccounts>

fun syncLoanById(loanId: Int): Observable<LoanWithAssociations>
fun syncLoanById(loanId: Int): Flow<LoanWithAssociations>

fun syncLoanRepaymentTemplate(loanId: Int): Observable<LoanRepaymentTemplate>
fun syncLoanRepaymentTemplate(loanId: Int): Flow<LoanRepaymentTemplate>

fun syncSavingsAccount(
type: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
*/
package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.loan.LoanRepaymentRequest
import com.mifos.core.objects.account.loan.LoanRepaymentResponse
import com.mifos.room.entities.PaymentTypeOption
import rx.Observable
import com.mifos.room.entities.accounts.loans.LoanRepaymentRequest
import com.mifos.room.entities.accounts.loans.LoanRepaymentResponse
import kotlinx.coroutines.flow.Flow

interface SyncLoanRepaymentTransactionRepository {

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

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

fun submitPayment(
suspend fun submitPayment(
loanId: Int,
request: LoanRepaymentRequest,
): Observable<LoanRepaymentResponse>
): LoanRepaymentResponse

fun deleteAndUpdateLoanRepayments(loanId: Int): Observable<List<LoanRepaymentRequest>>
fun deleteAndUpdateLoanRepayments(loanId: Int): Flow<List<LoanRepaymentRequest>>

fun updateLoanRepaymentTransaction(
loanRepaymentRequest: LoanRepaymentRequest,
): Observable<LoanRepaymentRequest>
): Flow<LoanRepaymentRequest?>
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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.room.entities.PaymentTypeOption
import kotlinx.coroutines.flow.Flow
import rx.Observable

/**
Expand All @@ -21,7 +22,7 @@ interface SyncSavingsAccountTransactionRepository {

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

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

fun processTransaction(
savingsAccountType: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@
package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.LoanAccountSummaryRepository
import com.mifos.core.entity.accounts.loan.LoanWithAssociations
import com.mifos.core.network.datamanager.DataManagerLoan
import rx.Observable
import com.mifos.room.entities.accounts.loans.LoanWithAssociations
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

/**
* Created by Aditya Gupta on 08/08/23.
*/
class LoanAccountSummaryRepositoryImp @Inject constructor(private val dataManagerLoan: DataManagerLoan) :
LoanAccountSummaryRepository {
class LoanAccountSummaryRepositoryImp @Inject constructor(
private val dataManagerLoan: DataManagerLoan,
) : LoanAccountSummaryRepository {

override fun getLoanById(loanId: Int): Observable<LoanWithAssociations> {
override fun getLoanById(loanId: Int): Flow<LoanWithAssociations?> {
return dataManagerLoan.getLoanById(loanId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,32 @@
package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.LoanRepaymentRepository
import com.mifos.core.entity.accounts.loan.LoanRepaymentRequest
import com.mifos.core.entity.templates.loans.LoanRepaymentTemplate
import com.mifos.core.network.datamanager.DataManagerLoan
import com.mifos.core.objects.account.loan.LoanRepaymentResponse
import rx.Observable
import com.mifos.room.entities.accounts.loans.LoanRepaymentRequest
import com.mifos.room.entities.accounts.loans.LoanRepaymentResponse
import com.mifos.room.entities.templates.loans.LoanRepaymentTemplate
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

/**
* Created by Aditya Gupta on 10/08/23.
*/
class LoanRepaymentRepositoryImp @Inject constructor(private val dataManagerLoan: DataManagerLoan) :
LoanRepaymentRepository {
class LoanRepaymentRepositoryImp @Inject constructor(
private val dataManagerLoan: DataManagerLoan,
) : LoanRepaymentRepository {

override fun getLoanRepayTemplate(loanId: Int): Observable<LoanRepaymentTemplate> {
override fun getLoanRepayTemplate(loanId: Int): Flow<LoanRepaymentTemplate?> {
return dataManagerLoan.getLoanRepayTemplate(loanId)
}

override fun submitPayment(
override suspend fun submitPayment(
therajanmaurya marked this conversation as resolved.
Show resolved Hide resolved
loanId: Int,
request: LoanRepaymentRequest,
): Observable<LoanRepaymentResponse> {
return submitPayment(loanId, request)
): LoanRepaymentResponse {
return dataManagerLoan.submitPayment(loanId, request)
}

override fun getDatabaseLoanRepaymentByLoanId(loanId: Int): Observable<LoanRepaymentRequest> {
override fun getDatabaseLoanRepaymentByLoanId(loanId: Int): Flow<LoanRepaymentRequest?> {
return dataManagerLoan.getDatabaseLoanRepaymentByLoanId(loanId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.LoanRepaymentScheduleRepository
import com.mifos.core.entity.accounts.loan.LoanWithAssociations
import com.mifos.core.network.DataManager
import com.mifos.room.entities.accounts.loans.LoanWithAssociations
import rx.Observable
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.LoanTransactionsRepository
import com.mifos.core.entity.accounts.loan.LoanWithAssociations
import com.mifos.core.network.DataManager
import com.mifos.room.entities.accounts.loans.LoanWithAssociations
import rx.Observable
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.OfflineDashboardRepository
import com.mifos.core.entity.accounts.loan.LoanRepaymentRequest
import com.mifos.core.entity.accounts.savings.SavingsAccountTransactionRequest
import com.mifos.core.entity.center.CenterPayload
import com.mifos.core.entity.client.ClientPayload
Expand All @@ -20,6 +19,8 @@ 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 kotlinx.coroutines.flow.Flow
import rx.Observable
import javax.inject.Inject

Expand All @@ -46,7 +47,7 @@ class OfflineDashboardRepositoryImp @Inject constructor(
return dataManagerCenter.allDatabaseCenterPayload
}

override fun databaseLoanRepayments(): Observable<List<LoanRepaymentRequest>> {
override fun databaseLoanRepayments(): Flow<List<LoanRepaymentRequest>> {
return dataManagerLoan.databaseLoanRepayments
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
package com.mifos.core.data.repositoryImp

import com.mifos.core.data.repository.SyncCentersDialogRepository
import com.mifos.core.entity.accounts.loan.LoanWithAssociations
import com.mifos.core.entity.accounts.savings.SavingsAccountWithAssociations
import com.mifos.core.entity.client.Client
import com.mifos.core.entity.group.Center
import com.mifos.core.entity.group.Group
import com.mifos.core.entity.templates.loans.LoanRepaymentTemplate
import com.mifos.core.entity.templates.savings.SavingsAccountTransactionTemplate
import com.mifos.core.network.datamanager.DataManagerCenter
import com.mifos.core.network.datamanager.DataManagerClient
Expand All @@ -25,8 +23,11 @@ import com.mifos.core.network.datamanager.DataManagerSavings
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.group.CenterWithAssociations
import com.mifos.room.entities.group.GroupWithAssociations
import com.mifos.room.entities.templates.loans.LoanRepaymentTemplate
import kotlinx.coroutines.flow.Flow
import rx.Observable
import javax.inject.Inject

Expand All @@ -45,11 +46,11 @@ class SyncCentersDialogRepositoryImp @Inject constructor(
return dataManagerCenter.syncCenterAccounts(centerId)
}

override fun syncLoanById(loanId: Int): Observable<LoanWithAssociations> {
override fun syncLoanById(loanId: Int): Flow<LoanWithAssociations> {
return dataManagerLoan.syncLoanById(loanId)
}

override fun syncLoanRepaymentTemplate(loanId: Int): Observable<LoanRepaymentTemplate> {
override fun syncLoanRepaymentTemplate(loanId: Int): Flow<LoanRepaymentTemplate> {
return dataManagerLoan.syncLoanRepaymentTemplate(loanId)
}

Expand Down
Loading