Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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 @@ -60,6 +60,7 @@ import androidx.compose.material.icons.outlined.ContentCopy
import androidx.compose.material.icons.outlined.CurrencyExchange
import androidx.compose.material.icons.outlined.DateRange
import androidx.compose.material.icons.outlined.DeleteOutline
import androidx.compose.material.icons.outlined.Directions
import androidx.compose.material.icons.outlined.DocumentScanner
import androidx.compose.material.icons.outlined.Draw
import androidx.compose.material.icons.outlined.EventRepeat
Expand Down Expand Up @@ -252,4 +253,6 @@ object MifosIcons {
val Copy = Icons.Outlined.ContentCopy
val Currency = Icons.Outlined.CurrencyExchange
val Camera = Icons.Outlined.Camera

val TransferFund = Icons.Outlined.Directions
Comment thread
Arinyadav1 marked this conversation as resolved.
Outdated
}
Comment thread
Arinyadav1 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ import kotlinx.serialization.Serializable
*/
@Serializable
data class AccountTransferRequest(
val fromOfficeId: Int,
val fromClientId: Int,
val fromAccountType: Int,
val fromAccountId: Int,
val toOfficeId: Int,
val toClientId: Int,
val toAccountType: Int,
val toAccountId: Int,
val transferDate: String,
val transferAmount: Double,
val transferDescription: String,
val dateFormat: String,
val locale: String,
val fromOfficeId: Int? = null,
val fromClientId: Int? = null,
val fromAccountType: Int? = null,
val fromAccountId: Int? = null,
val toOfficeId: Int? = null,
val toClientId: Int? = null,
val toAccountType: Int? = null,
val toAccountId: Int? = null,
val transferDate: String? = null,
val transferAmount: Double? = null,
val transferDescription: String? = null,
val dateFormat: String? = null,
val locale: String? = null,
)
Comment thread
Arinyadav1 marked this conversation as resolved.
1 change: 1 addition & 0 deletions core/ui/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<string name="core_ui_pay_outstanding_amount">Pay Outstanding Amount</string>
<string name="core_ui_edit">Edit</string>
<string name="core_ui_delete">Delete</string>
<string name="core_ui_transfer_fund">Transfer Fund</string>
Comment thread
Arinyadav1 marked this conversation as resolved.

<!-- Mifos Note -->
<string name="core_ui_note_createdBy">Created By:</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import androidclient.core.ui.generated.resources.core_ui_quantity
import androidclient.core.ui.generated.resources.core_ui_status
import androidclient.core.ui.generated.resources.core_ui_total_collateral_value
import androidclient.core.ui.generated.resources.core_ui_total_value
import androidclient.core.ui.generated.resources.core_ui_transfer_fund
import androidclient.core.ui.generated.resources.core_ui_type
import androidclient.core.ui.generated.resources.core_ui_upload_again
import androidclient.core.ui.generated.resources.core_ui_view_account
Expand Down Expand Up @@ -826,6 +827,8 @@ sealed class Actions(open val icon: ImageVector, open val text: StringResource)
Actions(icon, Res.string.core_ui_edit)
data class Delete(override val icon: ImageVector = MifosIcons.DeleteDocument) :
Actions(icon, Res.string.core_ui_delete)
data class TransferFund(override val icon: ImageVector = MifosIcons.TransferFund) :
Actions(icon, Res.string.core_ui_transfer_fund)
Comment thread
Arinyadav1 marked this conversation as resolved.
Outdated
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fun NavGraphBuilder.clientLoanAccountsDestination(
navController: NavController,
navigateToViewAccount: (Int) -> Unit,
navigateToMakeRepayment: (Int) -> Unit,
navigateToTransferFund: (Int) -> Unit,
createAccount: (Int, String) -> Unit,
) {
composable<ClientLoanAccountsRoute> {
Expand All @@ -32,6 +33,7 @@ fun NavGraphBuilder.clientLoanAccountsDestination(
viewAccount = navigateToViewAccount,
makeRepayment = navigateToMakeRepayment,
navController = navController,
transferFund = navigateToTransferFund,
createAccount = { clientId, accountNo -> createAccount(clientId, accountNo) },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ internal fun ClientLoanAccountsScreenRoute(
navigateBack: () -> Unit,
makeRepayment: (Int) -> Unit,
viewAccount: (Int) -> Unit,
transferFund: (Int) -> Unit,
navController: NavController,
createAccount: (Int, String) -> Unit,
viewModel: ClientLoanAccountsViewModel = koinViewModel(),
Expand All @@ -97,6 +98,7 @@ internal fun ClientLoanAccountsScreenRoute(
ClientLoanAccountsEvent.NavigateBack -> navigateBack()
is ClientLoanAccountsEvent.ViewAccount -> viewAccount(event.id)
is ClientLoanAccountsEvent.AddAccount -> createAccount(event.clientId, event.accountNo)
is ClientLoanAccountsEvent.TransferFund -> transferFund(event.loanId)
}
}

Expand Down Expand Up @@ -183,9 +185,13 @@ private fun ClientLoanAccountsScreen(
Res.string.client_loan_accounts_not_available,
)
),
loanProduct = loan.productName ?: stringResource(Res.string.client_loan_accounts_not_available),
loanProduct = loan.productName
?: stringResource(Res.string.client_loan_accounts_not_available),
originalLoan = symbol + (
(loan.originalLoan ?: stringResource(Res.string.client_loan_accounts_not_available)).toString()
(
loan.originalLoan
?: stringResource(Res.string.client_loan_accounts_not_available)
).toString()
),
amountPaid = symbol + (
(
Expand All @@ -211,27 +217,27 @@ private fun ClientLoanAccountsScreen(
}
)
),
type = loan.loanType?.value ?: stringResource(Res.string.client_loan_accounts_not_available),
status = loan.status?.value ?: stringResource(Res.string.client_loan_accounts_not_available),
type = loan.loanType?.value
?: stringResource(Res.string.client_loan_accounts_not_available),
status = loan.status?.value
?: stringResource(Res.string.client_loan_accounts_not_available),
// TODO check if we need to add other options as well, such as disburse and all
// currently didn't add it cuz its not in the UI design
menuList = when {
loan.status?.active == true -> {
listOf(
Actions.ViewAccount(
vectorResource(Res.drawable.wallet),
),
menuList = buildList {
add(
Actions.ViewAccount(
vectorResource(Res.drawable.wallet),
),
)

when {
loan.status?.active == true -> add(
Actions.MakeRepayment(
vectorResource(Res.drawable.cash_bundel),
),
)
}

else -> {
listOf(
Actions.ViewAccount(
vectorResource(Res.drawable.wallet),
),
loan.status?.overpaid == true -> add(
Actions.TransferFund(),
)
}
},
Expand All @@ -240,8 +246,16 @@ private fun ClientLoanAccountsScreen(
is Actions.ViewAccount -> onAction(
ClientLoanAccountsAction.ViewAccount(loan.id ?: 0),
)

is Actions.MakeRepayment -> onAction(
ClientLoanAccountsAction.MakeRepayment(loan.id ?: 0),
ClientLoanAccountsAction.MakeRepayment(
loan.id ?: 0,
),
)
is Actions.TransferFund -> onAction(
ClientLoanAccountsAction.TransferFund(
loanId = loan.id ?: -1,
Comment thread
biplab1 marked this conversation as resolved.
Outdated
),
)

else -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ClientLoanAccountsViewModel(
action.loanId,
),
)

is ClientLoanAccountsAction.HandleFilterClick -> handleFilterClick(action.status)

is ClientLoanAccountsAction.ClearFilters -> clearFilters()
Expand All @@ -92,6 +93,14 @@ class ClientLoanAccountsViewModel(
)
}
}

is ClientLoanAccountsAction.TransferFund -> {
sendEvent(
ClientLoanAccountsEvent.TransferFund(
loanId = action.loanId,
),
)
}
}
}

Expand Down Expand Up @@ -188,6 +197,7 @@ class ClientLoanAccountsViewModel(
)
}
}

