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; savings cleanup #2232

Merged
merged 1 commit into from
Nov 10, 2024
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
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://editorconfig.org/
# This configuration is used by ktlint when spotless invokes it

[*.{kt,kts}]
ij_kotlin_allow_trailing_comma=true
ij_kotlin_allow_trailing_comma_on_call_site=true
ktlint_function_naming_ignore_when_annotated_with=Composable, Test, Preview
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import org.gradle.configurationcache.extensions.capitalized
import org.gradle.internal.extensions.stdlib.capitalized
import org.gradle.kotlin.dsl.register
import org.gradle.language.base.plugins.LifecycleBasePlugin
import org.gradle.process.ExecOperations
Expand Down
Empty file added config/detekt/.editorconfig
Empty file.
6 changes: 3 additions & 3 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ complexity:
threshold: 600
LongMethod:
active: true
threshold: 180 #60
threshold: 360 #180 #60
LongParameterList:
active: true
# Updating Common values based on current scenario
Expand Down Expand Up @@ -785,7 +785,7 @@ style:
maxChainedCalls: 5
MaxLineLength:
active: true
maxLineLength: 120
maxLineLength: 150
excludePackageStatements: true
excludeImportStatements: true
excludeCommentStatements: false
Expand Down Expand Up @@ -828,7 +828,7 @@ style:
active: false
ReturnCount:
active: true
max: 2
max: 4
excludedFunctions:
- "equals"
excludeLabeled: false
Expand Down
9 changes: 9 additions & 0 deletions feature/savings/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* 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
*/
plugins {
alias(libs.plugins.mifos.android.feature)
alias(libs.plugins.mifos.android.library.compose)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
/*
* 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.feature.savings

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand All @@ -21,4 +28,4 @@ class ExampleInstrumentedTest {
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.mifos.feature.savings.test", appContext.packageName)
}
}
}
9 changes: 9 additions & 0 deletions feature/savings/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* 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.feature.savings.navigation

import androidx.navigation.NavController
Expand All @@ -9,11 +18,11 @@ import androidx.navigation.navigation
import com.mifos.core.common.utils.Constants
import com.mifos.core.objects.accounts.savings.DepositType
import com.mifos.core.objects.accounts.savings.SavingsAccountWithAssociations
import com.mifos.feature.savings.account.SavingsAccountScreen
import com.mifos.feature.savings.account_activate.SavingsAccountActivateScreen
import com.mifos.feature.savings.account_approval.SavingsAccountApprovalScreen
import com.mifos.feature.savings.account_summary.SavingsAccountSummaryScreen
import com.mifos.feature.savings.account_transaction.SavingsAccountTransactionScreen
import com.mifos.feature.savings.savingsAccount.SavingsAccountScreen
import com.mifos.feature.savings.savingsAccountActivate.SavingsAccountActivateScreen
import com.mifos.feature.savings.savingsAccountApproval.SavingsAccountApprovalScreen
import com.mifos.feature.savings.savingsAccountSummary.SavingsAccountSummaryScreen
import com.mifos.feature.savings.savingsAccountTransaction.SavingsAccountTransactionScreen

/**
* Created by Pronay Sarker on 14/08/2024 (1:10 PM)
Expand All @@ -22,41 +31,41 @@ import com.mifos.feature.savings.account_transaction.SavingsAccountTransactionSc
fun NavGraphBuilder.savingsNavGraph(
navController: NavController,
onBackPressed: () -> Unit,
loadMoreSavingsAccountInfo: (Int) -> Unit,
loadDocuments: (Int) -> Unit,
loadMoreSavingsAccountInfo: (String, Int) -> Unit,
loadDocuments: (Int, String) -> Unit,
) {
navigation(
startDestination = SavingsScreens.SavingsAccountSummary.route,
route = "savings_summary_route"
route = "savings_summary_route",
) {
savingsSummaryScreen(
onBackPressed = navController::popBackStack,
loadMoreSavingsAccountInfo = loadMoreSavingsAccountInfo,
loadDocuments = loadDocuments,
loadMoreSavingsAccountInfo = { loadMoreSavingsAccountInfo(Constants.DATA_TABLE_NAME_SAVINGS, it) },
loadDocuments = { loadDocuments(it, Constants.ENTITY_TYPE_SAVINGS) },
onDepositClick = { savingsAccountWithAssociations, depositType ->
navController.navigateToSavingsAccountTransactionScreen(
savingsAccountWithAssociations = savingsAccountWithAssociations,
depositType = depositType,
transactionType = Constants.SAVINGS_ACCOUNT_TRANSACTION_DEPOSIT
transactionType = Constants.SAVINGS_ACCOUNT_TRANSACTION_DEPOSIT,
)
},
onWithdrawButtonClicked = { savingsAccountWithAssociations, depositType ->
navController.navigateToSavingsAccountTransactionScreen(
savingsAccountWithAssociations = savingsAccountWithAssociations,
depositType = depositType,
transactionType = Constants.SAVINGS_ACCOUNT_TRANSACTION_WITHDRAWAL
transactionType = Constants.SAVINGS_ACCOUNT_TRANSACTION_WITHDRAWAL,
)
},
approveSavings = { _, accountNumber ->
navController.navigateToSavingsAccountApproval(
accountNumber
accountNumber,
)
},
activateSavings = { _, accountNumber ->
navController.navigateToSavingsAccountActivate(
accountNumber
accountNumber,
)
}
},
)

addSavingsAccountScreen {
Expand All @@ -78,18 +87,18 @@ fun NavGraphBuilder.savingsNavGraph(
}

fun NavGraphBuilder.addSavingsAccountScreen(
onBackPressed: () -> Unit
onBackPressed: () -> Unit,
) {
composable(
route = SavingsScreens.SavingsAccount.route,
arguments = listOf(
navArgument(name = Constants.GROUP_ID, builder = { type = NavType.IntType }),
navArgument(name = Constants.CLIENT_ID, builder = { type = NavType.IntType }),
navArgument(name = Constants.GROUP_ACCOUNT, builder = { type = NavType.BoolType })
)
navArgument(name = Constants.GROUP_ACCOUNT, builder = { type = NavType.BoolType }),
),
) {
SavingsAccountScreen(
navigateBack = onBackPressed
navigateBack = onBackPressed,
)
}
}
Expand All @@ -101,13 +110,13 @@ fun NavGraphBuilder.savingsSummaryScreen(
onDepositClick: (SavingsAccountWithAssociations, DepositType?) -> Unit,
onWithdrawButtonClicked: (SavingsAccountWithAssociations, DepositType?) -> Unit,
approveSavings: (savingsAccountType: DepositType?, savingsAccountNumber: Int) -> Unit,
activateSavings: (savingsAccountType: DepositType?, savingsAccountNumber: Int) -> Unit
activateSavings: (savingsAccountType: DepositType?, savingsAccountNumber: Int) -> Unit,
) {
composable(
route = SavingsScreens.SavingsAccountSummary.route,
arguments = listOf(
navArgument(name = "arg" , builder = { type = NavType.StringType })
)
navArgument(name = "arg", builder = { type = NavType.StringType }),
),
) {
SavingsAccountSummaryScreen(
navigateBack = onBackPressed,
Expand All @@ -116,60 +125,60 @@ fun NavGraphBuilder.savingsSummaryScreen(
onDepositClick = onDepositClick,
onWithdrawButtonClicked = onWithdrawButtonClicked,
approveSavings = approveSavings,
activateSavings = activateSavings
activateSavings = activateSavings,
)
}
}

fun NavGraphBuilder.savingsAccountActivateScreen(
onBackPressed: () -> Unit
onBackPressed: () -> Unit,
) {
composable(
route = SavingsScreens.SavingsAccountActivate.route,
arguments = listOf(
navArgument(name = Constants.SAVINGS_ACCOUNT_ID, builder = { type = NavType.IntType })
)
navArgument(name = Constants.SAVINGS_ACCOUNT_ID, builder = { type = NavType.IntType }),
),
) {
SavingsAccountActivateScreen(
navigateBack = onBackPressed
navigateBack = onBackPressed,
)
}
}

fun NavGraphBuilder.savingsAccountApprovalScreen(
onBackPressed: () -> Unit
onBackPressed: () -> Unit,
) {
composable(
route = SavingsScreens.SavingsAccountApproval.route,
arguments = listOf(
navArgument(name = Constants.SAVINGS_ACCOUNT_ID, builder = { type = NavType.IntType })
)
navArgument(name = Constants.SAVINGS_ACCOUNT_ID, builder = { type = NavType.IntType }),
),
) {
SavingsAccountApprovalScreen(
navigateBack = onBackPressed
navigateBack = onBackPressed,
)
}
}

fun NavGraphBuilder.savingsAccountTransactionScreen(
onBackPressed: () -> Unit
onBackPressed: () -> Unit,
) {
composable(
route = SavingsScreens.SavingsAccountTransaction.route,
arguments = listOf(
navArgument(name = "arg" , builder = { type = NavType.StringType })
)
navArgument(name = "arg", builder = { type = NavType.StringType }),
),
) {
SavingsAccountTransactionScreen(
navigateBack = onBackPressed
navigateBack = onBackPressed,
)
}
}

fun NavController.navigateToAddSavingsAccount(
groupId: Int,
clientId: Int,
isGroupAccount: Boolean
isGroupAccount: Boolean,
) {
navigate(SavingsScreens.SavingsAccount.argument(groupId, clientId, isGroupAccount))
}
Expand All @@ -182,20 +191,20 @@ fun NavController.navigateToSavingsAccountActivate(savingsAccountId: Int) {
navigate(SavingsScreens.SavingsAccountActivate.argument(savingsAccountId))
}

fun NavController.navigateToSavingsAccountSummaryScreen(id : Int, type: DepositType){
fun NavController.navigateToSavingsAccountSummaryScreen(id: Int, type: DepositType) {
navigate(SavingsScreens.SavingsAccountSummary.argument(id, type))
}

fun NavController.navigateToSavingsAccountTransactionScreen(
savingsAccountWithAssociations: SavingsAccountWithAssociations,
transactionType: String,
depositType: DepositType?
depositType: DepositType?,
) {
navigate(
SavingsScreens.SavingsAccountTransaction.argument(
savingsAccountWithAssociations,
transactionType,
depositType
)
depositType,
),
)
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* 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.feature.savings.navigation

import com.google.gson.Gson
Expand Down Expand Up @@ -45,7 +54,7 @@ sealed class SavingsScreens(val route: String) {
fun argument(
savingsAccountWithAssociations: SavingsAccountWithAssociations,
transactionType: String,
depositType: DepositType?
depositType: DepositType?,
): String {
val gson = Gson()
val arg = SavingsTransactionData(savingsAccountWithAssociations, depositType, transactionType)
Expand All @@ -58,4 +67,3 @@ sealed class SavingsScreens(val route: String) {
data object SavingsSyncAccountTransaction :
SavingsScreens("savings_sync_account_transaction")
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package com.mifos.feature.savings.account
/*
* 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.feature.savings.savingsAccount

import com.mifos.core.objects.client.Savings
import com.mifos.core.objects.zipmodels.SavingProductsAndTemplate
Expand All @@ -18,4 +27,4 @@ sealed class SavingAccountUiState {
data class ShowSavingsAccountCreatedSuccessfully(val savings: Savings?) : SavingAccountUiState()

data class ShowFetchingErrorString(val message: String) : SavingAccountUiState()
}
}
Loading
Loading