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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import com.mifos.core.objects.client.Client
import com.mifos.core.objects.client.ClientPayload
import com.mifos.core.objects.organisation.Office
import com.mifos.core.objects.organisation.Staff
import com.mifos.core.objects.templates.clients.AddressConfiguration
import com.mifos.core.objects.templates.clients.AddressTemplate
import com.mifos.core.objects.templates.clients.ClientsTemplate
import okhttp3.MultipartBody
import okhttp3.ResponseBody
Expand All @@ -32,4 +34,8 @@ interface CreateNewClientRepository {
fun createClient(clientPayload: ClientPayload): Observable<Client>

fun uploadClientImage(id: Int, file: MultipartBody.Part?): Observable<ResponseBody>

suspend fun getAddressConfiguration(): AddressConfiguration

suspend fun getAddressTemplate(): AddressTemplate
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import com.mifos.core.objects.client.Client
import com.mifos.core.objects.client.ClientPayload
import com.mifos.core.objects.organisation.Office
import com.mifos.core.objects.organisation.Staff
import com.mifos.core.objects.templates.clients.AddressConfiguration
import com.mifos.core.objects.templates.clients.AddressTemplate
import com.mifos.core.objects.templates.clients.ClientsTemplate
import okhttp3.MultipartBody
import okhttp3.ResponseBody
Expand Down Expand Up @@ -51,4 +53,12 @@ class CreateNewClientRepositoryImp @Inject constructor(
override fun uploadClientImage(id: Int, file: MultipartBody.Part?): Observable<ResponseBody> {
return dataManagerClient.uploadClientImage(id, file)
}

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
Expand Up @@ -17,13 +17,21 @@ import kotlinx.parcelize.Parcelize
*/
@Parcelize
data class Address(
var addressTypeId: Int? = null,
var addressTypeId: Int = -1,

var active: Boolean? = null,
var isActive: Boolean = false,

var street: String? = null,
var addressLine1: String = "",

var stateProvinceId: Int? = null,
var addressLine2: String = "",

var countryId: Int? = null,
var addressLine3: String = "",

var city: String = "",

var stateProvinceId: Int = -1,

var countryId: Int = -1,

var postalCode: String = "",
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ data class ClientPayload(
@Column
var clientClassificationId: Int? = null,

var address: List<Address>? = ArrayList(),
var address: List<Address>? = emptyList(),

@Column
var dateFormat: String? = "dd MMMM yyyy",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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.core.objects.templates.clients

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

data class AddressConfiguration(
val enabled: Boolean = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import com.mifos.core.objects.noncore.Identifier
import com.mifos.core.objects.noncore.IdentifierCreationResponse
import com.mifos.core.objects.noncore.IdentifierPayload
import com.mifos.core.objects.noncore.IdentifierTemplate
import com.mifos.core.objects.templates.clients.AddressConfiguration
import com.mifos.core.objects.templates.clients.AddressTemplate
import com.mifos.core.objects.templates.clients.ClientsTemplate
import kotlinx.coroutines.flow.Flow
import okhttp3.MultipartBody
Expand Down Expand Up @@ -345,4 +347,25 @@ class DataManagerClient @Inject constructor(
"activate",
)
}

/**
* 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 @@ -20,6 +20,8 @@ import com.mifos.core.objects.noncore.Identifier
import com.mifos.core.objects.noncore.IdentifierCreationResponse
import com.mifos.core.objects.noncore.IdentifierPayload
import com.mifos.core.objects.noncore.IdentifierTemplate
import com.mifos.core.objects.templates.clients.AddressConfiguration
import com.mifos.core.objects.templates.clients.AddressTemplate
import com.mifos.core.objects.templates.clients.ClientsTemplate
import kotlinx.coroutines.flow.Flow
import okhttp3.MultipartBody
Expand Down Expand Up @@ -220,4 +222,21 @@ interface ClientService {
@Body clientActivate: PostClientsClientIdRequest,
@Query("command") command: String? = null,
): PostClientsClientIdResponse

/**
* 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
}
Loading