private val LoanStatusEntity.isActuallyClosed: Boolean
get() = this.closed == true ||
this.closedObligationsMet == true ||
Expand Down Expand Up @@ -222,6 +232,9 @@ sealed interface ClientLoanAccountsEvent {
data class AddAccount(val clientId: Int, val accountNo: String) : ClientLoanAccountsEvent
data class MakeRepayment(val id: Int) : ClientLoanAccountsEvent
data class ViewAccount(val id: Int) : ClientLoanAccountsEvent
data class TransferFund(
val loanId: Int,
) : ClientLoanAccountsEvent
}

sealed interface ClientLoanAccountsAction {
Expand All @@ -238,6 +251,9 @@ sealed interface ClientLoanAccountsAction {
data object CloseDialog : ClientLoanAccountsAction
data class HandleFilterClick(val status: LoanStatusFilter) : ClientLoanAccountsAction
data object ClearFilters : ClientLoanAccountsAction
data class TransferFund(
val loanId: Int,
) : ClientLoanAccountsAction
}

enum class LoanStatusFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import com.mifos.feature.dataTable.navigation.navigateToDataTable
import com.mifos.feature.document.navigation.documentListScreen
import com.mifos.feature.document.navigation.navigateToDocumentListScreen
import com.mifos.feature.groups.navigation.navigateToGroupDetailsScreen
import com.mifos.feature.loan.amountTransfer.navigateToTransferScreen
import com.mifos.feature.loan.loanAccount.navigateToLoanAccountScreen
import com.mifos.feature.loan.loanAccountProfile.navigateToLoanAccountProfileScreen
import com.mifos.feature.loan.loanAccountSummary.navigateToLoanAccountSummaryScreen
Expand Down Expand Up @@ -338,6 +339,7 @@ fun NavGraphBuilder.clientNavGraph(
navigateBack = navController::popBackStack,
navigateToViewAccount = navController::navigateToLoanAccountProfileScreen,
navigateToMakeRepayment = navController::navigateToLoanRepaymentScreen,
navigateToTransferFund = navController::navigateToTransferScreen,
navController = navController,
createAccount = { clientId, accountNo -> navController.navigateToNewLoanAccountRoute(clientId, accountNo) },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,15 @@ import kotlinx.serialization.Serializable

@Serializable
data class AmountTransferScreenRoute(
val fromClientId: Int,
val fromAccountId: Int,
// for loan its 1
val fromAccountType: Int = 1,
val fromAccountNumber: String? = null,
val fromOfficeId: Int? = null,
val currency: String? = null,
)

fun NavController.navigateToTransferScreen(
fromAccountId: Int,
fromAccountNumber: String,
fromClientId: Int,
currency: String,
fromOfficeId: Int,
) {
navigate(
AmountTransferScreenRoute(
fromClientId = fromClientId,
fromAccountId = fromAccountId,
fromAccountNumber = fromAccountNumber,
fromOfficeId = fromOfficeId,
currency = currency,
),
)
}
Expand Down
Loading
Loading