Skip to content

Commit cb3975c

Browse files
feat(core:model): Migrate model module to KMP (#2732)
* feat(core:model): Migrate model module to KMP * Change properties from var to val and remove unnecessary annotations * remove inheritance of Account in ShareAccount, SavingAccount and LoanAccount * replace ArrayList() with emptyList() and improve numeric literal consistency
1 parent 174ccd2 commit cb3975c

File tree

177 files changed

+2276
-2427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+2276
-2427
lines changed

core/model/build.gradle.kts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
99
*/
1010
plugins {
11-
alias(libs.plugins.mifos.android.library)
12-
alias(libs.plugins.kotlin.android)
11+
alias(libs.plugins.mifos.kmp.library)
1312
alias(libs.plugins.kotlin.serialization)
1413
alias(libs.plugins.kotlin.parcelize)
1514
}
@@ -21,17 +20,15 @@ android {
2120
}
2221
}
2322

24-
dependencies {
25-
26-
api(projects.core.common)
27-
28-
implementation(libs.jetbrains.kotlin.jdk7)
29-
implementation(libs.kotlinx.serialization.json)
30-
31-
// For Serialized name
32-
implementation(libs.squareup.retrofit.converter.gson)
33-
34-
testImplementation(libs.junit)
35-
androidTestImplementation(libs.androidx.test.ext.junit)
36-
androidTestImplementation(libs.androidx.test.espresso.core)
23+
kotlin {
24+
androidTarget {
25+
compilerOptions {
26+
freeCompilerArgs.addAll("-P", "plugin:org.jetbrains.kotlin.parcelize:additionalAnnotation=org.mifos.mobile.core.model.Parcelize")
27+
}
28+
}
29+
sourceSets {
30+
commonMain.dependencies {
31+
implementation(libs.kotlinx.serialization.json)
32+
}
33+
}
3734
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
9+
*/
10+
package org.mifos.mobile.core.model
11+
12+
import android.os.Parcelable
13+
import kotlinx.parcelize.IgnoredOnParcel
14+
import kotlinx.parcelize.RawValue
15+
16+
actual typealias Parcelable = Parcelable
17+
18+
actual typealias IgnoredOnParcel = IgnoredOnParcel
19+
20+
actual typealias RawValue = RawValue
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
9+
*/
10+
package org.mifos.mobile.core.model
11+
12+
annotation class Parcelize()
13+
14+
expect interface Parcelable
15+
16+
expect annotation class IgnoredOnParcel()
17+
18+
@Target(AnnotationTarget.TYPE)
19+
expect annotation class RawValue()

core/model/src/main/java/org/mifos/mobile/core/model/entity/Charge.kt renamed to core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/Charge.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
*/
1010
package org.mifos.mobile.core.model.entity
1111

12-
import android.os.Parcelable
13-
import kotlinx.parcelize.Parcelize
12+
import org.mifos.mobile.core.model.Parcelable
13+
import org.mifos.mobile.core.model.Parcelize
1414

1515
@Parcelize
1616
data class Charge(
1717
val clientId: Int? = null,
1818
val chargeId: Int? = null,
1919
val name: String? = null,
20-
val dueDate: ArrayList<Int?> = ArrayList(),
20+
val dueDate: ArrayList<Int?> = arrayListOf(),
2121
val chargeTimeType: ChargeTimeType? = null,
2222
val chargeCalculationType: ChargeCalculationType? = null,
2323
val currency: Currency? = null,

core/model/src/main/java/org/mifos/mobile/core/model/entity/ChargeCalculationType.kt renamed to core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/ChargeCalculationType.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
*/
1010
package org.mifos.mobile.core.model.entity
1111

12-
import android.os.Parcelable
13-
import kotlinx.parcelize.Parcelize
1412
import kotlinx.serialization.Serializable
13+
import org.mifos.mobile.core.model.Parcelable
14+
import org.mifos.mobile.core.model.Parcelize
1515

1616
@Parcelize
1717
@Serializable
1818
data class ChargeCalculationType(
19-
var id: Int = 0,
20-
var code: String? = null,
21-
var value: String? = null,
19+
val id: Int = 0,
20+
val code: String? = null,
21+
val value: String? = null,
2222
) : Parcelable

core/model/src/main/java/org/mifos/mobile/core/model/entity/ChargeTimeType.kt renamed to core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/ChargeTimeType.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
*/
1010
package org.mifos.mobile.core.model.entity
1111

12-
import android.os.Parcelable
13-
import kotlinx.parcelize.Parcelize
12+
import org.mifos.mobile.core.model.Parcelable
13+
import org.mifos.mobile.core.model.Parcelize
1414

1515
/**
1616
* Created by michaelsosnick on 12/11/16.
1717
*/
1818

1919
@Parcelize
2020
data class ChargeTimeType(
21-
var id: Int = 0,
22-
var code: String? = null,
23-
var value: String? = null,
21+
val id: Int = 0,
22+
val code: String? = null,
23+
val value: String? = null,
2424
) : Parcelable

core/model/src/main/java/org/mifos/mobile/core/model/entity/CheckboxStatus.kt renamed to core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/CheckboxStatus.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ package org.mifos.mobile.core.model.entity
1313
* Created by dilpreet on 3/7/17.
1414
*/
1515

16-
data class CheckboxStatus @JvmOverloads constructor(
17-
var status: String?,
18-
var color: Int,
19-
var isChecked: Boolean = false,
16+
data class CheckboxStatus(
17+
val status: String?,
18+
val color: Int,
19+
val isChecked: Boolean = false,
2020
)

0 commit comments

Comments
 (0)