NTP-7179 | Narayan | Fixed Auto pay details empty bank account section (#14430)

This commit is contained in:
Aditya Narayan Malik
2025-01-03 20:31:47 +05:30
committed by GitHub
parent 5d9ae3490d
commit 004d78edc5
5 changed files with 59 additions and 48 deletions

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2024 by Navi Technologies Limited
* * Copyright © 2024-2025 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -11,7 +11,6 @@ import com.google.gson.reflect.TypeToken
import com.navi.base.cache.datastore.DataStoreHelper
import com.navi.base.utils.EMPTY
import com.navi.base.utils.ResourceProvider
import com.navi.common.R as CommonR
import com.navi.common.upi.UPI_LITE_ACCOUNT_TYPE_VALUE
import com.navi.common.upi.UPI_LITE_BANK_NAME_VALUE
import com.navi.common.utils.Constants.UNDERSCORE
@@ -20,7 +19,7 @@ import com.navi.pay.common.bankuptime.model.view.BankUptimeStatus
import com.navi.pay.common.bankuptime.repository.BankUptimeRepository
import com.navi.pay.common.model.config.NaviPayDefaultAccountSelectionConfig
import com.navi.pay.common.theme.color.NaviPayColor
import com.navi.pay.common.utils.getAccountTypeFormattedValue
import com.navi.pay.common.utils.accountEntityToLinkedAccountEntity
import com.navi.pay.management.common.sendmoney.model.view.EligibilityState
import com.navi.pay.management.lite.util.UpiLiteClHelper
import com.navi.pay.onboarding.account.add.model.view.AccountType
@@ -33,7 +32,6 @@ import com.navi.pay.utils.KEY_UPI_PRIMARY_ACCOUNT_VPA
import com.navi.pay.utils.NAVI_PAY_UPI_LITE_LOGO_URL
import com.navi.pay.utils.UPI_DEFAULT_ACCOUNT_SELECTION_CONFIG
import com.navi.pay.utils.getIfscForBankUptime
import com.navi.pay.utils.getMaskedAccountNumber
import com.navi.pay.utils.getUpiLiteFormattedAccountId
import com.navi.pay.utils.isAccountIdOfTypeUpiLite
import javax.inject.Inject
@@ -87,35 +85,13 @@ constructor(
val linkedAccounts =
activeAccounts.map {
LinkedAccountEntity(
accountId = it.bankAccountUniqueId,
bankCode = it.bankCode,
bankName = it.bankName,
name = it.name,
ifsc = it.ifsc,
fallbackBankLogoResId =
CommonR.drawable.ic_upi_bbps_default_bank_logo,
maskedAccountNumber =
it.maskedAccountNumber.getMaskedAccountNumber(),
originalMaskedAccountNumber = it.maskedAccountNumber,
accountType = it.type,
accountEntityToLinkedAccountEntity(
accountEntity = it,
vpaEntityList =
buidMappedVpaEntities.getOrElse(
key = it.bankAccountUniqueId,
defaultValue = { emptyList() }
),
isMPinSet = it.mPinSet,
mPinLength = it.mPinLength,
otpLength = it.otpLength,
atmPinLength = it.atmPinLength,
bankIconImageUrl = it.bankIconUrl,
isAccountPrimary = it.isAccountPrimary,
upiLiteInfo = it.upiLiteInfo,
accountTypeFormatted =
getAccountTypeFormattedValue(accountType = it.type),
creditLineAllowedMCC = it.creditLineAllowedMCC,
creditLineNotAllowedMCC = it.creditLineNotAllowedMCC,
updatedAt = it.updatedAt
)
)
}
if (!includeAllDetails) {

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2024 by Navi Technologies Limited
* * Copyright © 2024-2025 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -85,6 +85,8 @@ import com.navi.pay.management.common.sendmoney.model.network.TransactionInitiat
import com.navi.pay.management.common.sendmoney.model.view.PayeeEntity
import com.navi.pay.management.moneytransfer.scanpay.util.prepareUpiUri
import com.navi.pay.onboarding.account.add.model.view.AccountType
import com.navi.pay.onboarding.account.common.model.view.AccountEntity
import com.navi.pay.onboarding.account.common.model.view.VpaEntity
import com.navi.pay.onboarding.account.detail.model.view.LinkedAccountEntity
import com.navi.pay.onboarding.account.linked.model.view.LinkedAccountsScreenSource
import com.navi.pay.onboarding.binding.ui.NaviPayOnboardingActivity
@@ -937,3 +939,32 @@ fun toggleNaviPayIntentActivityEnableState(shouldEnable: Boolean) {
finish = true
)
}
fun accountEntityToLinkedAccountEntity(
accountEntity: AccountEntity,
vpaEntityList: List<VpaEntity>
): LinkedAccountEntity {
return LinkedAccountEntity(
accountId = accountEntity.bankAccountUniqueId,
bankCode = accountEntity.bankCode,
bankName = accountEntity.bankName,
name = accountEntity.name,
ifsc = accountEntity.ifsc,
fallbackBankLogoResId = CommonR.drawable.ic_upi_bbps_default_bank_logo,
maskedAccountNumber = accountEntity.maskedAccountNumber.getMaskedAccountNumber(),
originalMaskedAccountNumber = accountEntity.maskedAccountNumber,
accountType = accountEntity.type,
vpaEntityList = vpaEntityList,
isMPinSet = accountEntity.mPinSet,
mPinLength = accountEntity.mPinLength,
otpLength = accountEntity.otpLength,
atmPinLength = accountEntity.atmPinLength,
bankIconImageUrl = accountEntity.bankIconUrl,
isAccountPrimary = accountEntity.isAccountPrimary,
upiLiteInfo = accountEntity.upiLiteInfo,
accountTypeFormatted = getAccountTypeFormattedValue(accountType = accountEntity.type),
creditLineAllowedMCC = accountEntity.creditLineAllowedMCC,
creditLineNotAllowedMCC = accountEntity.creditLineNotAllowedMCC,
updatedAt = accountEntity.updatedAt
)
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2022-2024 by Navi Technologies Limited
* * Copyright © 2022-2025 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -28,6 +28,7 @@ import com.navi.pay.common.usecase.LinkedAccountsUseCase
import com.navi.pay.common.usecase.ValidateVpaUseCase
import com.navi.pay.common.utils.DeviceInfoProvider
import com.navi.pay.common.utils.NaviPayCommonUtils.getHelpCtaData
import com.navi.pay.common.utils.accountEntityToLinkedAccountEntity
import com.navi.pay.common.utils.getMetricInfo
import com.navi.pay.common.viewmodel.NaviPayBaseVM
import com.navi.pay.destinations.MandateDetailScreenOfActiveOrCompletedCategoryDestination
@@ -317,10 +318,7 @@ constructor(
updateShowLoader(true)
linkedAccountsUseCase.execute(screenName = screenName).collect {
getLinkedAccountEntityFromPayerVpa(
payerVpa = mandateEntity.payerVpa,
linkedAccounts = it
)
getLinkedAccountEntityFromPayerVpa(payerVpa = mandateEntity.payerVpa)
updateNextScreenDestinationState(
MandateDetailScreenOfActiveOrCompletedCategoryDestination(
@@ -334,17 +332,18 @@ constructor(
}
}
private fun getLinkedAccountEntityFromPayerVpa(
payerVpa: String,
linkedAccounts: List<LinkedAccountEntity>
) {
selectedBankAccount.update {
linkedAccounts.firstOrNull { linkedAccountEntity ->
linkedAccountEntity.vpaEntityList.any { vpaInfo -> vpaInfo.vpa == payerVpa }
}
}
// can be null for completed mandate as customer could have deleted that account for which
// mandate was completed
private suspend fun getLinkedAccountEntityFromPayerVpa(payerVpa: String) {
val vpaEntity = accountsRepository.getVpaEntityByVpa(payerVpa) ?: return
val accountEntity =
accountsRepository.getAccountEntityByBuid(vpaEntity.bankAccountUniqueId) ?: return
val linkedAccountEntity =
accountEntityToLinkedAccountEntity(
accountEntity = accountEntity,
vpaEntityList = listOf(vpaEntity)
)
selectedBankAccount.update { linkedAccountEntity }
}
private fun getLinkedAccountsInfoAndRedirect(mandateEntity: MandateEntity) {

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2024 by Navi Technologies Limited
* * Copyright © 2024-2025 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -41,4 +41,7 @@ interface VpaDao {
"SELECT * FROM $NAVI_PAY_DATABASE_VPA_TABLE_NAME WHERE bankAccountUniqueId = :buid AND status = :status LIMIT 1"
)
suspend fun getVpaEntityByBuidAndByStatus(buid: String, status: VpaStatus): VpaEntity?
@Query("SELECT * FROM $NAVI_PAY_DATABASE_VPA_TABLE_NAME WHERE vpa = :vpa LIMIT 1")
suspend fun getVpaEntityByVpa(vpa: String): VpaEntity?
}

View File

@@ -1,6 +1,6 @@
/*
*
* * Copyright © 2024 by Navi Technologies Limited
* * Copyright © 2024-2025 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
@@ -131,6 +131,8 @@ constructor(
suspend fun getVpaEntityByBuid(buid: String) = vpaDao.getVpaEntityByBuid(buid = buid)
suspend fun getVpaEntityByVpa(vpa: String) = vpaDao.getVpaEntityByVpa(vpa = vpa)
suspend fun getBuidMappedVpaEntitiesByStatus(
bankAccountUniqueIds: List<String>,
status: VpaStatus