Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ import com.mifos.core.data.repository.SyncLoanRepaymentTransactionRepository
import com.mifos.core.data.repository.SyncSavingsAccountTransactionRepository
import com.mifos.core.data.repository.UserVerificationRepository
import com.mifos.core.data.repository.loan.LoanAccountApprovalRepository
import com.mifos.core.data.repository.loan.LoanAccountDisbursementRepository
import com.mifos.core.data.repository.loan.LoanAccountRepository
import com.mifos.core.data.repository.loan.LoanAccountSummaryRepository
import com.mifos.core.data.repository.loan.LoanChargeFormRepository
import com.mifos.core.data.repository.loan.LoanChargeOffRepository
import com.mifos.core.data.repository.loan.LoanChargeRepository
import com.mifos.core.data.repository.loan.LoanCreateGuarantorRepository
import com.mifos.core.data.repository.loan.LoanDisburseRepository
import com.mifos.core.data.repository.loan.LoanOfficerRepository
import com.mifos.core.data.repository.loan.LoanRepaymentRepository
import com.mifos.core.data.repository.loan.LoanRepaymentScheduleRepository
Expand Down Expand Up @@ -144,13 +144,13 @@ import com.mifos.core.data.repositoryImp.SyncLoanRepaymentTransactionRepositoryI
import com.mifos.core.data.repositoryImp.SyncSavingsAccountTransactionRepositoryImp
import com.mifos.core.data.repositoryImp.UserVerificationRepositoryImpl
import com.mifos.core.data.repositoryImp.loan.LoanAccountApprovalRepositoryImp
import com.mifos.core.data.repositoryImp.loan.LoanAccountDisbursementRepositoryImp
import com.mifos.core.data.repositoryImp.loan.LoanAccountRepositoryImp
import com.mifos.core.data.repositoryImp.loan.LoanAccountSummaryRepositoryImp
import com.mifos.core.data.repositoryImp.loan.LoanChargeFormRepositoryImp
import com.mifos.core.data.repositoryImp.loan.LoanChargeOffRepositoryImpl
import com.mifos.core.data.repositoryImp.loan.LoanChargeRepositoryImp
import com.mifos.core.data.repositoryImp.loan.LoanCreateGuarantorRepositoryImp
import com.mifos.core.data.repositoryImp.loan.LoanDisburseRepositoryImpl
import com.mifos.core.data.repositoryImp.loan.LoanOfficerRepositoryImpl
import com.mifos.core.data.repositoryImp.loan.LoanRepaymentRepositoryImp
import com.mifos.core.data.repositoryImp.loan.LoanRepaymentScheduleRepositoryImp
Expand Down Expand Up @@ -195,7 +195,6 @@ val RepositoryModule = module {
// Loan
singleOf(::LoanAccountRepositoryImp) bind LoanAccountRepository::class
singleOf(::LoanAccountApprovalRepositoryImp) bind LoanAccountApprovalRepository::class
singleOf(::LoanAccountDisbursementRepositoryImp) bind LoanAccountDisbursementRepository::class
singleOf(::LoanAccountSummaryRepositoryImp) bind LoanAccountSummaryRepository::class
singleOf(::LoanChargeFormRepositoryImp) bind LoanChargeFormRepository::class
singleOf(::LoanChargeRepositoryImp) bind LoanChargeRepository::class
Expand All @@ -204,6 +203,7 @@ val RepositoryModule = module {
singleOf(::LoanTransactionsRepositoryImp) bind LoanTransactionsRepository::class
singleOf(::LoanReschedulesRepositoryImpl) bind LoanReschedulesRepository::class
singleOf(::LoanChargeOffRepositoryImpl) bind LoanChargeOffRepository::class
singleOf(::LoanDisburseRepositoryImpl) bind LoanDisburseRepository::class
singleOf(::LoanCreateGuarantorRepositoryImp) bind LoanCreateGuarantorRepository::class
singleOf(::LoanOfficerRepositoryImpl) bind LoanOfficerRepository::class

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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

import com.mifos.core.model.objects.account.loan.Currency
import com.mifos.core.network.dto.CurrencyDto

fun CurrencyDto.toModel(): Currency = Currency(
code = code,
name = name,
decimalPlaces = decimalPlaces,
inMultiplesOf = inMultiplesOf,
displaySymbol = displaySymbol,
nameCode = nameCode,
displayLabel = displayLabel,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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

import com.mifos.core.model.objects.account.loan.PaymentType
import com.mifos.core.network.dto.PaymentTypeOptionDto

fun PaymentTypeOptionDto.toModel(): PaymentType = PaymentType(
id = id,
name = name,
)
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.mappers.loan

import com.mifos.core.data.mappers.toModel
import com.mifos.core.model.objects.account.loan.Currency
import com.mifos.core.model.objects.account.loan.loanDisburse.LoanDisburseInput
import com.mifos.core.model.objects.account.loan.loanDisburse.LoanDisburseTemplate
import com.mifos.core.network.dto.loans.disburse.LoanDisburseRequestDto
import com.mifos.core.network.dto.loans.template.LoanDisburseTemplateDto

fun LoanDisburseInput.toDto(): LoanDisburseRequestDto = LoanDisburseRequestDto(
actualDisbursementDate = actualDisbursementDate,
transactionAmount = transactionAmount,
paymentTypeId = paymentTypeId,
note = note,
externalId = externalId,
accountNumber = accountNumber,
checkNumber = checkNumber,
routingCode = routingCode,
receiptNumber = receiptNumber,
bankNumber = bankNumber,
locale = locale,
dateFormat = dateFormat,
)

fun LoanDisburseTemplateDto.toModel(): LoanDisburseTemplate = LoanDisburseTemplate(
netDisbursalAmount = netDisbursalAmount,
date = date,
currency = currency?.toModel() ?: Currency(),
paymentTypeOptions = paymentTypeOptions.map { it.toModel() },
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.loan

import com.mifos.core.common.utils.DataState
import com.mifos.core.model.objects.account.loan.loanDisburse.LoanDisburseInput
import com.mifos.core.model.objects.account.loan.loanDisburse.LoanDisburseTemplate

interface LoanDisburseRepository {

suspend fun getDisburseTemplate(loanId: Int): DataState<LoanDisburseTemplate>

suspend fun disburse(loanId: Int, loanDisburseInput: LoanDisburseInput): DataState<Unit>
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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.loan

import com.mifos.core.common.utils.DataState
import com.mifos.core.data.mappers.loan.toDto
import com.mifos.core.data.mappers.loan.toModel
import com.mifos.core.data.repository.loan.LoanDisburseRepository
import com.mifos.core.data.util.NetworkMonitor
import com.mifos.core.data.util.runAsDataState
import com.mifos.core.model.objects.account.loan.loanDisburse.LoanDisburseInput
import com.mifos.core.model.objects.account.loan.loanDisburse.LoanDisburseTemplate
import com.mifos.core.network.datamanager.DataManagerLoan
import template.core.base.common.manager.DispatcherManager

class LoanDisburseRepositoryImpl(
private val dataManagerLoan: DataManagerLoan,
private val networkMonitor: NetworkMonitor,
private val dispatcher: DispatcherManager,
) : LoanDisburseRepository {
override suspend fun getDisburseTemplate(loanId: Int): DataState<LoanDisburseTemplate> {
return runAsDataState(
networkMonitor = networkMonitor,
context = dispatcher.io,
) {
dataManagerLoan.getDisburseTemplate(loanId).toModel()
}
}

override suspend fun disburse(
loanId: Int,
loanDisburseInput: LoanDisburseInput,
): DataState<Unit> {
return runAsDataState(
networkMonitor = networkMonitor,
context = dispatcher.io,
) {
dataManagerLoan.disburse(loanId, loanDisburseInput.toDto())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ import com.mifos.core.domain.useCases.createGuarantor.GetGuarantorAccountTemplat
import com.mifos.core.domain.useCases.createGuarantor.GetGuarantorTemplateUseCase
import com.mifos.core.domain.useCases.loanChargeOff.GetLoanChargeOffTemplateUseCase
import com.mifos.core.domain.useCases.loanChargeOff.LoanChargeOffUseCase
import com.mifos.core.domain.useCases.loanDisburse.GetLoanDisburseTemplateUseCase
import com.mifos.core.domain.useCases.loanDisburse.LoanDisburseUseCase
import org.koin.core.module.dsl.factoryOf
import org.koin.dsl.module

Expand Down Expand Up @@ -185,6 +187,8 @@ val UseCaseModule = module {
factoryOf(::UpdateSignatureUseCase)
factoryOf(::GetLoanChargeOffTemplateUseCase)
factoryOf(::LoanChargeOffUseCase)
factoryOf(::GetLoanDisburseTemplateUseCase)
factoryOf(::LoanDisburseUseCase)
factoryOf(::GetLoanOfficerOptionsUseCase)
factoryOf(::AssignLoanOfficerUseCase)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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.domain.useCases.loanDisburse

import com.mifos.core.common.utils.DataState
import com.mifos.core.data.repository.loan.LoanDisburseRepository
import com.mifos.core.model.objects.account.loan.loanDisburse.LoanDisburseTemplate

class GetLoanDisburseTemplateUseCase(
val repository: LoanDisburseRepository,
) {
suspend operator fun invoke(
loanId: Int,
): DataState<LoanDisburseTemplate> = repository.getDisburseTemplate(loanId)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.domain.useCases.loanDisburse

import com.mifos.core.common.utils.DataState
import com.mifos.core.data.repository.loan.LoanDisburseRepository
import com.mifos.core.model.objects.account.loan.loanDisburse.LoanDisburseInput

class LoanDisburseUseCase(
val repository: LoanDisburseRepository,
) {
suspend operator fun invoke(
loanId: Int,
loanDisburseInput: LoanDisburseInput,
): DataState<Unit> = repository.disburse(loanId, loanDisburseInput)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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.model.objects.account.loan.loanDisburse

import com.mifos.core.model.utils.DateConstants

data class LoanDisburseInput(
val actualDisbursementDate: String,
val transactionAmount: Double,
val paymentTypeId: Int? = null,
val note: String? = null,
val externalId: Int? = null,
val accountNumber: String? = null,
val checkNumber: String? = null,
val routingCode: String? = null,
val receiptNumber: String? = null,
val bankNumber: String? = null,
val locale: String = DateConstants.LOCALE,
val dateFormat: String = "dd-MM-yyyy",
)
Loading
Loading