Skip to content

Commit

Permalink
Merge branch 'master' into loan_charges_dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya-gupta99 authored Jul 18, 2024
2 parents 4454c02 + e624177 commit 10d79bd
Show file tree
Hide file tree
Showing 55 changed files with 3,362 additions and 2,134 deletions.
10 changes: 10 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 @@ -12,13 +12,15 @@ import com.mifos.core.data.repository.CreateNewCenterRepository
import com.mifos.core.data.repository.DocumentListRepository
import com.mifos.core.data.repository.GroupDetailsRepository
import com.mifos.core.data.repository.GroupListRepository
import com.mifos.core.data.repository.GroupLoanAccountRepository
import com.mifos.core.data.repository.GroupsListRepository
import com.mifos.core.data.repository.IndividualCollectionSheetDetailsRepository
import com.mifos.core.data.repository.LoanAccountRepository
import com.mifos.core.data.repository.LoanChargeDialogRepository
import com.mifos.core.data.repository.LoanChargeRepository
import com.mifos.core.data.repository.NewIndividualCollectionSheetRepository
import com.mifos.core.data.repository.PathTrackingRepository
import com.mifos.core.data.repository.PinPointClientRepository
import com.mifos.core.data.repository.ReportCategoryRepository
import com.mifos.core.data.repository.ReportDetailRepository
import com.mifos.core.data.repository_imp.ActivateRepositoryImp
Expand All @@ -32,13 +34,15 @@ import com.mifos.core.data.repository_imp.CreateNewCenterRepositoryImp
import com.mifos.core.data.repository_imp.DocumentListRepositoryImp
import com.mifos.core.data.repository_imp.GroupDetailsRepositoryImp
import com.mifos.core.data.repository_imp.GroupListRepositoryImp
import com.mifos.core.data.repository_imp.GroupLoanAccountRepositoryImp
import com.mifos.core.data.repository_imp.GroupsListRepositoryImpl
import com.mifos.core.data.repository_imp.IndividualCollectionSheetDetailsRepositoryImp
import com.mifos.core.data.repository_imp.LoanAccountRepositoryImp
import com.mifos.core.data.repository_imp.LoanChargeDialogRepositoryImp
import com.mifos.core.data.repository_imp.LoanChargeRepositoryImp
import com.mifos.core.data.repository_imp.NewIndividualCollectionSheetRepositoryImp
import com.mifos.core.data.repository_imp.PathTrackingRepositoryImp
import com.mifos.core.data.repository_imp.PinPointClientRepositoryImp
import com.mifos.core.data.repository_imp.ReportCategoryRepositoryImp
import com.mifos.core.data.repository_imp.ReportDetailRepositoryImp
import dagger.Binds
Expand Down Expand Up @@ -88,6 +92,9 @@ abstract class DataModule {
@Binds
internal abstract fun bindClientIdentifiersRepository(impl: ClientIdentifiersRepositoryImp): ClientIdentifiersRepository

@Binds
internal abstract fun bindPinpointRepository(impl: PinPointClientRepositoryImp): PinPointClientRepository

@Binds
internal abstract fun bindActivateRepository(impl: ActivateRepositoryImp): ActivateRepository

Expand All @@ -106,6 +113,9 @@ abstract class DataModule {
@Binds
internal abstract fun bindGroupListRepository(impl: GroupListRepositoryImp): GroupListRepository

@Binds
internal abstract fun bindGroupLoanAccountRepository(impl: GroupLoanAccountRepositoryImp): GroupLoanAccountRepository

@Binds
internal abstract fun bindLoanChargeRepository(impl: LoanChargeRepositoryImp): LoanChargeRepository

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.mifos.mifosxdroid.online.grouploanaccount
package com.mifos.core.data.repository

import com.mifos.core.data.GroupLoanPayload
import com.mifos.core.objects.accounts.loan.Loans
import com.mifos.core.objects.organisation.LoanProducts
import com.mifos.core.objects.templates.loans.GroupLoanTemplate
import rx.Observable

Expand All @@ -11,9 +10,7 @@ import rx.Observable
*/
interface GroupLoanAccountRepository {

fun allLoans(): Observable<List<LoanProducts>>

fun getGroupLoansAccountTemplate(groupId: Int, productId: Int): Observable<GroupLoanTemplate>

fun createGroupLoansAccount(loansPayload: GroupLoanPayload?): Observable<Loans>
fun createGroupLoansAccount(loansPayload: GroupLoanPayload): Observable<Loans>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.mifos.core.data.repository

import com.mifos.core.network.GenericResponse
import com.mifos.core.objects.client.ClientAddressRequest
import com.mifos.core.objects.client.ClientAddressResponse

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

suspend fun getClientPinpointLocations(clientId: Int): List<ClientAddressResponse>

suspend fun addClientPinpointLocation(
clientId: Int,
address: ClientAddressRequest
): GenericResponse

suspend fun deleteClientAddressPinpointLocation(
apptableId: Int,
datatableId: Int
): GenericResponse

suspend fun updateClientPinpointLocation(
apptableId: Int,
datatableId: Int,
address: ClientAddressRequest
): GenericResponse
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.mifos.mifosxdroid.online.grouploanaccount
package com.mifos.core.data.repository_imp

import com.mifos.core.data.GroupLoanPayload
import com.mifos.core.data.repository.GroupLoanAccountRepository
import com.mifos.core.network.DataManager
import com.mifos.core.objects.accounts.loan.Loans
import com.mifos.core.objects.organisation.LoanProducts
import com.mifos.core.objects.templates.loans.GroupLoanTemplate
import rx.Observable
import javax.inject.Inject
Expand All @@ -14,18 +14,14 @@ import javax.inject.Inject
class GroupLoanAccountRepositoryImp @Inject constructor(private val dataManager: DataManager) :
GroupLoanAccountRepository {

override fun allLoans(): Observable<List<LoanProducts>> {
return dataManager.allLoans
}

override fun getGroupLoansAccountTemplate(
groupId: Int,
productId: Int
): Observable<GroupLoanTemplate> {
return dataManager.getGroupLoansAccountTemplate(groupId, productId)
}

override fun createGroupLoansAccount(loansPayload: GroupLoanPayload?): Observable<Loans> {
override fun createGroupLoansAccount(loansPayload: GroupLoanPayload): Observable<Loans> {
return dataManager.createGroupLoansAccount(loansPayload)
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.mifos.mifosxdroid.activity.pinpointclient
package com.mifos.core.data.repository_imp

import com.mifos.core.data.repository.PinPointClientRepository
import com.mifos.core.network.GenericResponse
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.objects.client.ClientAddressRequest
import com.mifos.core.objects.client.ClientAddressResponse
import rx.Observable
import javax.inject.Inject

/**
Expand All @@ -13,31 +13,29 @@ import javax.inject.Inject
class PinPointClientRepositoryImp @Inject constructor(private val dataManagerClient: DataManagerClient) :
PinPointClientRepository {

override fun getClientPinpointLocations(clientId: Int): Observable<List<ClientAddressResponse>> {
override suspend fun getClientPinpointLocations(clientId: Int): List<ClientAddressResponse> {
return dataManagerClient.getClientPinpointLocations(clientId)
}

override fun addClientPinpointLocation(
override suspend fun addClientPinpointLocation(
clientId: Int,
address: ClientAddressRequest?
): Observable<GenericResponse> {
address: ClientAddressRequest
): GenericResponse {
return dataManagerClient.addClientPinpointLocation(clientId, address)
}

override fun deleteClientAddressPinpointLocation(
override suspend fun deleteClientAddressPinpointLocation(
apptableId: Int,
datatableId: Int
): Observable<GenericResponse> {
): GenericResponse {
return dataManagerClient.deleteClientAddressPinpointLocation(apptableId, datatableId)
}

override fun updateClientPinpointLocation(
override suspend fun updateClientPinpointLocation(
apptableId: Int,
datatableId: Int,
address: ClientAddressRequest?
): Observable<GenericResponse> {
address: ClientAddressRequest
): GenericResponse {
return dataManagerClient.updateClientPinpointLocation(apptableId, datatableId, address)
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,24 @@ fun MifosOutlinedTextField(
value: String,
onValueChange: (String) -> Unit,
maxLines: Int = 1,
readOnly : Boolean = false,
singleLine: Boolean = true,
icon: ImageVector? = null,
label: String,
visualTransformation: VisualTransformation = VisualTransformation.None,
trailingIcon: @Composable (() -> Unit)? = null,
keyboardType: KeyboardType = KeyboardType.Text,
error: Int?,
readOnly: Boolean = false
enabled: Boolean = true
) {

OutlinedTextField(
value = value,
onValueChange = onValueChange,
label = { Text(label) },
modifier = modifier,
readOnly = readOnly,
enabled = enabled,
leadingIcon = if (icon != null) {
{
Icon(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.mifos.core.designsystem.component

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Error
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp


@Composable
fun MifosErrorContent(
message: String,
isRefreshEnabled: Boolean = false,
imageVector: ImageVector? = null,
onRefresh: () -> Unit = {},
refreshButtonText: String = ""
) {
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Icon(
imageVector = imageVector ?: Icons.Default.Error,
contentDescription = null,
modifier = Modifier.size(48.dp)
)
if (isRefreshEnabled) {
Text(text = message, modifier = Modifier.padding(vertical = 16.dp))
Button(onClick = onRefresh) {
Text(text = refreshButtonText)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ fun MifosSweetError(
.padding(18.dp)
.semantics { contentDescription = "MifosSweetError" },
message: String,
isRetryEnabled: Boolean = true,
isRetryEnabled : Boolean = true,
buttonText : String = stringResource(id = R.string.core_designsystem_try_again),
onclick: () -> Unit
) {
Column(
Expand Down Expand Up @@ -86,7 +87,7 @@ fun MifosSweetError(
) {
Text(
modifier = Modifier.padding(start = 20.dp, end = 20.dp),
text = stringResource(id = R.string.core_designsystem_try_again),
text = buttonText,
fontSize = 15.sp
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ fun MifosTextFieldDropdown(
maxLines = 1,
colors = OutlinedTextFieldDefaults.colors(
focusedBorderColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary,
),
focusedLabelColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary,
),
textStyle = LocalDensity.current.run {
TextStyle(fontSize = 18.sp)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.material.icons.outlined.DateRange
import androidx.compose.material.icons.outlined.EventRepeat
import androidx.compose.material.icons.outlined.Group
import androidx.compose.material.icons.rounded.Add
import androidx.compose.material.icons.rounded.AddLocation
import androidx.compose.material.icons.rounded.ArrowBackIosNew
import androidx.compose.material.icons.rounded.Check
import androidx.compose.material.icons.rounded.Close
Expand Down Expand Up @@ -38,6 +39,7 @@ object MifosIcons {
val arrowDown = Icons.Rounded.KeyboardArrowDown
val moreVert = Icons.Rounded.MoreVert
val fileTask = Icons.Default.AssignmentTurnedIn
val addLocation = Icons.Rounded.AddLocation
val cloudDownload = Icons.Default.CloudDownload
val save = Icons.Rounded.Download
val error = Icons.Rounded.Error
Expand Down
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.PinPointClientRepository
import com.mifos.core.network.GenericResponse
import com.mifos.core.objects.client.ClientAddressRequest
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class AddClientPinpointLocationUseCase @Inject constructor(private val pinPointClientRepository: PinPointClientRepository) {

suspend operator fun invoke(
clientId: Int,
address: ClientAddressRequest
): Flow<Resource<GenericResponse>> = flow {
try {
emit(Resource.Loading())
val response = pinPointClientRepository.addClientPinpointLocation(clientId, address)
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,42 @@
package com.mifos.core.domain.use_cases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.GroupLoanPayload
import com.mifos.core.data.repository.GroupLoanAccountRepository
import com.mifos.core.objects.accounts.loan.Loans
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import rx.Subscriber
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers
import javax.inject.Inject

class CreateGroupLoansAccountUseCase @Inject constructor(private val repository: GroupLoanAccountRepository) {

suspend operator fun invoke(loansPayload: GroupLoanPayload): Flow<Resource<Loans>> =
callbackFlow {
try {
trySend(Resource.Loading())
repository.createGroupLoansAccount(loansPayload)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(object : Subscriber<Loans>() {
override fun onCompleted() {}

override fun onError(exception: Throwable) {
trySend(Resource.Error(exception.message.toString()))
}

override fun onNext(response: Loans) {
trySend(Resource.Success(response))
}
})
awaitClose { channel.close() }
} catch (exception: Exception) {
trySend(Resource.Error(exception.message.toString()))
}


}
}
Loading

0 comments on commit 10d79bd

Please sign in to comment.