Skip to content
Merged
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
5 changes: 5 additions & 0 deletions core/data/src/main/java/com/mifos/core/data/di/DataModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.mifos.core.data.repository.LoanAccountRepository
import com.mifos.core.data.repository.NewIndividualCollectionSheetRepository
import com.mifos.core.data.repository.PathTrackingRepository
import com.mifos.core.data.repository.ReportCategoryRepository
import com.mifos.core.data.repository.ReportDetailRepository
import com.mifos.core.data.repository_imp.CenterDetailsRepositoryImp
import com.mifos.core.data.repository_imp.CenterListRepositoryImp
import com.mifos.core.data.repository_imp.CheckerInboxRepositoryImp
Expand All @@ -27,6 +28,7 @@ import com.mifos.core.data.repository_imp.LoanAccountRepositoryImp
import com.mifos.core.data.repository_imp.NewIndividualCollectionSheetRepositoryImp
import com.mifos.core.data.repository_imp.PathTrackingRepositoryImp
import com.mifos.core.data.repository_imp.ReportCategoryRepositoryImp
import com.mifos.core.data.repository_imp.ReportDetailRepositoryImp
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand Down Expand Up @@ -74,6 +76,9 @@ abstract class DataModule {
@Binds
internal abstract fun bindClientIdentifiersRepository(impl: ClientIdentifiersRepositoryImp): ClientIdentifiersRepository

@Binds
internal abstract fun bindReportDetailRepository(impl: ReportDetailRepositoryImp): ReportDetailRepository

@Binds
internal abstract fun bindLoanAccountRepository(impl: LoanAccountRepositoryImp): LoanAccountRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.mifos.core.data.repository

import com.mifos.core.objects.runreports.FullParameterListResponse

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

suspend fun getReportFullParameterList(
reportName: String, parameterType: Boolean
): FullParameterListResponse

suspend fun getReportParameterDetails(
parameterName: String, parameterType: Boolean
): FullParameterListResponse

suspend fun getRunReportOffices(
parameterName: String, officeId: Int, parameterType: Boolean
): FullParameterListResponse

suspend fun getRunReportProduct(
parameterName: String, currency: String, parameterType: Boolean
): FullParameterListResponse

suspend fun getRunReportWithQuery(
reportName: String, options: Map<String, String>
): FullParameterListResponse

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mifos.mifosxdroid.online.runreports.reportdetail
package com.mifos.core.data.repository_imp

import com.mifos.core.data.repository.ReportDetailRepository
import com.mifos.core.network.datamanager.DataManagerRunReport
import com.mifos.core.objects.runreports.FullParameterListResponse
import rx.Observable
import javax.inject.Inject

/**
Expand All @@ -11,40 +11,40 @@ import javax.inject.Inject
class ReportDetailRepositoryImp @Inject constructor(private val dataManager: DataManagerRunReport) :
ReportDetailRepository {

override fun getReportFullParameterList(
reportName: String?,
override suspend fun getReportFullParameterList(
reportName: String,
parameterType: Boolean
): Observable<FullParameterListResponse> {
): FullParameterListResponse {
return dataManager.getReportFullParameterList(reportName, parameterType)
}

override fun getReportParameterDetails(
parameterName: String?,
override suspend fun getReportParameterDetails(
parameterName: String,
parameterType: Boolean
): Observable<FullParameterListResponse> {
): FullParameterListResponse {
return dataManager.getReportParameterDetails(parameterName, parameterType)
}

override fun getRunReportOffices(
parameterName: String?,
override suspend fun getRunReportOffices(
parameterName: String,
officeId: Int,
parameterType: Boolean
): Observable<FullParameterListResponse> {
): FullParameterListResponse {
return dataManager.getRunReportOffices(parameterName, officeId, parameterType)
}

override fun getRunReportProduct(
parameterName: String?,
currency: String?,
override suspend fun getRunReportProduct(
parameterName: String,
currency: String,
parameterType: Boolean
): Observable<FullParameterListResponse> {
): FullParameterListResponse {
return dataManager.getRunReportProduct(parameterName, currency, parameterType)
}

override fun getRunReportWithQuery(
reportName: String?,
options: Map<String?, String?>
): Observable<FullParameterListResponse> {
override suspend fun getRunReportWithQuery(
reportName: String,
options: Map<String, String>
): FullParameterListResponse {
return dataManager.getRunReportWithQuery(reportName, options)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ fun PermissionBox(
if (!isGranted) {
shouldShowPermissionRationale =
requiredPermissions.all {
ActivityCompat.shouldShowRequestPermissionRationale(
context as Activity,
it
)
(context as? Activity)?.let { it1 ->
ActivityCompat.shouldShowRequestPermissionRationale(
it1, it
)
} == false
}
}
shouldDirectUserToApplicationSettings =
Expand Down Expand Up @@ -114,7 +115,7 @@ fun PermissionBox(

if (shouldShowPermissionRationale) {
MifosDialogBox(
showDialogState = shouldShowPermissionRationale,
showDialogState = shouldShowPermissionRationale,
onDismiss = { shouldShowPermissionRationale = false },
title = title,
message = description,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.mifos.core.domain.use_cases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ReportDetailRepository
import com.mifos.core.objects.runreports.FullParameterListResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class GetReportFullParameterListUseCase @Inject constructor(private val repository: ReportDetailRepository) {

suspend operator fun invoke(
reportName: String,
parameterType: Boolean
): Flow<Resource<FullParameterListResponse>> = flow {
try {
emit(Resource.Loading())
val response = repository.getReportFullParameterList(reportName, parameterType)
emit(Resource.Success(response))
} catch (exception: Exception) {
emit(Resource.Error(exception.message.toString()))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.mifos.core.domain.use_cases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ReportDetailRepository
import com.mifos.core.objects.runreports.FullParameterListResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class GetReportParameterDetailsUseCase @Inject constructor(private val repository: ReportDetailRepository) {

suspend operator fun invoke(
parameterName: String,
parameterType: Boolean
): Flow<Resource<FullParameterListResponse>> = flow {
try {
emit(Resource.Loading())
val response = repository.getReportParameterDetails(parameterName, parameterType)
emit(Resource.Success(response))
} catch (exception: Exception) {
emit(Resource.Error(exception.message.toString()))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.mifos.core.domain.use_cases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ReportDetailRepository
import com.mifos.core.objects.runreports.FullParameterListResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class GetRunReportOfficesUseCase @Inject constructor(private val repository: ReportDetailRepository) {

suspend operator fun invoke(
parameterName: String,
officeId: Int,
parameterType: Boolean
): Flow<Resource<FullParameterListResponse>> = flow {
try {
emit(Resource.Loading())
val response = repository.getRunReportOffices(parameterName, officeId, parameterType)
emit(Resource.Success(response))

} catch (exception: Exception) {
emit(Resource.Error(exception.message.toString()))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.mifos.core.domain.use_cases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ReportDetailRepository
import com.mifos.core.objects.runreports.FullParameterListResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class GetRunReportProductUseCase @Inject constructor(private val repository: ReportDetailRepository) {

suspend operator fun invoke(
parameterName: String,
currency: String,
parameterType: Boolean
): Flow<Resource<FullParameterListResponse>> = flow {
try {
emit(Resource.Loading())
val response = repository.getRunReportProduct(parameterName, currency, parameterType)
emit(Resource.Success(response))
} catch (exception: Exception) {
emit(Resource.Error(exception.message.toString()))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.mifos.core.domain.use_cases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ReportDetailRepository
import com.mifos.core.objects.runreports.FullParameterListResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class GetRunReportWithQueryUseCase @Inject constructor(private val repository: ReportDetailRepository) {

suspend operator fun invoke(
reportName: String,
options: Map<String, String>
): Flow<Resource<FullParameterListResponse>> = flow {
try {
emit(Resource.Loading())
val response = repository.getRunReportWithQuery(reportName, options)
emit(Resource.Success(response))
} catch (exception: Exception) {
emit(Resource.Error(exception.message.toString()))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.mifos.core.network.BaseApiManager
import com.mifos.core.objects.group.CenterInfo
import com.mifos.core.objects.runreports.FullParameterListResponse
import com.mifos.core.objects.runreports.client.ClientReportTypeItem
import rx.Observable
import javax.inject.Inject
import javax.inject.Singleton

Expand All @@ -24,23 +23,23 @@ class DataManagerRunReport @Inject constructor(val mBaseApiManager: BaseApiManag
)
}

fun getReportFullParameterList(
reportName: String?, parameterType: Boolean
): Observable<FullParameterListResponse> {
suspend fun getReportFullParameterList(
reportName: String, parameterType: Boolean
): FullParameterListResponse {
return mBaseApiManager.runReportsService
.getReportFullParameterList(reportName, parameterType)
}

fun getReportParameterDetails(
parameterName: String?, parameterType: Boolean
): Observable<FullParameterListResponse> {
suspend fun getReportParameterDetails(
parameterName: String, parameterType: Boolean
): FullParameterListResponse {
return mBaseApiManager.runReportsService
.getReportParameterDetails(parameterName, parameterType)
}

fun getRunReportWithQuery(
reportName: String?, options: Map<String?, String?>
): Observable<FullParameterListResponse> {
suspend fun getRunReportWithQuery(
reportName: String, options: Map<String, String>
): FullParameterListResponse {
return mBaseApiManager.runReportsService
.getRunReportWithQuery(reportName, options)
}
Expand All @@ -53,19 +52,19 @@ class DataManagerRunReport @Inject constructor(val mBaseApiManager: BaseApiManag
.getCenterSummaryInfo(centerId, genericResultSet)
}

fun getRunReportOffices(
parameterName: String?, officeId: Int, parameterType: Boolean
): Observable<FullParameterListResponse> {
suspend fun getRunReportOffices(
parameterName: String, officeId: Int, parameterType: Boolean
): FullParameterListResponse {
return mBaseApiManager.runReportsService.getReportOffice(
parameterName,
officeId,
parameterType
)
}

fun getRunReportProduct(
parameterName: String?, currency: String?, parameterType: Boolean
): Observable<FullParameterListResponse> {
suspend fun getRunReportProduct(
parameterName: String, currency: String, parameterType: Boolean
): FullParameterListResponse {
return mBaseApiManager.runReportsService.getReportProduct(
parameterName,
currency,
Expand Down
Loading