diff --git a/core/common/src/main/java/com/mifos/core/common/network/MifosDispatchers.kt b/core/common/src/main/java/com/mifos/core/common/network/MifosDispatchers.kt index 7f959f1bcf..57dbe5b123 100644 --- a/core/common/src/main/java/com/mifos/core/common/network/MifosDispatchers.kt +++ b/core/common/src/main/java/com/mifos/core/common/network/MifosDispatchers.kt @@ -14,7 +14,7 @@ import kotlin.annotation.AnnotationRetention.RUNTIME @Qualifier @Retention(RUNTIME) -annotation class Dispatcher(val mifosDispatcher: MifosDispatchers) +annotation class Dispatcher(val dispatcher: MifosDispatchers) enum class MifosDispatchers { Default, diff --git a/core/data/src/main/java/com/mifos/core/data/repository/LoanRepaymentRepository.kt b/core/data/src/main/java/com/mifos/core/data/repository/LoanRepaymentRepository.kt index 1e9e89234e..89e271e70d 100644 --- a/core/data/src/main/java/com/mifos/core/data/repository/LoanRepaymentRepository.kt +++ b/core/data/src/main/java/com/mifos/core/data/repository/LoanRepaymentRepository.kt @@ -24,7 +24,7 @@ interface LoanRepaymentRepository { suspend fun submitPayment( loanId: Int, request: LoanRepaymentRequest, - ): Flow + ): LoanRepaymentResponse fun getDatabaseLoanRepaymentByLoanId(loanId: Int): Flow } diff --git a/core/data/src/main/java/com/mifos/core/data/repository/SyncCentersDialogRepository.kt b/core/data/src/main/java/com/mifos/core/data/repository/SyncCentersDialogRepository.kt index cfd2d8727d..47a4cbf4be 100644 --- a/core/data/src/main/java/com/mifos/core/data/repository/SyncCentersDialogRepository.kt +++ b/core/data/src/main/java/com/mifos/core/data/repository/SyncCentersDialogRepository.kt @@ -31,9 +31,9 @@ interface SyncCentersDialogRepository { fun syncCenterAccounts(centerId: Int): Observable - suspend fun syncLoanById(loanId: Int): Flow + fun syncLoanById(loanId: Int): Flow - suspend fun syncLoanRepaymentTemplate(loanId: Int): Flow + fun syncLoanRepaymentTemplate(loanId: Int): Flow fun getCenterWithAssociations(centerId: Int): Observable diff --git a/core/data/src/main/java/com/mifos/core/data/repository/SyncClientsDialogRepository.kt b/core/data/src/main/java/com/mifos/core/data/repository/SyncClientsDialogRepository.kt index 111613bf5a..6d219ad437 100644 --- a/core/data/src/main/java/com/mifos/core/data/repository/SyncClientsDialogRepository.kt +++ b/core/data/src/main/java/com/mifos/core/data/repository/SyncClientsDialogRepository.kt @@ -25,7 +25,7 @@ interface SyncClientsDialogRepository { suspend fun syncClientAccounts(clientId: Int): ClientAccounts - suspend fun syncLoanById(loanId: Int): Flow + fun syncLoanById(loanId: Int): Flow fun syncLoanRepaymentTemplate(loanId: Int): Flow diff --git a/core/data/src/main/java/com/mifos/core/data/repository/SyncLoanRepaymentTransactionRepository.kt b/core/data/src/main/java/com/mifos/core/data/repository/SyncLoanRepaymentTransactionRepository.kt index 91afe0727e..53890a797b 100644 --- a/core/data/src/main/java/com/mifos/core/data/repository/SyncLoanRepaymentTransactionRepository.kt +++ b/core/data/src/main/java/com/mifos/core/data/repository/SyncLoanRepaymentTransactionRepository.kt @@ -25,7 +25,7 @@ interface SyncLoanRepaymentTransactionRepository { request: LoanRepaymentRequest, ): LoanRepaymentResponse - suspend fun deleteAndUpdateLoanRepayments(loanId: Int): Flow> + fun deleteAndUpdateLoanRepayments(loanId: Int): Flow> fun updateLoanRepaymentTransaction( loanRepaymentRequest: LoanRepaymentRequest, diff --git a/core/data/src/main/java/com/mifos/core/data/repositoryImp/LoanAccountSummaryRepositoryImp.kt b/core/data/src/main/java/com/mifos/core/data/repositoryImp/LoanAccountSummaryRepositoryImp.kt index 923e73c5af..17e4100d81 100644 --- a/core/data/src/main/java/com/mifos/core/data/repositoryImp/LoanAccountSummaryRepositoryImp.kt +++ b/core/data/src/main/java/com/mifos/core/data/repositoryImp/LoanAccountSummaryRepositoryImp.kt @@ -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.network.datamanager.DataManagerLoan 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): Flow { return dataManagerLoan.getLoanById(loanId) + .flowOn(ioDispatcher) } } diff --git a/core/data/src/main/java/com/mifos/core/data/repositoryImp/LoanRepaymentRepositoryImp.kt b/core/data/src/main/java/com/mifos/core/data/repositoryImp/LoanRepaymentRepositoryImp.kt index 3b742ff2f1..f110de7759 100644 --- a/core/data/src/main/java/com/mifos/core/data/repositoryImp/LoanRepaymentRepositoryImp.kt +++ b/core/data/src/main/java/com/mifos/core/data/repositoryImp/LoanRepaymentRepositoryImp.kt @@ -9,35 +9,43 @@ */ 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.LoanRepaymentRepository import com.mifos.core.network.datamanager.DataManagerLoan 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.CoroutineDispatcher import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn 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, + @Dispatcher(MifosDispatchers.IO) + private val ioDispatcher: CoroutineDispatcher, +) : LoanRepaymentRepository { override fun getLoanRepayTemplate(loanId: Int): Flow { return dataManagerLoan.getLoanRepayTemplate(loanId) + .flowOn(ioDispatcher) } override suspend fun submitPayment( loanId: Int, request: LoanRepaymentRequest, - ): Flow { - return submitPayment(loanId, request) + ): LoanRepaymentResponse { + return dataManagerLoan.submitPayment(loanId, request) } override fun getDatabaseLoanRepaymentByLoanId(loanId: Int): Flow { return flow { emit(dataManagerLoan.getDatabaseLoanRepaymentByLoanId(loanId)) - } + }.flowOn(ioDispatcher) } } diff --git a/core/data/src/main/java/com/mifos/core/data/repositoryImp/OfflineDashboardRepositoryImp.kt b/core/data/src/main/java/com/mifos/core/data/repositoryImp/OfflineDashboardRepositoryImp.kt index bb3cb1000c..294d6a57cf 100644 --- a/core/data/src/main/java/com/mifos/core/data/repositoryImp/OfflineDashboardRepositoryImp.kt +++ b/core/data/src/main/java/com/mifos/core/data/repositoryImp/OfflineDashboardRepositoryImp.kt @@ -20,7 +20,9 @@ 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.CoroutineDispatcher import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOn import rx.Observable import javax.inject.Inject @@ -33,6 +35,7 @@ class OfflineDashboardRepositoryImp @Inject constructor( private val dataManagerCenter: DataManagerCenter, private val dataManagerLoan: DataManagerLoan, private val dataManagerSavings: DataManagerSavings, + private val ioDispatcher: CoroutineDispatcher, ) : OfflineDashboardRepository { override fun allDatabaseClientPayload(): Observable> { @@ -49,6 +52,7 @@ class OfflineDashboardRepositoryImp @Inject constructor( override fun databaseLoanRepayments(): Flow> { return dataManagerLoan.databaseLoanRepayments + .flowOn(ioDispatcher) } override fun allSavingsAccountTransactions(): Observable> { diff --git a/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncCentersDialogRepositoryImp.kt b/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncCentersDialogRepositoryImp.kt index 17ca65ebfd..b921633436 100644 --- a/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncCentersDialogRepositoryImp.kt +++ b/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncCentersDialogRepositoryImp.kt @@ -27,7 +27,7 @@ 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.Dispatchers +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOn import rx.Observable @@ -42,19 +42,21 @@ class SyncCentersDialogRepositoryImp @Inject constructor( private val dataManagerSavings: DataManagerSavings, private val dataManagerGroups: DataManagerGroups, private val dataManagerClient: DataManagerClient, + private val ioDispatcher: CoroutineDispatcher, ) : SyncCentersDialogRepository { override fun syncCenterAccounts(centerId: Int): Observable { return dataManagerCenter.syncCenterAccounts(centerId) } - override suspend fun syncLoanById(loanId: Int): Flow { + override fun syncLoanById(loanId: Int): Flow { return dataManagerLoan.syncLoanById(loanId) - .flowOn(Dispatchers.IO) + .flowOn(ioDispatcher) } - override suspend fun syncLoanRepaymentTemplate(loanId: Int): Flow { + override fun syncLoanRepaymentTemplate(loanId: Int): Flow { return dataManagerLoan.syncLoanRepaymentTemplate(loanId) + .flowOn(ioDispatcher) } override fun getCenterWithAssociations(centerId: Int): Observable { diff --git a/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncClientsDialogRepositoryImp.kt b/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncClientsDialogRepositoryImp.kt index 8c95176021..5cbeaef5a6 100644 --- a/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncClientsDialogRepositoryImp.kt +++ b/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncClientsDialogRepositoryImp.kt @@ -19,7 +19,7 @@ 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.templates.loans.LoanRepaymentTemplate -import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOn import rx.Observable @@ -32,19 +32,21 @@ class SyncClientsDialogRepositoryImp @Inject constructor( private val dataManagerClient: DataManagerClient, private val dataManagerLoan: DataManagerLoan, private val dataManagerSavings: DataManagerSavings, + private val ioDispatcher: CoroutineDispatcher, ) : SyncClientsDialogRepository { override suspend fun syncClientAccounts(clientId: Int): ClientAccounts { return dataManagerClient.getClientAccounts(clientId) } - override suspend fun syncLoanById(loanId: Int): Flow { + override fun syncLoanById(loanId: Int): Flow { return dataManagerLoan.syncLoanById(loanId) - .flowOn(Dispatchers.IO) + .flowOn(ioDispatcher) } override fun syncLoanRepaymentTemplate(loanId: Int): Flow { return dataManagerLoan.syncLoanRepaymentTemplate(loanId) + .flowOn(ioDispatcher) } override fun syncSavingsAccount( diff --git a/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncGroupsDialogRepositoryImp.kt b/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncGroupsDialogRepositoryImp.kt index 8230fb4543..c4dadcd329 100644 --- a/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncGroupsDialogRepositoryImp.kt +++ b/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncGroupsDialogRepositoryImp.kt @@ -23,7 +23,7 @@ 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.Dispatchers +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOn import rx.Observable @@ -37,6 +37,7 @@ class SyncGroupsDialogRepositoryImp @Inject constructor( private val dataManagerLoan: DataManagerLoan, private val dataManagerSavings: DataManagerSavings, private val dataManagerClient: DataManagerClient, + private val ioDispatcher: CoroutineDispatcher, ) : SyncGroupsDialogRepository { override fun syncGroupAccounts(groupId: Int): Observable { @@ -45,11 +46,12 @@ class SyncGroupsDialogRepositoryImp @Inject constructor( override fun syncLoanById(loanId: Int): Flow { return dataManagerLoan.syncLoanById(loanId) - .flowOn(Dispatchers.IO) + .flowOn(ioDispatcher) } override fun syncLoanRepaymentTemplate(loanId: Int): Flow { return dataManagerLoan.syncLoanRepaymentTemplate(loanId) + .flowOn(ioDispatcher) } override fun syncSavingsAccount( diff --git a/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncLoanRepaymentTransactionRepositoryImp.kt b/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncLoanRepaymentTransactionRepositoryImp.kt index 720a1de02c..52e609d574 100644 --- a/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncLoanRepaymentTransactionRepositoryImp.kt +++ b/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncLoanRepaymentTransactionRepositoryImp.kt @@ -14,20 +14,24 @@ import com.mifos.core.network.datamanager.DataManagerLoan import com.mifos.room.entities.PaymentTypeOption import com.mifos.room.entities.accounts.loans.LoanRepaymentRequest import com.mifos.room.entities.accounts.loans.LoanRepaymentResponse -import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOn import javax.inject.Inject -class SyncLoanRepaymentTransactionRepositoryImp @Inject constructor(private val dataManagerLoan: DataManagerLoan) : - SyncLoanRepaymentTransactionRepository { +class SyncLoanRepaymentTransactionRepositoryImp @Inject constructor( + private val dataManagerLoan: DataManagerLoan, + private val ioDispatcher: CoroutineDispatcher, +) : SyncLoanRepaymentTransactionRepository { override fun databaseLoanRepayments(): Flow> { return dataManagerLoan.databaseLoanRepayments + .flowOn(ioDispatcher) } override fun paymentTypeOption(): Flow> { return dataManagerLoan.paymentTypeOption + .flowOn(ioDispatcher) } override suspend fun submitPayment( @@ -37,13 +41,13 @@ class SyncLoanRepaymentTransactionRepositoryImp @Inject constructor(private val return dataManagerLoan.submitPayment(loanId, request) } - override suspend fun deleteAndUpdateLoanRepayments(loanId: Int): Flow> { + override fun deleteAndUpdateLoanRepayments(loanId: Int): Flow> { return dataManagerLoan.deleteAndUpdateLoanRepayments(loanId) - .flowOn(Dispatchers.IO) + .flowOn(ioDispatcher) } override fun updateLoanRepaymentTransaction(loanRepaymentRequest: LoanRepaymentRequest): Flow { return dataManagerLoan.updateLoanRepaymentTransaction(loanRepaymentRequest) - .flowOn(Dispatchers.IO) + .flowOn(ioDispatcher) } } diff --git a/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncSavingsAccountTransactionRepositoryImp.kt b/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncSavingsAccountTransactionRepositoryImp.kt index e40075368f..c3dc6f87da 100644 --- a/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncSavingsAccountTransactionRepositoryImp.kt +++ b/core/data/src/main/java/com/mifos/core/data/repositoryImp/SyncSavingsAccountTransactionRepositoryImp.kt @@ -15,7 +15,9 @@ import com.mifos.core.network.datamanager.DataManagerLoan import com.mifos.core.network.datamanager.DataManagerSavings import com.mifos.core.objects.account.saving.SavingsAccountTransactionResponse import com.mifos.room.entities.PaymentTypeOption +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOn import rx.Observable import javax.inject.Inject @@ -25,6 +27,7 @@ import javax.inject.Inject class SyncSavingsAccountTransactionRepositoryImp @Inject constructor( private val dataManagerSavings: DataManagerSavings, private val dataManagerLoan: DataManagerLoan, + private val ioDispatcher: CoroutineDispatcher, ) : SyncSavingsAccountTransactionRepository { override fun allSavingsAccountTransactions(): Observable> { @@ -33,6 +36,7 @@ class SyncSavingsAccountTransactionRepositoryImp @Inject constructor( override fun paymentTypeOption(): Flow> { return dataManagerLoan.paymentTypeOption + .flowOn(ioDispatcher) } override fun processTransaction( diff --git a/core/database/src/main/java/com/mifos/room/dao/LoanDao.kt b/core/database/src/main/java/com/mifos/room/dao/LoanDao.kt index 9f0c422e3e..f126141fef 100644 --- a/core/database/src/main/java/com/mifos/room/dao/LoanDao.kt +++ b/core/database/src/main/java/com/mifos/room/dao/LoanDao.kt @@ -50,8 +50,8 @@ interface LoanDao { @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertLoanRepaymentTemplate(template: LoanRepaymentTemplate) - @Query("SELECT * FROM LoanRepaymentTemplate WHERE loanId = :loanId") - fun getLoanRepaymentTemplate(loanId: Int): Flow> + @Query("SELECT * FROM LoanRepaymentTemplate WHERE loanId = :loanId LIMIT 1") + fun getLoanRepaymentTemplate(loanId: Int): LoanRepaymentTemplate? @Query("DELETE FROM LoanRepaymentTemplate WHERE loanId = :loanId") suspend fun deleteLoanRepaymentByLoanId(loanId: Int) diff --git a/core/database/src/main/java/com/mifos/room/entities/PaymentTypeOption.kt b/core/database/src/main/java/com/mifos/room/entities/PaymentTypeOption.kt index 3ae93075f6..a82a9ab4ae 100644 --- a/core/database/src/main/java/com/mifos/room/entities/PaymentTypeOption.kt +++ b/core/database/src/main/java/com/mifos/room/entities/PaymentTypeOption.kt @@ -22,23 +22,23 @@ data class PaymentTypeOption( @SerializedName("id") @PrimaryKey @ColumnInfo(name = "id") - var id: Int = 0, + val id: Int = 0, @SerializedName("name") @ColumnInfo(name = "name") - var name: String = "", + val name: String = "", @SerializedName("description") @ColumnInfo(name = "description") - var description: String? = null, + val description: String? = null, @SerializedName("isCashPayment") @ColumnInfo(name = "is_cash_payment") - var isCashPayment: Boolean? = null, + val isCashPayment: Boolean? = null, @SerializedName("position") @ColumnInfo(name = "position") - var position: Int? = null, + val position: Int? = null, ) : MifosBaseModel(), Comparable, Parcelable { override fun compareTo(another: PaymentTypeOption): Int { diff --git a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/ActualDisbursementDate.kt b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/ActualDisbursementDate.kt index 63abd8143d..6067d30f80 100644 --- a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/ActualDisbursementDate.kt +++ b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/ActualDisbursementDate.kt @@ -19,14 +19,14 @@ import kotlinx.parcelize.Parcelize @Parcelize data class ActualDisbursementDate( @PrimaryKey - var loanId: Int? = null, + val loanId: Int? = null, @ColumnInfo(name = "year") - var year: Int? = null, + val year: Int? = null, @ColumnInfo(name = "month") - var month: Int? = null, + val month: Int? = null, @ColumnInfo(name = "date") - var date: Int? = null, + val date: Int? = null, ) : Parcelable diff --git a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Loan.kt b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Loan.kt index c6abb28800..71530ced3b 100644 --- a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Loan.kt +++ b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Loan.kt @@ -22,87 +22,87 @@ import com.mifos.core.objects.account.loan.RepaymentFrequencyType import com.mifos.core.objects.account.loan.TermPeriodFrequencyType data class Loan( - var id: Int? = null, + val id: Int? = null, - var accountNo: String? = null, + val accountNo: String? = null, - var status: Status? = null, + val status: Status? = null, - var clientId: Int? = null, + val clientId: Int? = null, - var clientName: String? = null, + val clientName: String? = null, - var clientOfficeId: Int? = null, + val clientOfficeId: Int? = null, - var loanProductId: Int? = null, + val loanProductId: Int? = null, - var loanProductName: String? = null, + val loanProductName: String? = null, - var loanProductDescription: String? = null, + val loanProductDescription: String? = null, - var fundId: Int? = null, + val fundId: Int? = null, - var fundName: String? = null, + val fundName: String? = null, - var loanOfficerId: Int? = null, + val loanOfficerId: Int? = null, - var loanOfficerName: String? = null, + val loanOfficerName: String? = null, - var loanType: LoanType? = null, + val loanType: LoanType? = null, - var currency: Currency? = null, + val currency: Currency? = null, - var principal: Double? = null, + val principal: Double? = null, - var approvedPrincipal: Double? = null, + val approvedPrincipal: Double? = null, - var termFrequency: Int? = null, + val termFrequency: Int? = null, - var termPeriodFrequencyType: TermPeriodFrequencyType? = null, + val termPeriodFrequencyType: TermPeriodFrequencyType? = null, - var numberOfRepayments: Int? = null, + val numberOfRepayments: Int? = null, - var repaymentEvery: Int? = null, + val repaymentEvery: Int? = null, - var repaymentFrequencyType: RepaymentFrequencyType? = null, + val repaymentFrequencyType: RepaymentFrequencyType? = null, - var interestRatePerPeriod: Double? = null, + val interestRatePerPeriod: Double? = null, - var interestRateFrequencyType: InterestRateFrequencyType? = null, + val interestRateFrequencyType: InterestRateFrequencyType? = null, - var annualInterestRate: Double? = null, + val annualInterestRate: Double? = null, - var amortizationType: AmortizationType? = null, + val amortizationType: AmortizationType? = null, - var interestType: InterestType? = null, + val interestType: InterestType? = null, - var interestCalculationPeriodType: InterestCalculationPeriodType? = null, + val interestCalculationPeriodType: InterestCalculationPeriodType? = null, - var transactionProcessingStrategyId: Int? = null, + val transactionProcessingStrategyId: Int? = null, - var transactionProcessingStrategyName: String? = null, + val transactionProcessingStrategyName: String? = null, - var syncDisbursementWithMeeting: Boolean? = null, + val syncDisbursementWithMeeting: Boolean? = null, - var timeline: Timeline? = null, + val timeline: Timeline? = null, - var summary: Summary? = null, + val summary: Summary? = null, - var feeChargesAtDisbursementCharged: Double? = null, + val feeChargesAtDisbursementCharged: Double? = null, - var loanCounter: Int? = null, + val loanCounter: Int? = null, - var loanProductCounter: Int? = null, + val loanProductCounter: Int? = null, - var multiDisburseLoan: Boolean? = null, + val multiDisburseLoan: Boolean? = null, - var canDisburse: Boolean? = null, + val canDisburse: Boolean? = null, - var inArrears: Boolean? = null, + val inArrears: Boolean? = null, - var isNPA: Boolean? = null, + val isNPA: Boolean? = null, - var overdueCharges: List = ArrayList(), + val overdueCharges: List = ArrayList(), private val additionalProperties: MutableMap = HashMap(), ) diff --git a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanAccount.kt b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanAccount.kt index c51c60b92b..5e02b6d55c 100644 --- a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanAccount.kt +++ b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanAccount.kt @@ -32,38 +32,38 @@ import androidx.room.PrimaryKey ) data class LoanAccount( @PrimaryKey - var id: Int? = null, + val id: Int? = null, @ColumnInfo(name = "clientId") - var clientId: Long = 0, + val clientId: Long = 0, @ColumnInfo(name = "groupId") - var groupId: Long = 0, + val groupId: Long = 0, @ColumnInfo(name = "centerId") - var centerId: Long = 0, + val centerId: Long = 0, @ColumnInfo(name = "accountNo") - var accountNo: String? = null, + val accountNo: String? = null, @ColumnInfo(name = "externalId") - var externalId: String? = null, + val externalId: String? = null, @ColumnInfo(name = "productId") - var productId: Int? = null, + val productId: Int? = null, @ColumnInfo(name = "productName") - var productName: String? = null, + val productName: String? = null, @ColumnInfo(name = "status", index = true) - var status: Status? = null, + val status: Status? = null, @ColumnInfo(name = "loanType", index = true) - var loanType: LoanType? = null, + val loanType: LoanType? = null, @ColumnInfo(name = "loanCycle") - var loanCycle: Int? = null, + val loanCycle: Int? = null, @ColumnInfo(name = "inArrears") - var inArrears: Boolean? = null, + val inArrears: Boolean? = null, ) diff --git a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanRepaymentRequest.kt b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanRepaymentRequest.kt index 7498955242..b6a5109934 100644 --- a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanRepaymentRequest.kt +++ b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanRepaymentRequest.kt @@ -18,51 +18,51 @@ data class LoanRepaymentRequest( // TODO(check this out) // @PrimaryKey(autoGenerate = true) -// var id: Int = 0, +// val id: Int = 0, @ColumnInfo(name = "timeStamp") @PrimaryKey @Transient - var timeStamp: Long = 0, + val timeStamp: Long = 0, @ColumnInfo(name = "loanId") @Transient - var loanId: Int? = null, + val loanId: Int? = null, @ColumnInfo(name = "errorMessage") @Transient - var errorMessage: String? = null, + val errorMessage: String? = null, @ColumnInfo(name = "dateFormat") - var dateFormat: String? = null, + val dateFormat: String? = null, @ColumnInfo(name = "locale") - var locale: String? = null, + val locale: String? = null, @ColumnInfo(name = "transactionDate") - var transactionDate: String? = null, + val transactionDate: String? = null, @ColumnInfo(name = "transactionAmount") - var transactionAmount: String? = null, + val transactionAmount: String? = null, @ColumnInfo(name = "paymentTypeId") - var paymentTypeId: String? = null, + val paymentTypeId: String? = null, @ColumnInfo(name = "note") - var note: String? = null, + val note: String? = null, @ColumnInfo(name = "accountNumber") - var accountNumber: String? = null, + val accountNumber: String? = null, @ColumnInfo(name = "checkNumber") - var checkNumber: String? = null, + val checkNumber: String? = null, @ColumnInfo(name = "routingCode") - var routingCode: String? = null, + val routingCode: String? = null, @ColumnInfo(name = "receiptNumber") - var receiptNumber: String? = null, + val receiptNumber: String? = null, @ColumnInfo(name = "bankNumber") - var bankNumber: String? = null, + val bankNumber: String? = null, ) diff --git a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanRepaymentResponse.kt b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanRepaymentResponse.kt index 5995f1638c..87641bb4bc 100644 --- a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanRepaymentResponse.kt +++ b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanRepaymentResponse.kt @@ -19,10 +19,10 @@ import kotlinx.parcelize.Parcelize @Parcelize data class LoanRepaymentResponse( @PrimaryKey(autoGenerate = true) - var id: Int = 0, - var officeId: Int? = null, - var clientId: Int? = null, - var loanId: Int? = null, - var resourceId: Int? = null, - var changes: Changes? = null, + val id: Int = 0, + val officeId: Int? = null, + val clientId: Int? = null, + val loanId: Int? = null, + val resourceId: Int? = null, + val changes: Changes? = null, ) : Parcelable diff --git a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanType.kt b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanType.kt index f958ee980f..64d0752472 100644 --- a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanType.kt +++ b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanType.kt @@ -20,11 +20,11 @@ import kotlinx.serialization.Serializable @Parcelize data class LoanType( - var id: Int? = null, + val id: Int? = null, @ColumnInfo("code") - var code: String? = null, + val code: String? = null, @ColumnInfo("value") - var value: String? = null, + val value: String? = null, ) : Parcelable diff --git a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanWithAssociations.kt b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanWithAssociations.kt index 3fa40e6c8a..4c8f31c67b 100644 --- a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanWithAssociations.kt +++ b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/LoanWithAssociations.kt @@ -66,137 +66,137 @@ import kotlinx.parcelize.Parcelize ) data class LoanWithAssociations( @PrimaryKey(autoGenerate = true) - var id: Int = 0, + val id: Int = 0, @ColumnInfo(name = "accountNo") - var accountNo: String = "", + val accountNo: String = "", @ColumnInfo(name = "status", index = true) - var status: Status = Status(), + val status: Status = Status(), @ColumnInfo(name = "clientId") - var clientId: Int = 0, + val clientId: Int = 0, @ColumnInfo(name = "clientName") - var clientName: String = "", + val clientName: String = "", @ColumnInfo(name = "clientOfficeId") - var clientOfficeId: Int = 0, + val clientOfficeId: Int = 0, @ColumnInfo(name = "loanProductId") - var loanProductId: Int = 0, + val loanProductId: Int = 0, @ColumnInfo(name = "loanProductName") - var loanProductName: String = "", + val loanProductName: String = "", @ColumnInfo(name = "loanProductDescription") - var loanProductDescription: String = "", + val loanProductDescription: String = "", @ColumnInfo(name = "fundId") - var fundId: Int = 0, + val fundId: Int = 0, @ColumnInfo(name = "fundName") - var fundName: String = "", + val fundName: String = "", @ColumnInfo(name = "loanPurposeId") - var loanPurposeId: Int = 0, + val loanPurposeId: Int = 0, @ColumnInfo(name = "loanPurposeName") - var loanPurposeName: String = "", + val loanPurposeName: String = "", @ColumnInfo(name = "loanOfficerId") - var loanOfficerId: Int = 0, + val loanOfficerId: Int = 0, @ColumnInfo(name = "loanOfficerName") - var loanOfficerName: String = "", + val loanOfficerName: String = "", @Embedded(prefix = "LoanType_") - var loanType: LoanType = LoanType(), + val loanType: LoanType = LoanType(), @Embedded(prefix = "Currency_") - var currency: Currency = Currency(), + val currency: Currency = Currency(), @ColumnInfo(name = "principal") - var principal: Double = 0.0, + val principal: Double = 0.0, @ColumnInfo(name = "approvedPrincipal") - var approvedPrincipal: Double = 0.0, + val approvedPrincipal: Double = 0.0, @ColumnInfo(name = "termFrequency") - var termFrequency: Int = 0, + val termFrequency: Int = 0, @Embedded(prefix = "termPeriodFrequencyType_") - var termPeriodFrequencyType: TermPeriodFrequencyType = TermPeriodFrequencyType(), + val termPeriodFrequencyType: TermPeriodFrequencyType = TermPeriodFrequencyType(), @ColumnInfo(name = "numberOfRepayments") - var numberOfRepayments: Int = 0, + val numberOfRepayments: Int = 0, @ColumnInfo(name = "repaymentEvery") - var repaymentEvery: Int = 0, + val repaymentEvery: Int = 0, @Embedded(prefix = "repaymentFrequencyType_") - var repaymentFrequencyType: RepaymentFrequencyType = RepaymentFrequencyType(), + val repaymentFrequencyType: RepaymentFrequencyType = RepaymentFrequencyType(), @ColumnInfo(name = "interestRatePerPeriod") - var interestRatePerPeriod: Double = 0.0, + val interestRatePerPeriod: Double = 0.0, @Embedded(prefix = "interestRateFrequencyType_") - var interestRateFrequencyType: InterestRateFrequencyType = InterestRateFrequencyType(), + val interestRateFrequencyType: InterestRateFrequencyType = InterestRateFrequencyType(), @ColumnInfo(name = "annualInterestRate") - var annualInterestRate: Double = 0.0, + val annualInterestRate: Double = 0.0, @Embedded(prefix = "amortization_type_") - var amortizationType: AmortizationType = AmortizationType(), + val amortizationType: AmortizationType = AmortizationType(), @Embedded(prefix = "interestType_") - var interestType: InterestType = InterestType(), + val interestType: InterestType = InterestType(), @Embedded(prefix = "interestCalculationPeriodType_") - var interestCalculationPeriodType: InterestCalculationPeriodType = InterestCalculationPeriodType(), + val interestCalculationPeriodType: InterestCalculationPeriodType = InterestCalculationPeriodType(), @ColumnInfo(name = "transactionProcessingStrategyId") - var transactionProcessingStrategyId: Int = 0, + val transactionProcessingStrategyId: Int = 0, @ColumnInfo(name = "transactionProcessingStrategyName") - var transactionProcessingStrategyName: String = "", + val transactionProcessingStrategyName: String = "", @ColumnInfo(name = "syncDisbursementWithMeeting") - var syncDisbursementWithMeeting: Boolean = false, + val syncDisbursementWithMeeting: Boolean = false, @ColumnInfo(name = "timeline", index = true) - var timeline: Timeline = Timeline(), + val timeline: Timeline = Timeline(), @ColumnInfo(name = "summary", index = true) - var summary: Summary = Summary(), + val summary: Summary = Summary(), @Embedded(prefix = "repaymentSchedule_") - var repaymentSchedule: RepaymentSchedule = RepaymentSchedule(), + val repaymentSchedule: RepaymentSchedule = RepaymentSchedule(), @ColumnInfo(name = "transactions") - var transactions: List = ArrayList(), + val transactions: List = ArrayList(), @ColumnInfo(name = "feeChargesAtDisbursementCharged") - var feeChargesAtDisbursementCharged: Double = 0.0, + val feeChargesAtDisbursementCharged: Double = 0.0, @ColumnInfo(name = "totalOverpaid") - var totalOverpaid: Double = 0.0, + val totalOverpaid: Double = 0.0, @ColumnInfo(name = "loanCounter") - var loanCounter: Int = 0, + val loanCounter: Int = 0, @ColumnInfo(name = "loanProductCounter") - var loanProductCounter: Int = 0, + val loanProductCounter: Int = 0, @ColumnInfo(name = "multiDisburseLoan") - var multiDisburseLoan: Boolean = false, + val multiDisburseLoan: Boolean = false, @ColumnInfo(name = "canDisburse") - var canDisburse: Boolean = false, + val canDisburse: Boolean = false, @ColumnInfo(name = "inArrears") - var inArrears: Boolean = false, + val inArrears: Boolean = false, @ColumnInfo(name = "isNPA") - var isNPA: Boolean = false, + val isNPA: Boolean = false, ) : Parcelable diff --git a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Status.kt b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Status.kt index ee72e693a6..76fa650331 100644 --- a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Status.kt +++ b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Status.kt @@ -21,35 +21,35 @@ import kotlinx.serialization.Serializable @Parcelize data class Status( @PrimaryKey - var id: Int? = null, + val id: Int? = null, @ColumnInfo(name = "code") - var code: String? = null, + val code: String? = null, @ColumnInfo(name = "value") - var value: String? = null, + val value: String? = null, @ColumnInfo(name = "pendingApproval") - var pendingApproval: Boolean? = null, + val pendingApproval: Boolean? = null, @ColumnInfo(name = "waitingForDisbursal") - var waitingForDisbursal: Boolean? = null, + val waitingForDisbursal: Boolean? = null, @ColumnInfo(name = "active") - var active: Boolean? = null, + val active: Boolean? = null, @ColumnInfo(name = "closedObligationsMet") - var closedObligationsMet: Boolean? = null, + val closedObligationsMet: Boolean? = null, @ColumnInfo(name = "closedWrittenOff") - var closedWrittenOff: Boolean? = null, + val closedWrittenOff: Boolean? = null, @ColumnInfo(name = "closedRescheduled") - var closedRescheduled: Boolean? = null, + val closedRescheduled: Boolean? = null, @ColumnInfo(name = "closed") - var closed: Boolean? = null, + val closed: Boolean? = null, @ColumnInfo(name = "overpaid") - var overpaid: Boolean? = null, + val overpaid: Boolean? = null, ) : Parcelable diff --git a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Summary.kt b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Summary.kt index 68c8dda1fd..344690000d 100644 --- a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Summary.kt +++ b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Summary.kt @@ -23,107 +23,107 @@ import kotlinx.serialization.Serializable @Parcelize data class Summary( @PrimaryKey - var loanId: Int? = null, + val loanId: Int? = null, @Embedded - var currency: Currency? = null, + val currency: Currency? = null, @ColumnInfo(name = "principalDisbursed") - var principalDisbursed: Double? = null, + val principalDisbursed: Double? = null, @ColumnInfo(name = "principalPaid") - var principalPaid: Double? = null, + val principalPaid: Double? = null, @ColumnInfo(name = "principalWrittenOff") - var principalWrittenOff: Double? = null, + val principalWrittenOff: Double? = null, @ColumnInfo(name = "principalOutstanding") - var principalOutstanding: Double? = null, + val principalOutstanding: Double? = null, @ColumnInfo(name = "principalOverdue") - var principalOverdue: Double? = null, + val principalOverdue: Double? = null, @ColumnInfo(name = "interestCharged") - var interestCharged: Double? = null, + val interestCharged: Double? = null, @ColumnInfo(name = "interestPaid") - var interestPaid: Double? = null, + val interestPaid: Double? = null, @ColumnInfo(name = "interestWaived") - var interestWaived: Double? = null, + val interestWaived: Double? = null, @ColumnInfo(name = "interestWrittenOff") - var interestWrittenOff: Double? = null, + val interestWrittenOff: Double? = null, @ColumnInfo(name = "interestOutstanding") - var interestOutstanding: Double? = null, + val interestOutstanding: Double? = null, @ColumnInfo(name = "interestOverdue") - var interestOverdue: Double? = null, + val interestOverdue: Double? = null, @ColumnInfo(name = "feeChargesCharged") - var feeChargesCharged: Double? = null, + val feeChargesCharged: Double? = null, @ColumnInfo(name = "feeChargesDueAtDisbursementCharged") - var feeChargesDueAtDisbursementCharged: Double? = null, + val feeChargesDueAtDisbursementCharged: Double? = null, @ColumnInfo(name = "feeChargesPaid") - var feeChargesPaid: Double? = null, + val feeChargesPaid: Double? = null, @ColumnInfo(name = "feeChargesWaived") - var feeChargesWaived: Double? = null, + val feeChargesWaived: Double? = null, @ColumnInfo(name = "feeChargesWrittenOff") - var feeChargesWrittenOff: Double? = null, + val feeChargesWrittenOff: Double? = null, @ColumnInfo(name = "feeChargesOutstanding") - var feeChargesOutstanding: Double? = null, + val feeChargesOutstanding: Double? = null, @ColumnInfo(name = "feeChargesOverdue") - var feeChargesOverdue: Double? = null, + val feeChargesOverdue: Double? = null, @ColumnInfo(name = "penaltyChargesCharged") - var penaltyChargesCharged: Double? = null, + val penaltyChargesCharged: Double? = null, @ColumnInfo(name = "penaltyChargesPaid") - var penaltyChargesPaid: Double? = null, + val penaltyChargesPaid: Double? = null, @ColumnInfo(name = "penaltyChargesWaived") - var penaltyChargesWaived: Double? = null, + val penaltyChargesWaived: Double? = null, @ColumnInfo(name = "penaltyChargesWrittenOff") - var penaltyChargesWrittenOff: Double? = null, + val penaltyChargesWrittenOff: Double? = null, @ColumnInfo(name = "penaltyChargesOutstanding") - var penaltyChargesOutstanding: Double? = null, + val penaltyChargesOutstanding: Double? = null, @ColumnInfo(name = "penaltyChargesOverdue") - var penaltyChargesOverdue: Double? = null, + val penaltyChargesOverdue: Double? = null, @ColumnInfo(name = "totalExpectedRepayment") - var totalExpectedRepayment: Double? = null, + val totalExpectedRepayment: Double? = null, @ColumnInfo(name = "totalRepayment") - var totalRepayment: Double? = null, + val totalRepayment: Double? = null, @ColumnInfo(name = "totalExpectedCostOfLoan") - var totalExpectedCostOfLoan: Double? = null, + val totalExpectedCostOfLoan: Double? = null, @ColumnInfo(name = "totalCostOfLoan") - var totalCostOfLoan: Double? = null, + val totalCostOfLoan: Double? = null, @ColumnInfo(name = "totalWaived") - var totalWaived: Double? = null, + val totalWaived: Double? = null, @ColumnInfo(name = "totalWrittenOff") - var totalWrittenOff: Double? = null, + val totalWrittenOff: Double? = null, @ColumnInfo(name = "totalOutstanding") - var totalOutstanding: Double? = null, + val totalOutstanding: Double? = null, @ColumnInfo(name = "totalOverdue") - var totalOverdue: Double? = null, + val totalOverdue: Double? = null, @ColumnInfo(name = "overdueSinceDate") - var overdueSinceDate: List? = null, + val overdueSinceDate: List? = null, ) : Parcelable diff --git a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Timeline.kt b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Timeline.kt index 59b0c27754..37e969ccc8 100644 --- a/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Timeline.kt +++ b/core/database/src/main/java/com/mifos/room/entities/accounts/loans/Timeline.kt @@ -34,55 +34,55 @@ import kotlinx.serialization.Transient data class Timeline( @PrimaryKey @Transient - var loanId: Int? = null, + val loanId: Int? = null, @ColumnInfo(name = "submittedOnDate") - var submittedOnDate: List? = null, + val submittedOnDate: List? = null, @ColumnInfo(name = "submittedByUsername") - var submittedByUsername: String? = null, + val submittedByUsername: String? = null, @ColumnInfo(name = "submittedByFirstname") - var submittedByFirstname: String? = null, + val submittedByFirstname: String? = null, @ColumnInfo(name = "submittedByLastname") - var submittedByLastname: String? = null, + val submittedByLastname: String? = null, @ColumnInfo(name = "approvedOnDate") - var approvedOnDate: List? = null, + val approvedOnDate: List? = null, @ColumnInfo(name = "approvedByUsername") - var approvedByUsername: String? = null, + val approvedByUsername: String? = null, @ColumnInfo(name = "approvedByFirstname") - var approvedByFirstname: String? = null, + val approvedByFirstname: String? = null, @ColumnInfo(name = "approvedByLastname") - var approvedByLastname: String? = null, + val approvedByLastname: String? = null, @ColumnInfo(name = "expectedDisbursementDate") - var expectedDisbursementDate: List? = null, + val expectedDisbursementDate: List? = null, // todo check if its int @ColumnInfo(name = "actualDisburseDate", index = true) @Transient - var actualDisburseDate: ActualDisbursementDate? = null, + val actualDisburseDate: ActualDisbursementDate? = null, @ColumnInfo(name = "actualDisbursementDate") - var actualDisbursementDate: List? = null, + val actualDisbursementDate: List? = null, @ColumnInfo(name = "disbursedByUsername") - var disbursedByUsername: String? = null, + val disbursedByUsername: String? = null, @ColumnInfo(name = "disbursedByFirstname") - var disbursedByFirstname: String? = null, + val disbursedByFirstname: String? = null, @ColumnInfo(name = "disbursedByLastname") - var disbursedByLastname: String? = null, + val disbursedByLastname: String? = null, @ColumnInfo(name = "closedOnDate") - var closedOnDate: List? = null, + val closedOnDate: List? = null, @ColumnInfo(name = "expectedMaturityDate") - var expectedMaturityDate: List? = null, + val expectedMaturityDate: List? = null, ) : Parcelable diff --git a/core/database/src/main/java/com/mifos/room/entities/templates/loans/LoanRepaymentTemplate.kt b/core/database/src/main/java/com/mifos/room/entities/templates/loans/LoanRepaymentTemplate.kt index 5fb57c9b08..9d2c1f180c 100644 --- a/core/database/src/main/java/com/mifos/room/entities/templates/loans/LoanRepaymentTemplate.kt +++ b/core/database/src/main/java/com/mifos/room/entities/templates/loans/LoanRepaymentTemplate.kt @@ -23,32 +23,32 @@ import kotlinx.parcelize.Parcelize data class LoanRepaymentTemplate( @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "loanId") - var loanId: Int? = null, + val loanId: Int? = null, @ColumnInfo(name = "type") - var type: Type? = null, + val type: Type? = null, @ColumnInfo(name = "date") - var date: MutableList? = null, + val date: MutableList? = null, @ColumnInfo(name = "currency") - var currency: Currency? = null, + val currency: Currency? = null, @ColumnInfo(name = "amount") - var amount: Double? = null, + val amount: Double? = null, @ColumnInfo(name = "principalPortion") - var principalPortion: Double? = null, + val principalPortion: Double? = null, @ColumnInfo(name = "interestPortion") - var interestPortion: Double? = null, + val interestPortion: Double? = null, @ColumnInfo(name = "feeChargesPortion") - var feeChargesPortion: Double? = null, + val feeChargesPortion: Double? = null, @ColumnInfo(name = "penaltyChargesPortion") - var penaltyChargesPortion: Double? = null, + val penaltyChargesPortion: Double? = null, @ColumnInfo(name = "paymentTypeOptions") - var paymentTypeOptions: MutableList? = null, + val paymentTypeOptions: MutableList? = null, ) : Parcelable diff --git a/core/database/src/main/java/com/mifos/room/entities/templates/loans/LoanTemplate.kt b/core/database/src/main/java/com/mifos/room/entities/templates/loans/LoanTemplate.kt index 793a17df19..4aa83c3caa 100644 --- a/core/database/src/main/java/com/mifos/room/entities/templates/loans/LoanTemplate.kt +++ b/core/database/src/main/java/com/mifos/room/entities/templates/loans/LoanTemplate.kt @@ -44,115 +44,115 @@ import kotlinx.parcelize.Parcelize */ @Parcelize data class LoanTemplate( - var clientId: Int? = null, + val clientId: Int? = null, - var clientAccountNo: String? = null, + val clientAccountNo: String? = null, - var clientName: String? = null, + val clientName: String? = null, - var clientOfficeId: Int? = null, + val clientOfficeId: Int? = null, - var loanProductId: Int? = null, + val loanProductId: Int? = null, - var loanProductName: String? = null, + val loanProductName: String? = null, - var isLoanProductLinkedToFloatingRate: Boolean? = null, + val isLoanProductLinkedToFloatingRate: Boolean? = null, - var fundId: Int? = null, + val fundId: Int? = null, - var fundName: String? = null, + val fundName: String? = null, - var currency: Currency? = null, + val currency: Currency? = null, - var principal: Double? = null, + val principal: Double? = null, - var approvedPrincipal: Double? = null, + val approvedPrincipal: Double? = null, - var proposedPrincipal: Double? = null, + val proposedPrincipal: Double? = null, - var termFrequency: Int? = null, + val termFrequency: Int? = null, - var termPeriodFrequencyType: TermPeriodFrequencyType? = null, + val termPeriodFrequencyType: TermPeriodFrequencyType? = null, - var numberOfRepayments: Int? = null, + val numberOfRepayments: Int? = null, - var repaymentEvery: Int? = null, + val repaymentEvery: Int? = null, - var repaymentFrequencyType: RepaymentFrequencyType? = null, + val repaymentFrequencyType: RepaymentFrequencyType? = null, - var interestRatePerPeriod: Double? = null, + val interestRatePerPeriod: Double? = null, - var interestRateFrequencyType: InterestRateFrequencyType? = null, + val interestRateFrequencyType: InterestRateFrequencyType? = null, - var annualInterestRate: Double? = null, + val annualInterestRate: Double? = null, - var isFloatingInterestRate: Boolean? = null, + val isFloatingInterestRate: Boolean? = null, - var amortizationType: AmortizationType? = null, + val amortizationType: AmortizationType? = null, - var interestType: InterestType? = null, + val interestType: InterestType? = null, - var interestCalculationPeriodType: InterestCalculationPeriodType? = null, + val interestCalculationPeriodType: InterestCalculationPeriodType? = null, - var allowPartialPeriodInterestCalcualtion: Boolean? = null, + val allowPartialPeriodInterestCalcualtion: Boolean? = null, - var transactionProcessingStrategyId: Int? = null, + val transactionProcessingStrategyId: Int? = null, - var graceOnArrearsAgeing: Int? = null, + val graceOnArrearsAgeing: Int? = null, - var timeline: Timeline? = null, + val timeline: Timeline? = null, - var productOptions: List = ArrayList(), + val productOptions: List = ArrayList(), - var dataTables: ArrayList = ArrayList(), + val dataTables: ArrayList = ArrayList(), - var loanOfficerOptions: List = ArrayList(), + val loanOfficerOptions: List = ArrayList(), - var loanPurposeOptions: List = ArrayList(), + val loanPurposeOptions: List = ArrayList(), - var fundOptions: List = ArrayList(), + val fundOptions: List = ArrayList(), - var termFrequencyTypeOptions: List = ArrayList(), + val termFrequencyTypeOptions: List = ArrayList(), - var repaymentFrequencyTypeOptions: List = ArrayList(), + val repaymentFrequencyTypeOptions: List = ArrayList(), - var repaymentFrequencyNthDayTypeOptions: List = ArrayList(), + val repaymentFrequencyNthDayTypeOptions: List = ArrayList(), - var repaymentFrequencyDaysOfWeekTypeOptions: List = ArrayList(), + val repaymentFrequencyDaysOfWeekTypeOptions: List = ArrayList(), - var interestRateFrequencyTypeOptions: List = ArrayList(), + val interestRateFrequencyTypeOptions: List = ArrayList(), - var amortizationTypeOptions: List = ArrayList(), + val amortizationTypeOptions: List = ArrayList(), - var interestTypeOptions: List = ArrayList(), + val interestTypeOptions: List = ArrayList(), - var interestCalculationPeriodTypeOptions: List = ArrayList(), + val interestCalculationPeriodTypeOptions: List = ArrayList(), - var transactionProcessingStrategyOptions: List = ArrayList(), + val transactionProcessingStrategyOptions: List = ArrayList(), - var chargeOptions: List = ArrayList(), + val chargeOptions: List = ArrayList(), - var loanCollateralOptions: List = ArrayList(), + val loanCollateralOptions: List = ArrayList(), - var multiDisburseLoan: Boolean? = null, + val multiDisburseLoan: Boolean? = null, - var canDefineInstallmentAmount: Boolean? = null, + val canDefineInstallmentAmount: Boolean? = null, - var canDisburse: Boolean? = null, + val canDisburse: Boolean? = null, - var product: Product? = null, + val product: Product? = null, - var daysInMonthType: DaysInMonthType? = null, + val daysInMonthType: DaysInMonthType? = null, - var daysInYearType: DaysInYearType? = null, + val daysInYearType: DaysInYearType? = null, - var isInterestRecalculationEnabled: Boolean? = null, + val isInterestRecalculationEnabled: Boolean? = null, - var isVariableInstallmentsAllowed: Boolean? = null, + val isvaliableInstallmentsAllowed: Boolean? = null, - var minimumGap: Int? = null, + val minimumGap: Int? = null, - var maximumGap: Int? = null, + val maximumGap: Int? = null, - var accountLinkingOptions: List = ArrayList(), + val accountLinkingOptions: List = ArrayList(), ) : Parcelable diff --git a/core/database/src/main/java/com/mifos/room/entities/templates/loans/LoanTransactionTemplate.kt b/core/database/src/main/java/com/mifos/room/entities/templates/loans/LoanTransactionTemplate.kt index e023244b05..20e3c106dd 100644 --- a/core/database/src/main/java/com/mifos/room/entities/templates/loans/LoanTransactionTemplate.kt +++ b/core/database/src/main/java/com/mifos/room/entities/templates/loans/LoanTransactionTemplate.kt @@ -19,15 +19,15 @@ import kotlinx.parcelize.Parcelize */ @Parcelize data class LoanTransactionTemplate( - var type: Type? = null, + val type: Type? = null, - var date: List = ArrayList(), + val date: List = ArrayList(), - var amount: Double? = null, + val amount: Double? = null, - var manuallyReversed: Boolean? = null, + val manuallyReversed: Boolean? = null, - var possibleNextRepaymentDate: List = ArrayList(), + val possibleNextRepaymentDate: List = ArrayList(), - var paymentTypeOptions: List = ArrayList(), + val paymentTypeOptions: List = ArrayList(), ) : Parcelable diff --git a/core/database/src/main/java/com/mifos/room/helper/LoanDaoHelper.kt b/core/database/src/main/java/com/mifos/room/helper/LoanDaoHelper.kt index dfef371891..617388ac67 100644 --- a/core/database/src/main/java/com/mifos/room/helper/LoanDaoHelper.kt +++ b/core/database/src/main/java/com/mifos/room/helper/LoanDaoHelper.kt @@ -17,6 +17,7 @@ import com.mifos.room.entities.accounts.loans.LoanRepaymentResponse import com.mifos.room.entities.accounts.loans.LoanWithAssociations import com.mifos.room.entities.templates.loans.LoanRepaymentTemplate import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.emitAll import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.flow @@ -34,25 +35,29 @@ class LoanDaoHelper @Inject constructor( fun saveLoanById(loanWithAssociations: LoanWithAssociations): Flow { return flow { // Setting Loan Id in Summary Table - loanWithAssociations.summary.loanId = loanWithAssociations.id - - // Setting Timeline - val timeline = loanWithAssociations.timeline - timeline.loanId = loanWithAssociations.id - - // Setting ActualDisbursement in Table - val actualDisbursementDate = ActualDisbursementDate( - loanWithAssociations.id, - loanWithAssociations.timeline.actualDisbursementDate?.get(0), - loanWithAssociations.timeline.actualDisbursementDate?.get(1), - loanWithAssociations.timeline.actualDisbursementDate?.get(2), + val updatedSummary = loanWithAssociations.summary.copy( + loanId = loanWithAssociations.id, ) - timeline.actualDisburseDate = actualDisbursementDate - loanWithAssociations.timeline = timeline - // Save all entities using DAO - loanDao.saveLoanWithAssociations(loanWithAssociations) - emit(loanWithAssociations) + val updatedTimeline = loanWithAssociations.timeline.copy( + loanId = loanWithAssociations.id, + actualDisburseDate = loanWithAssociations.timeline.actualDisbursementDate?.let { + ActualDisbursementDate( + loanId = loanWithAssociations.id, + year = it.getOrNull(0), + month = it.getOrNull(1), + date = it.getOrNull(2), + ) + }, + ) + + val updatedLoanWithAssociations = loanWithAssociations.copy( + summary = updatedSummary, + timeline = updatedTimeline, + ) + + loanDao.saveLoanWithAssociations(updatedLoanWithAssociations) + emit(updatedLoanWithAssociations) } } @@ -66,14 +71,18 @@ class LoanDaoHelper @Inject constructor( return flow { val loan = loanDao.getLoanById(loanId).firstOrNull() - if (loan != null) { - loan.timeline.actualDisbursementDate = listOf( - loan.timeline.actualDisburseDate?.year, - loan.timeline.actualDisburseDate?.month, - loan.timeline.actualDisburseDate?.date, + val updatedLoan = loan?.let { + val updatedTimeline = it.timeline.copy( + actualDisbursementDate = listOf( + it.timeline.actualDisburseDate?.year, + it.timeline.actualDisburseDate?.month, + it.timeline.actualDisburseDate?.date, + ), ) + it.copy(timeline = updatedTimeline) } - emit(loan) + + emit(updatedLoan) } } @@ -87,12 +96,15 @@ class LoanDaoHelper @Inject constructor( suspend fun saveLoanRepaymentTransaction( loanId: Int, loanRepaymentRequest: LoanRepaymentRequest, - ): LoanRepaymentResponse { // Setting Loan Id and Time Stamp - loanRepaymentRequest.loanId = loanId - loanRepaymentRequest.timeStamp = (System.currentTimeMillis() / 1000) + ): LoanRepaymentResponse { + // Setting Loan Id and Time Stamp + val updatedLoanRepaymentRequest = loanRepaymentRequest.copy( + loanId = loanId, + timeStamp = System.currentTimeMillis() / 1000, + ) // Saving Transaction In Database Table - loanDao.insertLoanRepaymentTransaction(loanRepaymentRequest) + loanDao.insertLoanRepaymentTransaction(updatedLoanRepaymentRequest) return LoanRepaymentResponse() } @@ -143,9 +155,11 @@ class LoanDaoHelper @Inject constructor( * @return List */ // TODO recheck logic in DatabaseHelperLoan.deleteAndUpdateLoanRepayments() - suspend fun deleteAndUpdateLoanRepayments(loanId: Int): Flow> { - loanDao.deleteLoanRepaymentByLoanId(loanId) - return loanDao.readAllLoanRepaymentTransaction() + fun deleteAndUpdateLoanRepayments(loanId: Int): Flow> { + return flow { + loanDao.deleteLoanRepaymentByLoanId(loanId) + emitAll(loanDao.readAllLoanRepaymentTransaction()) + } } /** @@ -160,12 +174,14 @@ class LoanDaoHelper @Inject constructor( loanId: Int, loanRepaymentTemplate: LoanRepaymentTemplate, ): LoanRepaymentTemplate { - loanRepaymentTemplate.loanId = loanId - loanRepaymentTemplate.paymentTypeOptions?.forEach { paymentTypeOption -> + val updatedLoanRepaymentTemplate = loanRepaymentTemplate.copy(loanId = loanId) + + updatedLoanRepaymentTemplate.paymentTypeOptions?.forEach { paymentTypeOption -> loanDao.insertPaymentTypeOption(paymentTypeOption) } - loanDao.insertLoanRepaymentTemplate(loanRepaymentTemplate) - return loanRepaymentTemplate + + loanDao.insertLoanRepaymentTemplate(updatedLoanRepaymentTemplate) + return updatedLoanRepaymentTemplate } /** @@ -187,15 +203,14 @@ class LoanDaoHelper @Inject constructor( */ fun getLoanRepayTemplate(loanId: Int): Flow { return flow { - val loanRepaymentTemplate = - loanDao.getLoanRepaymentTemplate(loanId).first().firstOrNull() + val loanRepaymentTemplate = loanDao.getLoanRepaymentTemplate(loanId) val paymentTypeOptions = loanDao.getPaymentTypeOptions().first() - if (loanRepaymentTemplate != null) { - loanRepaymentTemplate.paymentTypeOptions = paymentTypeOptions.toMutableList() - } + val updatedLoanRepaymentTemplate = loanRepaymentTemplate?.copy( + paymentTypeOptions = paymentTypeOptions.toMutableList(), + ) - emit(loanRepaymentTemplate) + emit(updatedLoanRepaymentTemplate) } } } diff --git a/core/network/src/main/java/com/mifos/core/network/datamanager/DataManagerLoan.kt b/core/network/src/main/java/com/mifos/core/network/datamanager/DataManagerLoan.kt index 406617f4b1..0c72977433 100644 --- a/core/network/src/main/java/com/mifos/core/network/datamanager/DataManagerLoan.kt +++ b/core/network/src/main/java/com/mifos/core/network/datamanager/DataManagerLoan.kt @@ -76,8 +76,7 @@ class DataManagerLoan @Inject constructor( */ fun syncLoanById(loanId: Int): Flow { return flow { - val loanWithAssociations = - mBaseApiManager.loanApi.getLoanByIdWithAllAssociations(loanId) + val loanWithAssociations = mBaseApiManager.loanApi.getLoanByIdWithAllAssociations(loanId) loanDaoHelper.saveLoanById(loanWithAssociations) emit(loanWithAssociations) } @@ -222,7 +221,7 @@ class DataManagerLoan @Inject constructor( * @param loanId Loan Id of the Loan * @return List */ - suspend fun deleteAndUpdateLoanRepayments(loanId: Int): Flow> { + fun deleteAndUpdateLoanRepayments(loanId: Int): Flow> { return loanDaoHelper.deleteAndUpdateLoanRepayments(loanId) } diff --git a/feature/center/src/main/java/com/mifos/feature/center/syncCentersDialog/SyncCentersDialogViewModel.kt b/feature/center/src/main/java/com/mifos/feature/center/syncCentersDialog/SyncCentersDialogViewModel.kt index 7fd80c3517..16249a1583 100644 --- a/feature/center/src/main/java/com/mifos/feature/center/syncCentersDialog/SyncCentersDialogViewModel.kt +++ b/feature/center/src/main/java/com/mifos/feature/center/syncCentersDialog/SyncCentersDialogViewModel.kt @@ -36,7 +36,6 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import retrofit2.HttpException @@ -367,7 +366,7 @@ class SyncCentersDialogViewModel @Inject constructor( loanWithAssociations, loanRepaymentTemplate, ) - }.flowOn(Dispatchers.IO) + } } /** diff --git a/feature/loan/src/main/java/com/mifos/feature/loan/loanAccountSummary/LoanAccountSummaryViewModel.kt b/feature/loan/src/main/java/com/mifos/feature/loan/loanAccountSummary/LoanAccountSummaryViewModel.kt index 5a82fb91a7..32eec06e43 100644 --- a/feature/loan/src/main/java/com/mifos/feature/loan/loanAccountSummary/LoanAccountSummaryViewModel.kt +++ b/feature/loan/src/main/java/com/mifos/feature/loan/loanAccountSummary/LoanAccountSummaryViewModel.kt @@ -17,11 +17,9 @@ import com.mifos.core.common.utils.Constants import com.mifos.core.data.repository.LoanAccountSummaryRepository import com.mifos.room.entities.accounts.loans.LoanWithAssociations import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.catch -import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.launch import javax.inject.Inject @@ -48,7 +46,6 @@ class LoanAccountSummaryViewModel @Inject constructor( _loanAccountSummaryUiState.value = LoanAccountSummaryUiState.ShowProgressbar repository.getLoanById(loanAccountNumber) - .flowOn(Dispatchers.IO) .catch { Log.d("ErrorDebug", it.message.toString()) _loanAccountSummaryUiState.value = diff --git a/feature/loan/src/main/java/com/mifos/feature/loan/loanRepayment/LoanRepaymentScreen.kt b/feature/loan/src/main/java/com/mifos/feature/loan/loanRepayment/LoanRepaymentScreen.kt index b0bc653fdd..2700e3978c 100644 --- a/feature/loan/src/main/java/com/mifos/feature/loan/loanRepayment/LoanRepaymentScreen.kt +++ b/feature/loan/src/main/java/com/mifos/feature/loan/loanRepayment/LoanRepaymentScreen.kt @@ -479,20 +479,19 @@ private fun ShowLoanRepaymentConfirmationDialog( onClick = { onDismiss() if (Network.isOnline(context)) { - val request = LoanRepaymentRequest() - - request.accountNumber = loanAccountNumber - request.paymentTypeId = paymentTypeId - request.dateFormat = "dd MM yyyy" - request.locale = "en" - request.transactionAmount = total - request.transactionDate = SimpleDateFormat( - "dd MMMM yyyy", - Locale.getDefault(), - ).format( - repaymentDate, + val request = LoanRepaymentRequest( + accountNumber = loanAccountNumber, + paymentTypeId = paymentTypeId, + dateFormat = "dd MM yyyy", + locale = "en", + transactionAmount = total, + transactionDate = SimpleDateFormat( + "dd MMMM yyyy", + Locale.getDefault(), + ).format( + repaymentDate, + ), ) - submitPayment.invoke(request) } else { Toast.makeText( diff --git a/feature/loan/src/main/java/com/mifos/feature/loan/loanRepayment/LoanRepaymentViewModel.kt b/feature/loan/src/main/java/com/mifos/feature/loan/loanRepayment/LoanRepaymentViewModel.kt index 1591dd7d9c..1b18322a2d 100644 --- a/feature/loan/src/main/java/com/mifos/feature/loan/loanRepayment/LoanRepaymentViewModel.kt +++ b/feature/loan/src/main/java/com/mifos/feature/loan/loanRepayment/LoanRepaymentViewModel.kt @@ -58,7 +58,6 @@ class LoanRepaymentViewModel @Inject constructor( _loanRepaymentUiState.value = LoanRepaymentUiState.ShowProgressbar repository.getLoanRepayTemplate(loanId) - .flowOn(Dispatchers.IO) .catch { Log.d("loanRepaymentLog ", ", $loanId ${it.message}") _loanRepaymentUiState.value = @@ -80,18 +79,16 @@ class LoanRepaymentViewModel @Inject constructor( viewModelScope.launch { _loanRepaymentUiState.value = LoanRepaymentUiState.ShowProgressbar - repository.submitPayment(loanId, request) - .flowOn(Dispatchers.IO) - .catch { - _loanRepaymentUiState.value = - LoanRepaymentUiState.ShowError(R.string.feature_loan_payment_failed) - } - .collect { loanRepaymentResponse -> - _loanRepaymentUiState.value = - LoanRepaymentUiState.ShowPaymentSubmittedSuccessfully( - loanRepaymentResponse, - ) - } + try { + val loanRepaymentResponse = repository.submitPayment(loanId, request) + _loanRepaymentUiState.value = + LoanRepaymentUiState.ShowPaymentSubmittedSuccessfully( + loanRepaymentResponse, + ) + } catch (e: Exception) { + _loanRepaymentUiState.value = + LoanRepaymentUiState.ShowError(R.string.feature_loan_payment_failed) + } } } diff --git a/feature/offline/src/main/java/com/mifos/feature/offline/dashboard/OfflineDashboardViewModel.kt b/feature/offline/src/main/java/com/mifos/feature/offline/dashboard/OfflineDashboardViewModel.kt index 30889781f2..d8c2d41e9f 100644 --- a/feature/offline/src/main/java/com/mifos/feature/offline/dashboard/OfflineDashboardViewModel.kt +++ b/feature/offline/src/main/java/com/mifos/feature/offline/dashboard/OfflineDashboardViewModel.kt @@ -95,25 +95,13 @@ class OfflineDashboardViewModel @Inject constructor( fun loadDatabaseLoanRepaymentTransactions() { viewModelScope.launch { - repository.databaseLoanRepayments().catch { e -> - setError(Type.SYNC_LOAN_REPAYMENTS, e.message.toString()) - }.collect { loanRepaymentRequests -> - setCountOfSyncData(Type.SYNC_LOAN_REPAYMENTS, loanRepaymentRequests.size) - } + repository.databaseLoanRepayments() + .catch { e -> + setError(Type.SYNC_LOAN_REPAYMENTS, e.message.toString()) + }.collect { loanRepaymentRequests -> + setCountOfSyncData(Type.SYNC_LOAN_REPAYMENTS, loanRepaymentRequests.size) + } } -// repository.databaseLoanRepayments() -// .observeOn(AndroidSchedulers.mainThread()) -// .subscribeOn(Schedulers.io()) -// .subscribe(object : Subscriber>() { -// override fun onCompleted() {} -// override fun onError(e: Throwable) { -// setError(Type.SYNC_LOAN_REPAYMENTS, e.message.toString()) -// } -// -// override fun onNext(loanRepaymentRequests: List) { -// setCountOfSyncData(Type.SYNC_LOAN_REPAYMENTS, loanRepaymentRequests.size) -// } -// }) } fun loadDatabaseSavingsAccountTransactions() { diff --git a/feature/offline/src/main/java/com/mifos/feature/offline/syncLoanRepaymentTransaction/SyncLoanRepaymentTransactionViewModel.kt b/feature/offline/src/main/java/com/mifos/feature/offline/syncLoanRepaymentTransaction/SyncLoanRepaymentTransactionViewModel.kt index 62993a8ef6..dc5bb85734 100644 --- a/feature/offline/src/main/java/com/mifos/feature/offline/syncLoanRepaymentTransaction/SyncLoanRepaymentTransactionViewModel.kt +++ b/feature/offline/src/main/java/com/mifos/feature/offline/syncLoanRepaymentTransaction/SyncLoanRepaymentTransactionViewModel.kt @@ -125,8 +125,9 @@ class SyncLoanRepaymentTransactionViewModel @Inject constructor( ) } } catch (e: Exception) { - val eLoanRepaymentRequest = mLoanRepaymentRequests[mClientSyncIndex] - eLoanRepaymentRequest.errorMessage = errorMessage.toString() + val eLoanRepaymentRequest = mLoanRepaymentRequests[mClientSyncIndex].copy( + errorMessage = errorMessage.toString(), + ) updateLoanRepayment(eLoanRepaymentRequest) } } diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/injection/module/RepositoryModule.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/injection/module/RepositoryModule.kt index 2b55f418eb..184140b4fc 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/injection/module/RepositoryModule.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/injection/module/RepositoryModule.kt @@ -9,6 +9,8 @@ */ package com.mifos.mifosxdroid.injection.module +import com.mifos.core.common.network.Dispatcher +import com.mifos.core.common.network.MifosDispatchers import com.mifos.core.data.repository.CreateNewClientRepository import com.mifos.core.data.repository.DocumentDialogRepository import com.mifos.core.data.repository.NoteRepository @@ -59,6 +61,7 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent +import kotlinx.coroutines.CoroutineDispatcher /** * Created by Aditya Gupta on 06/08/23. @@ -123,12 +126,15 @@ class RepositoryModule { dataManagerLoan: DataManagerLoan, dataManagerSavings: DataManagerSavings, dataManagerClient: DataManagerClient, + @Dispatcher(MifosDispatchers.IO) + ioDispatcher: CoroutineDispatcher, ): SyncGroupsDialogRepository { return SyncGroupsDialogRepositoryImp( dataManagerGroups, dataManagerLoan, dataManagerSavings, dataManagerClient, + ioDispatcher = ioDispatcher, ) } @@ -137,11 +143,14 @@ class RepositoryModule { dataManagerClient: DataManagerClient, dataManagerLoan: DataManagerLoan, dataManagerSavings: DataManagerSavings, + @Dispatcher(MifosDispatchers.IO) + ioDispatcher: CoroutineDispatcher, ): SyncClientsDialogRepository { return SyncClientsDialogRepositoryImp( dataManagerClient, dataManagerLoan, dataManagerSavings, + ioDispatcher = ioDispatcher, ) } @@ -152,6 +161,8 @@ class RepositoryModule { dataManagerSavings: DataManagerSavings, dataManagerGroups: DataManagerGroups, dataManagerClient: DataManagerClient, + @Dispatcher(MifosDispatchers.IO) + ioDispatcher: CoroutineDispatcher, ): SyncCentersDialogRepository { return SyncCentersDialogRepositoryImp( dataManagerCenter, @@ -159,6 +170,7 @@ class RepositoryModule { dataManagerSavings, dataManagerGroups, dataManagerClient, + ioDispatcher, ) } @@ -169,6 +181,8 @@ class RepositoryModule { dataManagerCenter: DataManagerCenter, dataManagerLoan: DataManagerLoan, dataManagerSavings: DataManagerSavings, + @Dispatcher(MifosDispatchers.IO) + ioDispatcher: CoroutineDispatcher, ): OfflineDashboardRepository { return OfflineDashboardRepositoryImp( dataManagerClient, @@ -176,6 +190,7 @@ class RepositoryModule { dataManagerCenter, dataManagerLoan, dataManagerSavings, + ioDispatcher, ) } @@ -188,13 +203,23 @@ class RepositoryModule { fun providesSyncSavingsAccountTransactionRepository( dataManagerSavings: DataManagerSavings, dataManagerLoan: DataManagerLoan, + @Dispatcher(MifosDispatchers.IO) + ioDispatcher: CoroutineDispatcher, ): SyncSavingsAccountTransactionRepository { - return SyncSavingsAccountTransactionRepositoryImp(dataManagerSavings, dataManagerLoan) + return SyncSavingsAccountTransactionRepositoryImp( + dataManagerSavings, + dataManagerLoan, + ioDispatcher, + ) } @Provides - fun providesSyncLoanRepaymentTransactionRepository(dataManagerLoan: DataManagerLoan): SyncLoanRepaymentTransactionRepository { - return SyncLoanRepaymentTransactionRepositoryImp(dataManagerLoan) + fun providesSyncLoanRepaymentTransactionRepository( + dataManagerLoan: DataManagerLoan, + @Dispatcher(MifosDispatchers.IO) + ioDispatcher: CoroutineDispatcher, + ): SyncLoanRepaymentTransactionRepository { + return SyncLoanRepaymentTransactionRepositoryImp(dataManagerLoan, ioDispatcher) } @Provides