Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmp-navigation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ kotlin {
implementation(projects.feature.settings)
implementation(projects.feature.search)
implementation(projects.feature.searchRecord)
implementation(projects.feature.standingInstruction)
implementation(projects.feature.passcode)

implementation(compose.material3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.mifos.feature.savings.di.SavingsModule
import com.mifos.feature.search.di.SearchModule
import com.mifos.feature.searchrecord.di.SearchRecordModule
import com.mifos.feature.settings.di.SettingsModule
import com.mifos.feature.standingInstruction.di.StandingInstructionsModule
import com.mifos.room.di.DaoModule
import com.mifos.room.di.HelperModule
import com.mifos.room.di.PlatformSpecificDatabaseModule
Expand Down Expand Up @@ -94,6 +95,7 @@ object KoinModules {
SettingsModule,
SearchRecordModule,
MifosAuthenticatorModule,
StandingInstructionsModule,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,10 @@ object Constants {
const val POSTAL_CODE = "postalCode"
const val STATUS = "status"
const val DOCUMENT_KEY = "documentKey"

/**
* Constant values for standing instructions account type
*/
const val LOAN_ACCOUNT_VAL = 1
const val SAVINGS_ACCOUNT_VAL = 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import com.mifos.core.data.repository.SearchRecordRepository
import com.mifos.core.data.repository.SearchRepository
import com.mifos.core.data.repository.ShareAccountRepository
import com.mifos.core.data.repository.SignatureRepository
import com.mifos.core.data.repository.StandingInstructionsRepository
import com.mifos.core.data.repository.SurveyListRepository
import com.mifos.core.data.repository.SurveySubmitRepository
import com.mifos.core.data.repository.SyncCenterPayloadsRepository
Expand Down Expand Up @@ -133,6 +134,7 @@ import com.mifos.core.data.repositoryImp.SearchRecordRepositoryImpl
import com.mifos.core.data.repositoryImp.SearchRepositoryImp
import com.mifos.core.data.repositoryImp.ShareAccountRepositoryImpl
import com.mifos.core.data.repositoryImp.SignatureRepositoryImp
import com.mifos.core.data.repositoryImp.StandingInstructionsRepositoryImp
import com.mifos.core.data.repositoryImp.SurveyListRepositoryImp
import com.mifos.core.data.repositoryImp.SurveySubmitRepositoryImp
import com.mifos.core.data.repositoryImp.SyncCenterPayloadsRepositoryImp
Expand Down Expand Up @@ -221,6 +223,9 @@ val RepositoryModule = module {
singleOf(::SavingsAccountTransactionRepositoryImp) bind SavingsAccountTransactionRepository::class
singleOf(::SavingsAccountTransactionReceiptRepositoryImpl) bind SavingsAccountTransactionReceiptRepository::class

// Standing Instructions
singleOf(::StandingInstructionsRepositoryImp) bind StandingInstructionsRepository::class

// Sync
singleOf(::SyncCenterPayloadsRepositoryImp) bind SyncCenterPayloadsRepository::class
singleOf(::SyncCentersDialogRepositoryImp) bind SyncCentersDialogRepository::class
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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.mappers.standingInstructions

import com.mifos.core.model.objects.standingInstructions.StandingInstruction
import com.mifos.core.model.objects.standingInstructions.StandingInstructionAccount
import com.mifos.core.model.objects.standingInstructions.StandingInstructionClient
import com.mifos.core.network.dto.standingInstruction.StandingInstructionDto
import com.mifos.room.entities.standingInstructions.StandingInstructionAccountEntity
import com.mifos.room.entities.standingInstructions.StandingInstructionClientEntity
import com.mifos.room.entities.standingInstructions.StandingInstructionEntity

fun StandingInstructionDto.toEntity(): StandingInstructionEntity {
return StandingInstructionEntity(
id = this.id,
amount = this.amount,
validFrom = this.validFrom,
fromClient = this.fromClient?.let { StandingInstructionClientEntity(it.id, it.displayName) },
toClient = this.toClient?.let { StandingInstructionClientEntity(it.id, it.displayName) },
fromAccount = this.fromAccount?.let { StandingInstructionAccountEntity(it.id, it.accountNo, it.productName) },
toAccount = this.toAccount?.let {
StandingInstructionAccountEntity(
it.id,
it.accountNo,
it.productName,
)
},
)
}

fun StandingInstructionEntity.toDomain(): StandingInstruction {
return StandingInstruction(
id = this.id,
amount = this.amount,
validFrom = this.validFrom,
fromClient = this.fromClient?.toDomain(),
toClient = this.toClient?.toDomain(),
fromAccount = this.fromAccount?.toDomain(),
toAccount = this.toAccount?.toDomain(),
)
}

fun StandingInstructionClientEntity.toDomain(): StandingInstructionClient {
return StandingInstructionClient(
id = this.id,
displayName = this.displayName,
)
}

fun StandingInstructionAccountEntity.toDomain(): StandingInstructionAccount {
return StandingInstructionAccount(
id = this.id,
accountNo = this.accountNo,
productName = this.productName,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.mappers.standingInstructions

import com.mifos.core.model.objects.standingInstructions.StandingInstruction
import com.mifos.core.model.objects.standingInstructions.StandingInstructionAccount
import com.mifos.core.model.objects.standingInstructions.StandingInstructionClient
import com.mifos.core.model.objects.standingInstructions.StandingInstructionUpdate
import com.mifos.core.network.dto.standingInstruction.ClientDto
import com.mifos.core.network.dto.standingInstruction.StandingInstructionAccountDto
import com.mifos.core.network.dto.standingInstruction.StandingInstructionDto
import com.mifos.core.network.dto.standingInstruction.UpdateStandingInstructionDto

fun StandingInstructionDto.toDomain(): StandingInstruction {
return StandingInstruction(
id = this.id,
amount = this.amount,
validFrom = this.validFrom,
fromClient = this.fromClient?.toDomain(),
toClient = this.toClient?.toDomain(),
fromAccount = this.fromAccount?.toDomain(),
toAccount = this.toAccount?.toDomain(),
)
}

fun ClientDto.toDomain(): StandingInstructionClient {
return StandingInstructionClient(
id = this.id,
displayName = this.displayName,
)
}

fun StandingInstructionAccountDto.toDomain(): StandingInstructionAccount {
return StandingInstructionAccount(
id = this.id,
accountNo = this.accountNo,
productName = this.productName,
)
}

fun StandingInstructionUpdate.toDto(): UpdateStandingInstructionDto {
return UpdateStandingInstructionDto(
amount = this.amount,
validFrom = this.validFrom,
locale = this.locale,
dateFormat = this.dateFormat,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.common.utils.Page
import com.mifos.core.model.objects.standingInstructions.StandingInstruction
import com.mifos.core.model.objects.standingInstructions.StandingInstructionUpdate
import kotlinx.coroutines.flow.Flow

/**
* Created by Shlok Sharma(techsavvy185) on 19/06/2026.
*/
interface StandingInstructionsRepository {
fun getStandingInstructionList(
clientId: Long,
clientName: String,
fromAccountType: Int,
fromAccountId: Long,
limit: Int,
offset: Int,
): Flow<DataState<Page<StandingInstruction>>>

suspend fun updateStandingInstruction(
standingInstructionId: Long,
update: StandingInstructionUpdate,
): DataState<Unit>

suspend fun deleteStandingInstruction(
standingInstructionId: Long,
): DataState<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* 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.Page
import com.mifos.core.common.utils.asDataStateFlow
import com.mifos.core.data.mappers.standingInstructions.toDomain
import com.mifos.core.data.mappers.standingInstructions.toDto
import com.mifos.core.data.repository.StandingInstructionsRepository
import com.mifos.core.data.util.NetworkMonitor
import com.mifos.core.data.util.runAsDataState
import com.mifos.core.data.util.withNetworkCheck
import com.mifos.core.model.objects.standingInstructions.StandingInstruction
import com.mifos.core.model.objects.standingInstructions.StandingInstructionUpdate
import com.mifos.core.network.datamanager.DataManagerStandingInstructions
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import template.core.base.common.manager.DispatcherManager

class StandingInstructionsRepositoryImp(
private val dataManagerStandingInstructions: DataManagerStandingInstructions,
private val networkMonitor: NetworkMonitor,
private val dispatcher: DispatcherManager,
) : StandingInstructionsRepository {

override fun getStandingInstructionList(
clientId: Long,
clientName: String,
fromAccountType: Int,
fromAccountId: Long,
limit: Int,
offset: Int,
): Flow<DataState<Page<StandingInstruction>>> {
return networkMonitor.withNetworkCheck(
dataManagerStandingInstructions
.retrieveListStandingInstructions(
clientId = clientId,
clientName = clientName,
fromAccountType = fromAccountType,
fromAccountId = fromAccountId,
limit = limit,
offset = offset,
)
.map { pageDto ->
Page(
totalFilteredRecords = pageDto.totalFilteredRecords,
pageItems = pageDto.pageItems.map { it.toDomain() },
)
}
.asDataStateFlow(),
).flowOn(dispatcher.io)
}

override suspend fun updateStandingInstruction(
standingInstructionId: Long,
update: StandingInstructionUpdate,
): DataState<Unit> {
return runAsDataState(
networkMonitor,
dispatcher.io,
) {
dataManagerStandingInstructions.updateStandingInstruction(
standingInstructionId,
update.toDto(),
)
}
}

override suspend fun deleteStandingInstruction(
standingInstructionId: Long,
): DataState<Unit> {
return runAsDataState(
networkMonitor,
dispatcher.io,
) {
dataManagerStandingInstructions.deleteStandingInstruction(
standingInstructionId,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ object APIEndPoint {
const val FIXED_DEPOSIT = "fixeddepositaccounts"
const val ACCOUNT_TRANSFERS = "accounttransfers"
const val RESCHEDULE_LOANS = "rescheduleloans"
const val STANDING_INSTRUCTIONS = "standinginstructions"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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.room.entities.standingInstructions

data class StandingInstructionAccountEntity(
val id: Int? = null,
val accountNo: String? = null,
val productName: String? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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.room.entities.standingInstructions

data class StandingInstructionClientEntity(
val id: Int? = null,
val displayName: String? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2025 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.room.entities.standingInstructions

import template.core.base.database.Entity
import template.core.base.database.PrimaryKey

@Entity(
tableName = "StandingInstruction",
indices = [],
inheritSuperIndices = false,
primaryKeys = [],
ignoredColumns = [],
foreignKeys = [],
)
data class StandingInstructionEntity(
@PrimaryKey(autoGenerate = false)
val id: Int,

val amount: Double? = null,

val validFrom: String? = null,

val fromClient: StandingInstructionClientEntity? = null,

val toClient: StandingInstructionClientEntity? = null,

val fromAccount: StandingInstructionAccountEntity? = null,

val toAccount: StandingInstructionAccountEntity? = null,
)
Loading
Loading