Skip to content

Commit

Permalink
database.loan -DBflow to room
Browse files Browse the repository at this point in the history
  • Loading branch information
itsPronay committed Jan 28, 2025
1 parent 5a80565 commit f20adfc
Show file tree
Hide file tree
Showing 91 changed files with 3,031 additions and 1,227 deletions.
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?>
}
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 @@ -9,19 +9,27 @@
*/
package com.mifos.core.data.repositoryImp

import com.mifos.core.common.network.Dispatcher
import com.mifos.core.common.network.MifosDispatchers
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.CoroutineDispatcher
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOn
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,
@Dispatcher(MifosDispatchers.IO)
private val ioDispatcher: CoroutineDispatcher,
) : LoanAccountSummaryRepository {

override fun getLoanById(loanId: Int): Observable<LoanWithAssociations> {
override fun getLoanById(loanId: Int): Flow<LoanWithAssociations?> {
return dataManagerLoan.getLoanById(loanId)
.flowOn(ioDispatcher)
}
}
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(
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

0 comments on commit f20adfc

Please sign in to comment.