Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrate [core.model] to KMP #2285

Draft
wants to merge 2 commits into
base: kmp-impl
Choose a base branch
from
Draft
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
7 changes: 5 additions & 2 deletions core/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
plugins {
alias(libs.plugins.mifos.android.library)
alias(libs.plugins.mifos.kmp.library)
id(libs.plugins.kotlin.parcelize.get().pluginId)
id("kotlinx-serialization")

alias(libs.plugins.mifos.android.hilt)
alias(libs.plugins.mifos.android.library.jacoco)
alias(libs.plugins.secrets)
Expand All @@ -27,7 +30,7 @@ secrets {
}

dependencies {
implementation(projects.core.model)
// implementation(projects.core.model)
testImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.turbine)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2024 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.common.utils

expect annotation class Parcelize()

expect interface Parcelable

expect annotation class IgnoredOnParcel()

expect interface Parceler<P> {
fun create(parcel: Parcel): P

fun P.write(parcel: Parcel, flags: Int)
}

expect annotation class TypeParceler<T, P : Parceler<in T>>()

expect class Parcel {
fun readByte(): Byte
fun readInt(): Int

fun readFloat(): Float
fun readDouble(): Double
fun readString(): String?

fun writeByte(value: Byte)
fun writeInt(value: Int)

fun writeFloat(value: Float)

fun writeDouble(value: Double)
fun writeString(value: String?)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.model

import com.google.gson.annotations.SerializedName
package com.mifos.core.common.utils

@Serializable
data class ServerConfig(
val protocol: String,
@SerializedName("end_point")
@SerialName("end_point")
val endPoint: String,
@SerializedName("api_path")
@SerialName("api_path")
val apiPath: String,
val port: String,
val tenant: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.common.utils

actual interface Parcelable
actual annotation class IgnoredOnParcel
actual annotation class Parcelize
actual interface Parceler<P> {
actual fun create(parcel: Parcel): P
actual fun P.write(parcel: Parcel, flags: Int)
}

actual annotation class TypeParceler<T, P : Parceler<in T>>

actual class Parcel {
actual fun readString(): String? = null
actual fun readByte(): Byte = 1

actual fun readInt(): Int = 1

actual fun readFloat(): Float = 1f

actual fun readDouble(): Double = 1.0

actual fun writeByte(value: Byte) {
}

actual fun writeInt(value: Int) {
}

actual fun writeFloat(value: Float) {
}

actual fun writeDouble(value: Double) {
}

actual fun writeString(value: String?) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.common.utils

actual interface Parcelable
actual annotation class IgnoredOnParcel
actual annotation class Parcelize
actual interface Parceler<P> {
actual fun create(parcel: Parcel): P
actual fun P.write(parcel: Parcel, flags: Int)
}

actual annotation class TypeParceler<T, P : Parceler<in T>>

actual class Parcel {
actual fun readString(): String? = null
actual fun readByte(): Byte = 1

actual fun readInt(): Int = 1

actual fun readFloat(): Float = 1f

actual fun readDouble(): Double = 1.0

actual fun writeByte(value: Byte) {
}

actual fun writeInt(value: Int) {
}

actual fun writeFloat(value: Float) {
}

actual fun writeDouble(value: Double) {
}

actual fun writeString(value: String?) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
package com.mifos.core.common.utils

import com.google.gson.Gson
import com.mifos.core.model.ServerConfig
import core.mifos.core.model.ServerConfig

fun String.asServerConfig(): ServerConfig {
fun String.asServerConfig(): core.mifos.core.model.ServerConfig {
val jsonString = this.replace("'", "\"")
return Gson().fromJson(jsonString, ServerConfig::class.java)
return Gson().fromJson(jsonString, core.mifos.core.model.ServerConfig::class.java)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.common.utils

import android.os.Parcel
import android.os.Parcelable
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parceler
import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.TypeParceler

actual typealias Parcelize = Parcelize

actual typealias Parcelable = Parcelable

actual typealias IgnoredOnParcel = IgnoredOnParcel

actual typealias Parceler<P> = Parceler<P>

actual typealias TypeParceler<T, P> = TypeParceler<T, P>

actual typealias Parcel = Parcel
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.common.utils

actual interface Parcelable
actual annotation class IgnoredOnParcel
actual annotation class Parcelize
actual interface Parceler<P> {
actual fun create(parcel: Parcel): P
actual fun P.write(parcel: Parcel, flags: Int)
}

actual annotation class TypeParceler<T, P : Parceler<in T>>

actual class Parcel {
actual fun readString(): String? = null
actual fun readByte(): Byte = 1

actual fun readInt(): Int = 1

actual fun readFloat(): Float = 1f

actual fun readDouble(): Double = 1.0

actual fun writeByte(value: Byte) {
}

actual fun writeInt(value: Int) {
}

actual fun writeFloat(value: Float) {
}

actual fun writeDouble(value: Double) {
}

actual fun writeString(value: String?) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.common.utils

actual interface Parcelable
actual annotation class IgnoredOnParcel
actual annotation class Parcelize
actual interface Parceler<P> {
actual fun create(parcel: Parcel): P
actual fun P.write(parcel: Parcel, flags: Int)
}

actual annotation class TypeParceler<T, P : Parceler<in T>>

actual class Parcel {
actual fun readString(): String? = null
actual fun readByte(): Byte = 1

actual fun readInt(): Int = 1

actual fun readFloat(): Float = 1f

actual fun readDouble(): Double = 1.0

actual fun writeByte(value: Byte) {
}

actual fun writeInt(value: Int) {
}

actual fun writeFloat(value: Float) {
}

actual fun writeDouble(value: Double) {
}

actual fun writeString(value: String?) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
package com.mifos.core.data.repository

import com.mifos.core.objects.checkerinboxtask.CheckerTask
import com.mifos.core.objects.checkerinboxtask.RescheduleLoansTask
import kotlinx.coroutines.flow.Flow

/**
Expand All @@ -19,7 +18,7 @@ import kotlinx.coroutines.flow.Flow

interface CheckerInboxTasksRepository {

suspend fun getRescheduleLoansTaskList(): Flow<List<RescheduleLoansTask>>
suspend fun getRescheduleLoansTaskList(): Flow<List<com.mifos.core.model.objects.checkerinboxtask.RescheduleLoansTask>>

suspend fun getCheckerTaskList(
actionName: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ package com.mifos.core.data.repository
import com.mifos.core.entity.accounts.loan.Loans
import com.mifos.core.entity.client.Client
import com.mifos.core.entity.client.ClientPayload
import com.mifos.core.model.objects.payloads.GroupLoanPayload
import com.mifos.core.network.model.LoansPayload
import com.mifos.core.payloads.GroupLoanPayload
import rx.Observable

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.loan.Loans
import com.mifos.core.model.objects.payloads.GroupLoanPayload
import com.mifos.core.objects.template.loan.GroupLoanTemplate
import com.mifos.core.payloads.GroupLoanPayload
import rx.Observable

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
package com.mifos.core.data.repository

import com.mifos.core.network.GenericResponse
import com.mifos.core.objects.account.loan.LoanApproval
import rx.Observable

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

fun approveLoan(loanId: Int, loanApproval: LoanApproval?): Observable<GenericResponse>
fun approveLoan(loanId: Int, loanApproval: com.mifos.core.model.objects.account.loan.LoanApproval?): Observable<GenericResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ package com.mifos.core.data.repository
import com.mifos.core.entity.accounts.loan.Loans
import com.mifos.core.entity.templates.loans.LoanTemplate
import com.mifos.core.network.model.LoansPayload
import com.mifos.core.objects.organisations.LoanProducts
import rx.Observable

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

suspend fun allLoans(): Observable<List<LoanProducts>>
suspend fun allLoans(): Observable<List<com.mifos.core.model.objects.organisations.LoanProducts>>

suspend fun getLoansAccountTemplate(clientId: Int, productId: Int): Observable<LoanTemplate>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.loan.LoanRepaymentRequest
import com.mifos.core.entity.templates.loans.LoanRepaymentTemplate
import com.mifos.core.objects.account.loan.LoanRepaymentResponse
import rx.Observable

/**
Expand All @@ -24,7 +23,7 @@ interface LoanRepaymentRepository {
fun submitPayment(
loanId: Int,
request: LoanRepaymentRequest,
): Observable<LoanRepaymentResponse>
): Observable<com.mifos.core.model.objects.account.loan.LoanRepaymentResponse>

fun getDatabaseLoanRepaymentByLoanId(loanId: Int): Observable<LoanRepaymentRequest>
}
Loading
Loading