TP-69510 | Removed BankAccountEntity (#11911)

This commit is contained in:
vedant aggarwal
2024-07-25 17:43:53 +05:30
committed by GitHub
parent f8733cc821
commit 05ae5b2eb9
11 changed files with 86 additions and 91 deletions

View File

@@ -37,7 +37,6 @@ import com.navi.pay.management.upinumber.list.model.view.UpiNumber
import com.navi.pay.management.upinumber.list.model.view.UpiNumberLinkedAccountEntity
import com.navi.pay.onboarding.account.add.model.network.AccountItemResponse
import com.navi.pay.onboarding.account.add.model.view.AccountType
import com.navi.pay.onboarding.account.add.model.view.BankAccountEntity
import com.navi.pay.onboarding.account.add.model.view.BankEntity
import com.navi.pay.onboarding.account.detail.model.view.LinkedAccountEntity
import com.navi.pay.onboarding.account.linked.model.view.LinkedAccountsScreenSource
@@ -793,7 +792,7 @@ class NaviPayAnalytics private constructor() {
NaviTrackEvent.trackEventOnClickStream("NaviPay_SelectBank_Accounts_NotFound")
}
fun onBankAccountsFound(bankAccounts: List<BankAccountEntity>) {
fun onBankAccountsFound(bankAccounts: List<LinkedAccountEntity>) {
NaviTrackEvent.trackEventOnClickStream(
"NaviPay_SelectBank_Accounts_Found",
mapOf(Pair("bankAccountsSize", bankAccounts.size.toString()))
@@ -898,7 +897,7 @@ class NaviPayAnalytics private constructor() {
}
fun onUpiGuidelinesBottomSheetOpened(
bankInfo: BankAccountEntity,
bankInfo: LinkedAccountEntity,
onboardingSource: String? = null,
naviPaySessionAttributes: Map<String, String>? = null
) {

View File

@@ -8,9 +8,12 @@
package com.navi.pay.onboarding.account.add.model.network
import com.google.gson.annotations.SerializedName
import com.navi.pay.onboarding.account.add.model.view.BankAccountEntity
import com.navi.pay.R
import com.navi.pay.onboarding.account.add.model.view.BankEntity
import com.navi.pay.utils.getBankNameAccountNumberText
import com.navi.pay.onboarding.account.common.model.view.VpaEntity
import com.navi.pay.onboarding.account.common.model.view.VpaStatus
import com.navi.pay.onboarding.account.detail.model.view.LinkedAccountEntity
import com.navi.pay.utils.getAccountTypeFormattedValue
import com.navi.pay.utils.getMaskedAccountNumber
data class AccountItemResponse(
@@ -31,19 +34,38 @@ data class AccountItemResponse(
@SerializedName("creditLineNotAllowedMCC") val creditLineNotAllowedMCC: List<String>? = null
)
fun AccountItemResponse.toAccountEntity(selectedBank: BankEntity?): BankAccountEntity {
return BankAccountEntity(
accountId = bankAccountUniqueId,
bankCode = bankCode,
bankName = bankName,
bankLogoUrl = selectedBank?.iconUrl ?: "",
maskedAccountNumber = maskedAccountNumber.getMaskedAccountNumber(),
accountName = getBankNameAccountNumberText(bankName, maskedAccountNumber),
accountType = type,
vpaSuggestions = vpaSuggestions,
mPinSet = mPinSet,
creditLineAccSubType = creditLineAccSubType ?: "",
creditLineAllowedMCC = creditLineAllowedMCC ?: emptyList(),
creditLineNotAllowedMCC = creditLineNotAllowedMCC ?: emptyList()
fun AccountItemResponse.toLinkedAccountEntity(selectedBank: BankEntity?): LinkedAccountEntity {
return LinkedAccountEntity(
accountId = bankAccountUniqueId,
bankCode = bankCode,
bankName = bankName,
name = name,
ifsc = ifsc,
fallbackBankLogoResId = R.drawable.ic_np_default_bank_logo,
maskedAccountNumber = maskedAccountNumber.getMaskedAccountNumber(),
originalMaskedAccountNumber = maskedAccountNumber,
accountType = type,
vpaEntityList = vpaSuggestions.map { it.toVPAEntity(bankAccountUniqueId) },
isMPinSet = mPinSet,
mPinLength = mPinLength,
otpLength = otpLength,
atmPinLength = atmPinLength,
bankIconImageUrl = selectedBank?.iconUrl ?: "",
isAccountPrimary = false,
upiLiteInfo = emptyList(),
accountTypeFormatted = getAccountTypeFormattedValue(type),
creditLineAllowedMCC = creditLineAllowedMCC ?: emptyList(),
creditLineNotAllowedMCC = creditLineNotAllowedMCC ?: emptyList(),
)
.apply { creditLineAccSubType = creditLineAccSubType ?: "" }
}
// Converting VPA suggestions to list of VPA entity to store in LinkedAccountEntity
private fun String.toVPAEntity(buid: String): VpaEntity {
return VpaEntity(
vpa = this,
status = VpaStatus.ACTIVE, // dummy
isVpaPrimary = false, // dummy
bankAccountUniqueId = buid
)
}

View File

@@ -8,6 +8,7 @@
package com.navi.pay.onboarding.account.add.model.view
import com.navi.pay.common.model.view.NaviPayErrorConfig
import com.navi.pay.onboarding.account.detail.model.view.LinkedAccountEntity
import com.navi.pay.onboardingV2.utils.UpiGuidelineItem
sealed class AccountAdditionBottomSheetType {
@@ -31,11 +32,11 @@ sealed class AccountAdditionBottomSheetType {
data class UpiGuidelinesBottomSheet(
val guidelineItems: List<UpiGuidelineItem>,
val bankEntity: BankAccountEntity,
val bankEntity: LinkedAccountEntity,
) : AccountAdditionBottomSheetType()
data class FetchedAccountsList(
val accountEntities: List<BankAccountEntity>,
val accountEntities: List<LinkedAccountEntity>,
val selectedAccountType: AccountType
) : AccountAdditionBottomSheetType()

View File

@@ -1,28 +0,0 @@
/*
*
* * Copyright © 2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.pay.onboarding.account.add.model.view
import com.navi.pay.utils.getAccountTypeFormattedValue
data class BankAccountEntity(
val accountId: String,
val bankCode: String,
val bankName: String,
val bankLogoUrl: String,
val maskedAccountNumber: String,
val accountType: String,
val accountName: String,
var isSelected: Boolean = false,
val mPinSet: Boolean,
val vpaSuggestions: List<String>,
val creditLineAccSubType: String,
val creditLineAllowedMCC: List<String>,
val creditLineNotAllowedMCC: List<String>
) {
val accountTypeFormatted by lazy { getAccountTypeFormattedValue(accountType = accountType) }
}

View File

@@ -80,7 +80,7 @@ fun AccountAdditionScreen(
accountAdditionViewModel.effect.collectLatest {
when (it) {
is AccountAdditionScreenContract.Effect.FinishActivity -> {
if (!it.selectedAccount?.mPinSet.orTrue()) {
if (!it.selectedAccount?.isMPinSet.orTrue()) {
accountAdditionViewModel.startPinAction(
activity = naviPayOnboardingActivityV2,
launcher = launcher,

View File

@@ -48,7 +48,7 @@ import com.navi.pay.common.ui.ImageWithCircularBackground
import com.navi.pay.common.ui.LoaderRoundedButton
import com.navi.pay.common.ui.NaviPayRadioButton
import com.navi.pay.onboarding.account.add.model.view.AccountType
import com.navi.pay.onboarding.account.add.model.view.BankAccountEntity
import com.navi.pay.onboarding.account.detail.model.view.LinkedAccountEntity
import com.navi.pay.onboardingV2.model.view.AccountAdditionScreenContract
import com.navi.pay.utils.NAVI_PAY_PRIMARY_CTA_LOADER_LOTTIE
import com.navi.pay.utils.clickableDebounce
@@ -56,7 +56,7 @@ import com.navi.rr.utils.ext.clickable
@Composable
fun FetchedAccountsListBottomSheet(
accountEntities: List<BankAccountEntity>,
accountEntities: List<LinkedAccountEntity>,
eventDispatcher: (AccountAdditionScreenContract.Event) -> Unit,
enableAddAccountCtaLoaderState: Boolean,
selectedAccountType: AccountType
@@ -152,7 +152,7 @@ fun FetchedAccountsListBottomSheet(
@Composable
private fun BankAccountEntityItem(
bankAccountEntity: BankAccountEntity,
bankAccountEntity: LinkedAccountEntity,
onSelected: () -> Unit,
isSelected: Boolean
) {
@@ -179,7 +179,7 @@ private fun BankAccountEntityItem(
color = NaviPayColor.borderAlt,
shape = CircleShape
),
imageUrl = bankAccountEntity.bankLogoUrl,
imageUrl = bankAccountEntity.bankIconImageUrl,
imageSize = 32.dp,
fallbackIconUrl = R.drawable.ic_np_default_bank_logo
)
@@ -189,7 +189,7 @@ private fun BankAccountEntityItem(
Column {
Row(verticalAlignment = Alignment.CenterVertically) {
NaviText(
text = bankAccountEntity.accountName,
text = bankAccountEntity.bankNameAccountNumber,
fontSize = 16.sp,
fontFamily = ttComposeFontFamily,
fontWeight = getFontWeight(FontWeightEnum.NAVI_HEADLINE_REGULAR),

View File

@@ -53,7 +53,6 @@ import com.navi.pay.common.ui.NaviPayRadioButton
import com.navi.pay.common.ui.ThemeRoundedButton
import com.navi.pay.destinations.NaviPayLauncherScreenDestination
import com.navi.pay.onboarding.account.add.model.view.AccountType
import com.navi.pay.onboarding.account.add.model.view.BankAccountEntity
import com.navi.pay.onboarding.account.add.viewmodel.SelectBankScreenBottomSheetUIState
import com.navi.pay.onboarding.account.detail.model.view.LinkedAccountEntity
import com.navi.pay.onboardingV2.utils.getDescriptionTextIdForNoLinkedAccountsAsPerAccountType
@@ -69,7 +68,7 @@ fun SelectBankAccountBottomSheet(
selectBankScreenBottomSheetUIState: SelectBankScreenBottomSheetUIState,
naviPayAnalytics: NaviPayAnalytics.NaviPaySelectBank,
onAccountSearchNoAccountFoundButtonClicked: () -> Unit,
onAccountSelected: (BankAccountEntity) -> Unit,
onAccountSelected: (LinkedAccountEntity) -> Unit,
onLinkAccountClicked: () -> Unit,
onAddAccountRetry: () -> Unit,
navigator: DestinationsNavigator,
@@ -165,8 +164,8 @@ fun SelectBankAccountBottomSheet(
@Composable
private fun BankAccountFoundView(
accountEntities: List<BankAccountEntity>,
onAccountSelected: (BankAccountEntity) -> Unit,
accountEntities: List<LinkedAccountEntity>,
onAccountSelected: (LinkedAccountEntity) -> Unit,
onLinkAccountClick: () -> Unit,
accountType: AccountType,
onDismissClicked: () -> Unit
@@ -244,8 +243,8 @@ private fun BankAccountFoundView(
@Composable
private fun BankAccountEntityItem(
bankAccountEntity: BankAccountEntity,
onSelected: (BankAccountEntity) -> Unit,
bankAccountEntity: LinkedAccountEntity,
onSelected: (LinkedAccountEntity) -> Unit,
isSelected: Boolean
) {
Column(
@@ -266,7 +265,7 @@ private fun BankAccountEntityItem(
boxSize = 40.dp,
backgroundColor = NaviPayColor.ctaWhite,
backgroundCornerRadius = 4.dp,
imageUrl = bankAccountEntity.bankLogoUrl,
imageUrl = bankAccountEntity.bankIconImageUrl,
imageSize = 36.dp
)
@@ -275,7 +274,7 @@ private fun BankAccountEntityItem(
Column {
Row(verticalAlignment = Alignment.CenterVertically) {
NaviText(
text = bankAccountEntity.accountName,
text = bankAccountEntity.bankNameAccountNumber,
fontSize = 16.sp,
fontFamily = ttComposeFontFamily,
fontWeight = getFontWeight(FontWeightEnum.NAVI_HEADLINE_REGULAR),

View File

@@ -44,14 +44,14 @@ import com.navi.pay.onboarding.account.add.model.network.AccountItemResponse
import com.navi.pay.onboarding.account.add.model.network.AddAccountRequest
import com.navi.pay.onboarding.account.add.model.network.FetchAccountsRequest
import com.navi.pay.onboarding.account.add.model.network.FetchAccountsResponse
import com.navi.pay.onboarding.account.add.model.network.toAccountEntity
import com.navi.pay.onboarding.account.add.model.network.toLinkedAccountEntity
import com.navi.pay.onboarding.account.add.model.view.AccountAdditionBottomSheetStateHolder
import com.navi.pay.onboarding.account.add.model.view.AccountAdditionBottomSheetType
import com.navi.pay.onboarding.account.add.model.view.AccountType
import com.navi.pay.onboarding.account.add.model.view.BankAccountEntity
import com.navi.pay.onboarding.account.add.model.view.BankEntity
import com.navi.pay.onboarding.account.add.model.view.EnabledAccountAdditionTypes
import com.navi.pay.onboarding.account.add.repository.BankRepository
import com.navi.pay.onboarding.account.detail.model.view.LinkedAccountEntity
import com.navi.pay.onboardingV2.model.view.AccountAdditionScreenContract
import com.navi.pay.onboardingV2.model.view.AccountAdditionUiState
import com.navi.pay.onboardingV2.utils.OnboardingIntentDataProvider
@@ -273,7 +273,7 @@ constructor(
}
private suspend fun updateCustomerStatusInDataStoreAndFinishActivity(
selectedAccount: BankAccountEntity? = null,
selectedAccount: LinkedAccountEntity? = null,
isBackPressed: Boolean = false
) {
dataStoreInfoProvider.saveStringData(
@@ -386,8 +386,7 @@ constructor(
accountsResponse.refresh(newList = fetchBankAccountResponse)
val accountEntities =
accountsResponse.map { it.toAccountEntity(selectedBank = selectedAccount) }
accountEntities[0].isSelected = true
accountsResponse.map { it.toLinkedAccountEntity(selectedBank = selectedAccount) }
if (accountEntities.size == 1) {
linkAccount(selectedAccount = accountEntities[0], selectedAccountType)
@@ -406,7 +405,10 @@ constructor(
}
}
private fun linkAccount(selectedAccount: BankAccountEntity, selectedAccountType: AccountType) {
private fun linkAccount(
selectedAccount: LinkedAccountEntity,
selectedAccountType: AccountType
) {
viewModelScope.safeLaunch(coroutineDispatcherProvider.io) {
val selectedVpa = getSelectedVpa(selectedAccount = selectedAccount)
val addAccountApiResponse =
@@ -431,16 +433,16 @@ constructor(
}
}
private fun getSelectedVpa(selectedAccount: BankAccountEntity): String {
return if (selectedAccount.vpaSuggestions.isNotEmpty()) {
selectedAccount.vpaSuggestions[0]
private fun getSelectedVpa(selectedAccount: LinkedAccountEntity): String {
return if (selectedAccount.vpaEntityList.isNotEmpty()) {
selectedAccount.vpaEntityList[0].vpa
} else {
""
}
}
private suspend fun addBankAccount(
selectedAccount: BankAccountEntity,
selectedAccount: LinkedAccountEntity,
selectedVpa: String,
selectedAccountType: AccountType
): RepoResult<Any?> {
@@ -466,7 +468,7 @@ constructor(
notifyError(response = addAccountApiResponse, cancelable = false)
}
private suspend fun handleAddAccountSuccess(selectedAccount: BankAccountEntity) {
private suspend fun handleAddAccountSuccess(selectedAccount: LinkedAccountEntity) {
_bindingProgress.update { 1f }
_enableAddAccountCtaLoaderState.update { false }
naviPayCustomerStatusHandler.updateCustomerStatus(
@@ -480,7 +482,7 @@ constructor(
checkIfUpiGuidelinesBottomSheetVisibility(selectedAccount = selectedAccount)
}
private fun showAddAccountSuccessBottomSheet(selectedAccount: BankAccountEntity) {
private fun showAddAccountSuccessBottomSheet(selectedAccount: LinkedAccountEntity) {
updateBottomSheetUIState(
showBottomSheet = true,
bottomSheetStateChange = false,
@@ -506,10 +508,10 @@ constructor(
}
private suspend fun checkIfUpiGuidelinesBottomSheetVisibility(
selectedAccount: BankAccountEntity
selectedAccount: LinkedAccountEntity
) {
if (!isUpiGuidelinesBottomSheetVisible()) {
if (!selectedAccount.mPinSet) {
if (!selectedAccount.isMPinSet) {
updateBottomSheetUIState(
showBottomSheet = true,
bottomSheetStateChange = false,
@@ -526,7 +528,7 @@ constructor(
}
}
private fun openUpiGuidelinesBottomSheet(bankEntity: BankAccountEntity) {
private fun openUpiGuidelinesBottomSheet(bankEntity: LinkedAccountEntity) {
naviPayAnalytics.onUpiGuidelinesBottomSheetOpened(
bankInfo = bankEntity,
onboardingSource = onboardingSource,
@@ -543,7 +545,7 @@ constructor(
)
}
private suspend fun onUpiGuidelinesContinueClicked(bankEntity: BankAccountEntity) {
private suspend fun onUpiGuidelinesContinueClicked(bankEntity: LinkedAccountEntity) {
updateCustomerStatusInDataStoreAndFinishActivity(selectedAccount = bankEntity)
}

View File

@@ -39,9 +39,8 @@ import com.navi.pay.management.upinumber.list.viewmodel.UpiNumberViewModel.Compa
import com.navi.pay.onboarding.account.add.model.network.AccountItemResponse
import com.navi.pay.onboarding.account.add.model.network.AddAccountRequest
import com.navi.pay.onboarding.account.add.model.network.FetchAccountsRequest
import com.navi.pay.onboarding.account.add.model.network.toAccountEntity
import com.navi.pay.onboarding.account.add.model.network.toLinkedAccountEntity
import com.navi.pay.onboarding.account.add.model.view.AccountType
import com.navi.pay.onboarding.account.add.model.view.BankAccountEntity
import com.navi.pay.onboarding.account.add.model.view.BankEntity
import com.navi.pay.onboarding.account.add.model.view.SelectBankScreenBottomSheetHandler
import com.navi.pay.onboarding.account.add.repository.BankRepository
@@ -171,7 +170,7 @@ constructor(
val bottomSheetStateHolder = _bottomSheetStateHolder.asStateFlow()
var selectedBank: BankEntity? = null
private var selectedAccount: BankAccountEntity? = null
private var selectedAccount: LinkedAccountEntity? = null
private val _uiState = MutableStateFlow<SelectBankScreenStates>(SelectBankScreenStates.Loader)
val uiState = _uiState.asStateFlow()
@@ -237,7 +236,7 @@ constructor(
}
}
private fun updateSelectedAccount(selectedAccount: BankAccountEntity?) {
private fun updateSelectedAccount(selectedAccount: LinkedAccountEntity?) {
this.selectedAccount = selectedAccount
}
@@ -326,9 +325,8 @@ constructor(
noBankFoundCount = 0
accountsResponse.refresh(fetchBankAccountsList)
val accountEntities =
accountsResponse.map { it.toAccountEntity(selectedBank = selectedBank) }
accountsResponse.map { it.toLinkedAccountEntity(selectedBank = selectedBank) }
updateSelectedAccount(selectedAccount = accountEntities[0])
accountEntities[0].isSelected = true
if (accountEntities.size == 1) {
linkAccount()
@@ -362,7 +360,7 @@ constructor(
}
}
fun onAccountSelected(bankAccountEntity: BankAccountEntity) {
fun onAccountSelected(bankAccountEntity: LinkedAccountEntity) {
selectedAccount = bankAccountEntity
}
@@ -535,7 +533,7 @@ sealed class SelectBankScreenStates {
sealed class SelectBankScreenBottomSheetUIState {
data object Searching : SelectBankScreenBottomSheetUIState()
data class Found(val accountEntities: List<BankAccountEntity>) :
data class Found(val accountEntities: List<LinkedAccountEntity>) :
SelectBankScreenBottomSheetUIState()
data object NotFound : SelectBankScreenBottomSheetUIState()

View File

@@ -98,4 +98,6 @@ data class LinkedAccountEntity(
@IgnoredOnParcel var isDisabled: Boolean = false
@IgnoredOnParcel var infoMessage: String? = null
@IgnoredOnParcel var creditLineAccSubType: String? = null
}

View File

@@ -9,8 +9,8 @@ package com.navi.pay.onboardingV2.model.view
import com.navi.pay.common.viewmodel.NaviPayViewModelContract
import com.navi.pay.onboarding.account.add.model.view.AccountType
import com.navi.pay.onboarding.account.add.model.view.BankAccountEntity
import com.navi.pay.onboarding.account.add.model.view.BankEntity
import com.navi.pay.onboarding.account.detail.model.view.LinkedAccountEntity
interface AccountAdditionScreenContract :
NaviPayViewModelContract<
@@ -32,7 +32,7 @@ interface AccountAdditionScreenContract :
sealed class Effect {
data class FinishActivity(
val selectedAccount: BankAccountEntity?,
val selectedAccount: LinkedAccountEntity?,
val isBackPressed: Boolean
) : Effect()
}
@@ -48,10 +48,10 @@ interface AccountAdditionScreenContract :
data object OnZeroLinkedAccountsCtaClicked : Event()
data class OnUpiGuidelinesContinueClicked(val bankEntity: BankAccountEntity) : Event()
data class OnUpiGuidelinesContinueClicked(val bankEntity: LinkedAccountEntity) : Event()
data class OnFetchedAccountSelected(
val bankEntity: BankAccountEntity,
val bankEntity: LinkedAccountEntity,
val selectedAccountType: AccountType
) : Event()