Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c8529d6
feat: general tab screen for loan account
amanna13 Mar 2, 2026
2fc67ac
feat: general tab loan section
amanna13 Mar 2, 2026
835dc60
fix: minor changes in ui
amanna13 Mar 2, 2026
f558cc5
fix: resolved conflicts and navigation wiring
amanna13 Mar 3, 2026
aa92e0c
fix: changed text to camel case
amanna13 Mar 3, 2026
2f66d5d
fix: cleanup unused code
amanna13 Mar 4, 2026
5957603
fix: updated the currency formatter to use already available component
amanna13 Mar 4, 2026
3643e1d
fix: restructured use of DateHelper
amanna13 Mar 4, 2026
66ad3df
fix: refactor LoanAccountGeneralScreen to use when(state) for UI stat…
amanna13 Mar 4, 2026
387b2b5
fix: refactored certain use of variables
amanna13 Mar 4, 2026
8226ed8
fix: fixed table ui
amanna13 Mar 4, 2026
6620c66
fix: fixed static checks
amanna13 Mar 4, 2026
08757f3
fix: fixed addressed changes
amanna13 Mar 11, 2026
8ca66b3
fix: updated incorrect copyright docs
amanna13 Mar 13, 2026
b2b701d
fix: fixed changes requested
amanna13 Mar 27, 2026
b31cb6c
fix: fixed the unknown error throw
amanna13 Mar 27, 2026
668e71f
fix: changed route to use required arg with no default
amanna13 Apr 2, 2026
5d7c0dc
fix: use of specific error msg in viewmodel
amanna13 Apr 3, 2026
200730d
fix: changed continuous network monitoring to one-time only
amanna13 Apr 7, 2026
2400311
fix: fixed empty values in entity and structured loanWithAssociation
amanna13 Apr 7, 2026
6b25f3b
fix: used abstract mapper
amanna13 Apr 7, 2026
709f801
fix: replaced hardcoded principal waived
amanna13 Apr 7, 2026
e3f232a
fix: Network monitor moved to repository layer
amanna13 Apr 9, 2026
d6ed44d
fix: updated screen to use theme-aware dynamic colors
amanna13 Apr 9, 2026
a06cd12
fix: wrong mapping of proposedAmount
amanna13 Apr 10, 2026
7eda71d
fix: changed Map to use sealed interface
amanna13 Apr 10, 2026
4bf8325
fix: refactored to use helper function for currency formatter
amanna13 Apr 10, 2026
528d8a3
fix: fixed network monitor implementation
amanna13 Apr 23, 2026
bfe042b
fix: fixed license issues
amanna13 Apr 23, 2026
5e94fef
fix: license issues across files static checks failures
amanna13 Apr 23, 2026
5f1a1b8
fix : merge conflicts resolved
Kartikey15dem May 17, 2026
92a8106
fix : dto and mappers added
Kartikey15dem May 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import com.mifos.core.data.repository.GroupsListRepository
import com.mifos.core.data.repository.IndividualCollectionSheetDetailsRepository
import com.mifos.core.data.repository.LoanAccountApprovalRepository
import com.mifos.core.data.repository.LoanAccountDisbursementRepository
import com.mifos.core.data.repository.LoanAccountGeneralRepository
import com.mifos.core.data.repository.LoanAccountRepository
import com.mifos.core.data.repository.LoanAccountSummaryRepository
import com.mifos.core.data.repository.LoanChargeFormRepository
Expand Down Expand Up @@ -111,6 +112,7 @@ import com.mifos.core.data.repositoryImp.GroupsListRepositoryImpl
import com.mifos.core.data.repositoryImp.IndividualCollectionSheetDetailsRepositoryImp
import com.mifos.core.data.repositoryImp.LoanAccountApprovalRepositoryImp
import com.mifos.core.data.repositoryImp.LoanAccountDisbursementRepositoryImp
import com.mifos.core.data.repositoryImp.LoanAccountGeneralRepositoryImp
import com.mifos.core.data.repositoryImp.LoanAccountRepositoryImp
import com.mifos.core.data.repositoryImp.LoanAccountSummaryRepositoryImp
import com.mifos.core.data.repositoryImp.LoanChargeFormRepositoryImp
Expand Down Expand Up @@ -190,6 +192,7 @@ val RepositoryModule = module {
singleOf(::LoanAccountRepositoryImp) bind LoanAccountRepository::class
singleOf(::LoanAccountApprovalRepositoryImp) bind LoanAccountApprovalRepository::class
singleOf(::LoanAccountDisbursementRepositoryImp) bind LoanAccountDisbursementRepository::class
singleOf(::LoanAccountGeneralRepositoryImp) bind LoanAccountGeneralRepository::class
singleOf(::LoanAccountSummaryRepositoryImp) bind LoanAccountSummaryRepository::class
singleOf(::LoanChargeFormRepositoryImp) bind LoanChargeFormRepository::class
singleOf(::LoanChargeRepositoryImp) bind LoanChargeRepository::class
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2026 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mifos-x-field-officer-app/blob/master/LICENSE.md
*/
package com.mifos.core.data.repository

import com.mifos.core.common.utils.DataState
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
import kotlinx.coroutines.flow.Flow

interface LoanAccountGeneralRepository {

fun getLoanById(loanId: Int): Flow<DataState<LoanWithAssociations?>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
package com.mifos.core.data.repository

import com.mifos.core.common.utils.DataState
import com.mifos.room.entities.accounts.loans.LoanWithAssociationsEntity
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
import kotlinx.coroutines.flow.Flow

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

fun getLoanById(loanId: Int): Flow<DataState<LoanWithAssociationsEntity?>>
fun getLoanById(loanId: Int): Flow<DataState<LoanWithAssociations?>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
package com.mifos.core.data.repository

import com.mifos.core.common.utils.DataState
import com.mifos.room.entities.accounts.loans.LoanWithAssociationsEntity
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
import kotlinx.coroutines.flow.Flow

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

fun getLoanRepaySchedule(loanId: Int): Flow<DataState<LoanWithAssociationsEntity>>
fun getLoanRepaySchedule(loanId: Int): Flow<DataState<LoanWithAssociations>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
package com.mifos.core.data.repository

import com.mifos.core.common.utils.DataState
import com.mifos.room.entities.accounts.loans.LoanWithAssociationsEntity
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
import kotlinx.coroutines.flow.Flow

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

fun getLoanTransactions(loan: Int): Flow<DataState<LoanWithAssociationsEntity>>
fun getLoanTransactions(loan: Int): Flow<DataState<LoanWithAssociations>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
package com.mifos.core.data.repository

import com.mifos.core.common.utils.DataState
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
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.LoanWithAssociationsEntity
import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociationsEntity
import com.mifos.room.entities.client.ClientEntity
import com.mifos.room.entities.group.CenterEntity
Expand All @@ -31,7 +31,7 @@ interface SyncCentersDialogRepository {

fun syncCenterAccounts(centerId: Int): Flow<DataState<CenterAccounts>>

fun syncLoanById(loanId: Int): Flow<DataState<LoanWithAssociationsEntity>>
fun syncLoanById(loanId: Int): Flow<DataState<LoanWithAssociations>>

fun syncLoanRepaymentTemplate(loanId: Int): Flow<DataState<LoanRepaymentTemplateEntity>>

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

import com.mifos.core.common.utils.DataState
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
import com.mifos.room.entities.accounts.ClientAccounts
import com.mifos.room.entities.accounts.loans.LoanWithAssociationsEntity
import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociationsEntity
import com.mifos.room.entities.client.ClientEntity
import com.mifos.room.entities.templates.loans.LoanRepaymentTemplateEntity
Expand All @@ -25,7 +25,7 @@ interface SyncClientsDialogRepository {

suspend fun syncClientAccounts(clientId: Int): ClientAccounts

fun syncLoanById(loanId: Int): Flow<DataState<LoanWithAssociationsEntity>>
fun syncLoanById(loanId: Int): Flow<DataState<LoanWithAssociations>>

fun syncLoanRepaymentTemplate(loanId: Int): Flow<DataState<LoanRepaymentTemplateEntity>>

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

import com.mifos.core.common.utils.DataState
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
import com.mifos.room.entities.accounts.ClientAccounts
import com.mifos.room.entities.accounts.GroupAccounts
import com.mifos.room.entities.accounts.loans.LoanWithAssociationsEntity
import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociationsEntity
import com.mifos.room.entities.client.ClientEntity
import com.mifos.room.entities.group.GroupEntity
Expand All @@ -28,7 +28,7 @@ interface SyncGroupsDialogRepository {

fun syncGroupAccounts(groupId: Int): Flow<DataState<GroupAccounts>>

fun syncLoanById(loanId: Int): Flow<DataState<LoanWithAssociationsEntity>>
fun syncLoanById(loanId: Int): Flow<DataState<LoanWithAssociations>>

fun syncLoanRepaymentTemplate(loanId: Int): Flow<DataState<LoanRepaymentTemplateEntity>>

Expand Down

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation mixes concerns (network state handling, error mapping, and data fetching) and may lead to incorrect behavior (e.g., combine triggering network calls even when offline). It would be better to align on the expected architecture and responsibilities first.

I’d suggest discussing this approach with @niyajali on Slack before proceeding with further implementation.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2026 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mifos-x-field-officer-app/blob/master/LICENSE.md
*/
package com.mifos.core.data.repositoryImp

import com.mifos.core.common.utils.DataState
import com.mifos.core.common.utils.asDataStateFlow
import com.mifos.core.data.repository.LoanAccountGeneralRepository
import com.mifos.core.data.util.NetworkMonitor
import com.mifos.core.data.util.withNetworkCheck
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
import com.mifos.core.network.datamanager.DataManagerLoan
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOn

class LoanAccountGeneralRepositoryImp(
private val dataManagerLoan: DataManagerLoan,
private val networkMonitor: NetworkMonitor,
private val ioDispatcher: CoroutineDispatcher,
) : LoanAccountGeneralRepository {

override fun getLoanById(loanId: Int): Flow<DataState<LoanWithAssociations?>> {
return networkMonitor.withNetworkCheck(
dataManagerLoan.getLoanById(loanId)
.asDataStateFlow(),
).flowOn(ioDispatcher)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ package com.mifos.core.data.repositoryImp
import com.mifos.core.common.utils.DataState
import com.mifos.core.common.utils.asDataStateFlow
import com.mifos.core.data.repository.LoanAccountSummaryRepository
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
import com.mifos.core.network.datamanager.DataManagerLoan
import com.mifos.room.entities.accounts.loans.LoanWithAssociationsEntity
import kotlinx.coroutines.flow.Flow

/**
Expand All @@ -23,7 +23,7 @@ class LoanAccountSummaryRepositoryImp(
private val dataManagerLoan: DataManagerLoan,
) : LoanAccountSummaryRepository {

override fun getLoanById(loanId: Int): Flow<DataState<LoanWithAssociationsEntity?>> {
override fun getLoanById(loanId: Int): Flow<DataState<LoanWithAssociations?>> {
return dataManagerLoan.getLoanById(loanId)
.asDataStateFlow()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ package com.mifos.core.data.repositoryImp
import com.mifos.core.common.utils.DataState
import com.mifos.core.common.utils.asDataStateFlow
import com.mifos.core.data.repository.LoanRepaymentScheduleRepository
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
import com.mifos.core.network.DataManager
import com.mifos.room.entities.accounts.loans.LoanWithAssociationsEntity
import com.mifos.core.network.mappers.loan.toDomain
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

/**
* Created by Aditya Gupta on 12/08/23.
Expand All @@ -23,7 +25,8 @@ class LoanRepaymentScheduleRepositoryImp(
private val dataManager: DataManager,
) : LoanRepaymentScheduleRepository {

override fun getLoanRepaySchedule(loanId: Int): Flow<DataState<LoanWithAssociationsEntity>> {
return dataManager.getLoanRepaySchedule(loanId).asDataStateFlow()
override fun getLoanRepaySchedule(loanId: Int): Flow<DataState<LoanWithAssociations>> {
return dataManager.getLoanRepaySchedule(loanId).map { it.toDomain() }
.asDataStateFlow()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ package com.mifos.core.data.repositoryImp
import com.mifos.core.common.utils.DataState
import com.mifos.core.common.utils.asDataStateFlow
import com.mifos.core.data.repository.LoanTransactionsRepository
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
import com.mifos.core.network.DataManager
import com.mifos.room.entities.accounts.loans.LoanWithAssociationsEntity
import com.mifos.core.network.mappers.loan.toDomain
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

/**
* Created by Aditya Gupta on 12/08/23.
Expand All @@ -23,7 +25,8 @@ class LoanTransactionsRepositoryImp(
private val dataManager: DataManager,
) : LoanTransactionsRepository {

override fun getLoanTransactions(loan: Int): Flow<DataState<LoanWithAssociationsEntity>> {
return dataManager.getLoanTransactions(loan).asDataStateFlow()
override fun getLoanTransactions(loan: Int): Flow<DataState<LoanWithAssociations>> {
return dataManager.getLoanTransactions(loan).map { it.toDomain() }
.asDataStateFlow()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package com.mifos.core.data.repositoryImp
import com.mifos.core.common.utils.DataState
import com.mifos.core.common.utils.asDataStateFlow
import com.mifos.core.data.repository.SyncCentersDialogRepository
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
import com.mifos.core.network.datamanager.DataManagerCenter
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.network.datamanager.DataManagerGroups
Expand All @@ -20,7 +21,6 @@ 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.LoanWithAssociationsEntity
import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociationsEntity
import com.mifos.room.entities.client.ClientEntity
import com.mifos.room.entities.group.CenterEntity
Expand All @@ -47,7 +47,7 @@ class SyncCentersDialogRepositoryImp(
.asDataStateFlow()
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ package com.mifos.core.data.repositoryImp
import com.mifos.core.common.utils.DataState
import com.mifos.core.common.utils.asDataStateFlow
import com.mifos.core.data.repository.SyncClientsDialogRepository
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.network.datamanager.DataManagerLoan
import com.mifos.core.network.datamanager.DataManagerSavings
import com.mifos.room.entities.accounts.ClientAccounts
import com.mifos.room.entities.accounts.loans.LoanWithAssociationsEntity
import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociationsEntity
import com.mifos.room.entities.client.ClientEntity
import com.mifos.room.entities.templates.loans.LoanRepaymentTemplateEntity
Expand All @@ -36,7 +36,7 @@ class SyncClientsDialogRepositoryImp(
return dataManagerClient.getClientAccounts(clientId)
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ package com.mifos.core.data.repositoryImp
import com.mifos.core.common.utils.DataState
import com.mifos.core.common.utils.asDataStateFlow
import com.mifos.core.data.repository.SyncGroupsDialogRepository
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations
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.ClientAccounts
import com.mifos.room.entities.accounts.GroupAccounts
import com.mifos.room.entities.accounts.loans.LoanWithAssociationsEntity
import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociationsEntity
import com.mifos.room.entities.client.ClientEntity
import com.mifos.room.entities.group.GroupEntity
Expand All @@ -42,7 +42,7 @@ class SyncGroupsDialogRepositoryImp(
.asDataStateFlow()
}

override fun syncLoanById(loanId: Int): Flow<DataState<LoanWithAssociationsEntity>> {
override fun syncLoanById(loanId: Int): Flow<DataState<LoanWithAssociations>> {
return dataManagerLoan.syncLoanById(loanId)
.asDataStateFlow()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import com.mifos.room.dao.SurveyDao
import com.mifos.room.entities.PaymentTypeOptionEntity
import com.mifos.room.entities.accounts.loans.ActualDisbursementDateEntity
import com.mifos.room.entities.accounts.loans.LoanAccountEntity
import com.mifos.room.entities.accounts.loans.LoanAccountSummaryEntity
import com.mifos.room.entities.accounts.loans.LoanRepaymentRequestEntity
import com.mifos.room.entities.accounts.loans.LoanRepaymentResponseEntity
import com.mifos.room.entities.accounts.loans.LoanStatusEntity
import com.mifos.room.entities.accounts.loans.LoanTimelineEntity
import com.mifos.room.entities.accounts.loans.LoanTypeEntity
import com.mifos.room.entities.accounts.loans.LoanWithAssociationsEntity
import com.mifos.room.entities.accounts.loans.LoansAccountSummaryEntity
import com.mifos.room.entities.accounts.savings.SavingAccountCurrencyEntity
import com.mifos.room.entities.accounts.savings.SavingAccountDepositTypeEntity
import com.mifos.room.entities.accounts.savings.SavingsAccountEntity
Expand Down Expand Up @@ -90,7 +90,7 @@ import com.mifos.room.typeconverters.CustomTypeConverters
LoanStatusEntity::class,
LoanTypeEntity::class,
LoanWithAssociationsEntity::class,
LoansAccountSummaryEntity::class,
LoanAccountSummaryEntity::class,
LoanTimelineEntity::class,
// savings package
SavingAccountDepositTypeEntity::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ data class Loan(

val timeline: LoanTimelineEntity? = null,

val summary: LoansAccountSummaryEntity? = null,
val summary: LoanAccountSummaryEntity? = null,

val feeChargesAtDisbursementCharged: Double? = null,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import template.core.base.database.PrimaryKey
)
@Serializable
@Parcelize
data class LoansAccountSummaryEntity(
data class LoanAccountSummaryEntity(
@PrimaryKey(autoGenerate = true)
val loanId: Int? = null,

Expand All @@ -38,6 +38,8 @@ data class LoansAccountSummaryEntity(

val principalPaid: Double? = null,

val principalWaived: Double? = null,

val principalWrittenOff: Double? = null,

val principalOutstanding: Double? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
*/
package com.mifos.room.entities.accounts.loans

import com.mifos.core.model.utils.Parcelable
import com.mifos.core.model.utils.Parcelize
import kotlinx.serialization.Serializable
import com.mifos.core.model.objects.account.loan.loanWithAssociations.LoanWithAssociations

@Parcelize
@Serializable
data class LoanApprovalData(
val loanID: Int,
val loanWithAssociations: LoanWithAssociationsEntity,
) : Parcelable
val loanWithAssociations: LoanWithAssociations,
)
Loading
Loading