Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[database.Loan] dbflow to room
Browse files Browse the repository at this point in the history
itsPronay committed Jan 26, 2025
1 parent 5a80565 commit 09da817
Showing 85 changed files with 2,741 additions and 937 deletions.
Original file line number Diff line number Diff line change
@@ -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
@@ -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>
): Flow<LoanRepaymentResponse?>

fun getDatabaseLoanRepaymentByLoanId(loanId: Int): Observable<LoanRepaymentRequest>
fun getDatabaseLoanRepaymentByLoanId(loanId: Int): Flow<LoanRepaymentRequest?>
}
Original file line number Diff line number Diff line change
@@ -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

/**
Original file line number Diff line number Diff line change
@@ -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

/**
Original file line number Diff line number Diff line change
@@ -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

/**
@@ -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
@@ -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

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

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

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

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

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

Original file line number Diff line number Diff line change
@@ -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

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

suspend fun syncClientAccounts(clientId: Int): ClientAccounts

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

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

fun syncSavingsAccount(
type: String?,
Original file line number Diff line number Diff line change
@@ -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

/**
@@ -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?,
Original file line number Diff line number Diff line change
@@ -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(
loanId: Int,
request: LoanRepaymentRequest,
): Observable<LoanRepaymentResponse>
): Flow<LoanRepaymentResponse>

fun deleteAndUpdateLoanRepayments(loanId: Int): Observable<List<LoanRepaymentRequest>>
suspend 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
@@ -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

/**
@@ -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?,
Original file line number Diff line number Diff line change
@@ -10,9 +10,9 @@
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

/**
@@ -21,7 +21,7 @@ import javax.inject.Inject
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
@@ -10,11 +10,12 @@
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 kotlinx.coroutines.flow.flow
import javax.inject.Inject

/**
@@ -23,18 +24,20 @@ import javax.inject.Inject
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> {
): Flow<LoanRepaymentResponse> {
return submitPayment(loanId, request)
}

override fun getDatabaseLoanRepaymentByLoanId(loanId: Int): Observable<LoanRepaymentRequest> {
return dataManagerLoan.getDatabaseLoanRepaymentByLoanId(loanId)
override fun getDatabaseLoanRepaymentByLoanId(loanId: Int): Flow<LoanRepaymentRequest?> {
return flow {
emit(dataManagerLoan.getDatabaseLoanRepaymentByLoanId(loanId))
}
}
}
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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
@@ -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

@@ -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
}

Original file line number Diff line number Diff line change
@@ -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
@@ -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

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

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

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

Loading

0 comments on commit 09da817

Please sign in to comment.