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

import com.mifos.core.common.utils.DataState
import com.mifos.room.entities.client.AddressConfiguration
import com.mifos.room.entities.client.AddressTemplate
import com.mifos.room.entities.client.ClientPayloadEntity
import com.mifos.room.entities.organisation.OfficeEntity
import com.mifos.room.entities.organisation.StaffEntity
Expand All @@ -31,4 +33,8 @@ interface CreateNewClientRepository {
suspend fun createClient(clientPayload: ClientPayloadEntity): Int?

suspend fun uploadClientImage(clientId: Int, image: MultiPartFormDataContent)

suspend fun getAddressConfiguration(): AddressConfiguration

suspend fun getAddressTemplate(): AddressTemplate
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import com.mifos.core.data.repository.CreateNewClientRepository
import com.mifos.core.network.datamanager.DataManagerClient
import com.mifos.core.network.datamanager.DataManagerOffices
import com.mifos.core.network.datamanager.DataManagerStaff
import com.mifos.room.entities.client.AddressConfiguration
import com.mifos.room.entities.client.AddressTemplate
import com.mifos.room.entities.client.ClientPayloadEntity
import com.mifos.room.entities.organisation.OfficeEntity
import com.mifos.room.entities.organisation.StaffEntity
Expand Down Expand Up @@ -53,4 +55,12 @@ class CreateNewClientRepositoryImp(
override suspend fun uploadClientImage(clientId: Int, image: MultiPartFormDataContent) {
return dataManagerClient.uploadClientImage(clientId, image)
}

override suspend fun getAddressConfiguration(): AddressConfiguration {
return dataManagerClient.getAddressConfiguration()
}

override suspend fun getAddressTemplate(): AddressTemplate {
return dataManagerClient.getAddressTemplate()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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/android-client/blob/master/LICENSE.md
*/
package com.mifos.room.entities.client

import com.mifos.room.entities.templates.clients.OptionsEntity
import kotlinx.serialization.Serializable

@Serializable
data class AddressTemplate(
val addressTypeIdOptions: List<OptionsEntity> = emptyList(),
val countryIdOptions: List<OptionsEntity> = emptyList(),
val stateProvinceIdOptions: List<OptionsEntity> = emptyList(),
)

@Serializable
data class AddressConfiguration(
val enabled: Boolean = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package com.mifos.room.entities.client

import com.mifos.core.model.objects.clients.Address
import com.mifos.core.model.utils.Parcelable
import com.mifos.core.model.utils.Parcelize
import com.mifos.room.entities.noncore.DataTablePayload
Expand Down Expand Up @@ -62,15 +63,14 @@ data class ClientPayloadEntity(

val clientClassificationId: Int? = null,

val address: String? = null,
val address: List<Address>? = emptyList(),

val dateFormat: String? = null,

val locale: String? = null,

val datatables: List<DataTablePayload>? = null,

// TODO add legal form id field
// 1 for Person (Individual client)
val legalFormId: Int? = null,
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.mifos.core.model.objects.account.saving.InterestCalculationType
import com.mifos.core.model.objects.account.saving.InterestCompoundingPeriodType
import com.mifos.core.model.objects.account.saving.InterestPostingPeriodType
import com.mifos.core.model.objects.account.saving.LockinPeriodFrequencyType
import com.mifos.core.model.objects.clients.Address
import com.mifos.room.entities.PaymentTypeOptionEntity
import com.mifos.room.entities.Timeline
import com.mifos.room.entities.accounts.loans.ActualDisbursementDateEntity
Expand Down Expand Up @@ -692,4 +693,12 @@ class CustomTypeConverters {
fun toResponseDatasList(json: String?): List<ResponseDatasEntity>? {
return json?.let { Json.decodeFromString(it) }
}

@TypeConverter
fun fromAddressList(addressList: List<Address>?): String? =
addressList?.let { Json.encodeToString(it) }

@TypeConverter
fun toAddressList(json: String?): List<Address>? =
json?.let { Json.decodeFromString(it) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,21 @@ import kotlinx.serialization.Serializable
@Parcelize
@Serializable
data class Address(
val addressTypeId: Int? = null,
val active: Boolean? = null,
val street: String? = null,
val stateProvinceId: Int? = null,
val countryId: Int? = null,
val addressTypeId: Int = -1,

val isActive: Boolean = false,

val addressLine1: String = "",

val addressLine2: String = "",

val addressLine3: String = "",

val city: String = "",

val stateProvinceId: Int = -1,

val countryId: Int = -1,

val postalCode: String = "",
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import com.mifos.core.network.model.DeleteClientsClientIdIdentifiersIdentifierId
import com.mifos.core.network.model.PostClientsClientIdRequest
import com.mifos.core.network.model.PostClientsClientIdResponse
import com.mifos.room.entities.accounts.ClientAccounts
import com.mifos.room.entities.client.AddressConfiguration
import com.mifos.room.entities.client.AddressTemplate
import com.mifos.room.entities.client.ClientEntity
import com.mifos.room.entities.client.ClientPayloadEntity
import com.mifos.room.entities.templates.clients.ClientsTemplateEntity
Expand Down Expand Up @@ -446,4 +448,25 @@ class DataManagerClient(
"activate",
)
}

/**Add commentMore actions
* Gets the address configuration.
*
* @return The address configuration.
*/
suspend fun getAddressConfiguration(): AddressConfiguration {
return mBaseApiManager.clientsApi.getAddressConfiguration()
}

/**
* Gets the address template.
*
* The address template is a predefined format for addresses that can be used to ensure consistency
* and accuracy when collecting and storing address information.
*
* @return The address template.
*/
suspend fun getAddressTemplate(): AddressTemplate {
return mBaseApiManager.clientsApi.getAddressTemplate()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ package com.mifos.core.network.datamanager

import com.mifos.core.datastore.UserPreferencesRepository
import com.mifos.core.network.BaseApiManager
import com.mifos.core.network.mappers.staffs.StaffMapper
import com.mifos.room.entities.organisation.StaffEntity
import com.mifos.room.helper.StaffDaoHelper
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flow

/**
* Created by Rajan Maurya on 7/7/16.
Expand All @@ -37,15 +35,8 @@ class DataManagerStaff(
fun getStaffInOffice(officeId: Int): Flow<List<StaffEntity>> {
return prefManager.userInfo.flatMapLatest { userData ->
when (userData.userStatus) {
false -> flow {
baseApiManager.getStaffApi().retrieveAll16(
officeId.toLong(),
null,
null,
null,
)
.map(StaffMapper::mapFromEntity)
}
false ->
mBaseApiManager.staffApi.getStaffForOffice(officeId)

/**
* return all List of Staffs of Office from DatabaseHelperOffices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import com.mifos.core.network.model.PostAuthenticationRequest
import com.mifos.core.network.model.PostAuthenticationResponse
import com.mifos.room.basemodel.APIEndPoint
import com.mifos.room.entities.accounts.ClientAccounts
import com.mifos.room.entities.client.AddressConfiguration
import com.mifos.room.entities.client.AddressTemplate
import com.mifos.room.entities.client.ClientEntity
import com.mifos.room.entities.client.ClientPayloadEntity
import com.mifos.room.entities.templates.clients.ClientsTemplateEntity
Expand Down Expand Up @@ -221,4 +223,21 @@ interface ClientService {
@Path("clientId") clientId: Int,
@Body clientActivate: ActivatePayload?,
): Flow<GenericResponse>

/**Add commentMore actions
* Retrieves address configuration from Global Configuration.
*
* @return The AddressConfiguration object
*/
@GET("configurations/name/enable-address")
suspend fun getAddressConfiguration(): AddressConfiguration

/**
* Retrieves an address template.
* This template can be used to pre-fill address forms or guide users in providing address information.
*
* @return An [AddressTemplate] object containing the structure for an address.
*/
@GET("client/addresses/template")
suspend fun getAddressTemplate(): AddressTemplate
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
<string name="feature_client_gender">Gender</string>
<string name="feature_client_dob">Date of Birth</string>
<string name="feature_client_client">Client</string>
<string name="feature_client_client_type">Client Type</string>
<string name="feature_client_client_classification">Client Classification</string>
<string name="feature_client_office_name_mandatory">Office*</string>
<string name="feature_client_staff">Staff</string>
Expand All @@ -170,5 +171,21 @@

<string name="feature_client_failed_to_fetch_clients">"Failed to Fetch Clients"</string>
<string name="feature_client_failed_to_more_clients">"Failed to load more Clients"</string>

<string name="feature_client_address">Address :</string>
<string name="feature_client_add_address">Add Address</string>
<string name="feature_client_address_type">Address Type*</string>
<string name="feature_client_address_line_1">Address Line 1</string>
<string name="feature_client_address_line_2">Address Line 2</string>
<string name="feature_client_address_line_3">Address Line 3</string>
<string name="feature_client_street">Street</string>
<string name="feature_client_city">City</string>
<string name="feature_client_town_village">Town/Village</string>
<string name="feature_client_county_district">County/District</string>
<string name="feature_client_country">Country</string>
<string name="feature_client_state_province">State/Province</string>
<string name="feature_client_postal_code">Postal Code</string>
<string name="feature_client_address_active">Address Active</string>
<string name="feature_client_error_address_type_is_required">Address Type is required</string>
<string name="feature_client_failed_to_fetch_address_configuration">Failed to fetch address configuration</string>
<string name="feature_client_failed_to_fetch_address_template">Failed to fetch address template</string>
</resources>
Loading