From d9473c89ad252092eba16a95d66a25cb51eba4da Mon Sep 17 00:00:00 2001 From: Balrambhai Sharma Date: Mon, 28 Apr 2025 18:47:47 +0530 Subject: [PATCH] NTP-44548 | Regression Bug Fix (#15949) --- .../ledger/TransactionLedgerHeader.kt | 3 ++- .../ui/transaction/ledger/TxnLedgerScreen.kt | 5 +++- .../sendmoney/viewmodel/SendMoneyViewModel.kt | 24 +++++++++++++++---- .../viewmodel/PayToContactsViewModel.kt | 16 +++++++++++-- .../viewmodel/OrderDetailsViewModel.kt | 3 +++ .../com/navi/pay/utils/NaviPayConstants.kt | 4 ++++ 6 files changed, 46 insertions(+), 9 deletions(-) diff --git a/android/navi-pay/src/main/kotlin/com/navi/pay/management/common/sendmoney/ui/transaction/ledger/TransactionLedgerHeader.kt b/android/navi-pay/src/main/kotlin/com/navi/pay/management/common/sendmoney/ui/transaction/ledger/TransactionLedgerHeader.kt index a17385d6f1..2c35185940 100644 --- a/android/navi-pay/src/main/kotlin/com/navi/pay/management/common/sendmoney/ui/transaction/ledger/TransactionLedgerHeader.kt +++ b/android/navi-pay/src/main/kotlin/com/navi/pay/management/common/sendmoney/ui/transaction/ledger/TransactionLedgerHeader.kt @@ -170,6 +170,7 @@ private fun VpaAddressRow( Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) { if (vpaIcon.isNotNullAndNotEmpty()) { VpaIconBadge(iconUrl = vpaIcon, isBankTransfer = isBankTransfer) + Spacer(modifier = Modifier.width(4.dp)) } if (vpaAddress.isNotNullAndNotEmpty()) { @@ -198,7 +199,7 @@ private fun VpaAddressText(text: String, color: Color) { fontFamily = naviFontFamily, fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_REGULAR), color = color, - modifier = Modifier.padding(start = 4.dp), + modifier = Modifier, maxLines = 1, overflow = TextOverflow.Ellipsis, ) diff --git a/android/navi-pay/src/main/kotlin/com/navi/pay/management/common/sendmoney/ui/transaction/ledger/TxnLedgerScreen.kt b/android/navi-pay/src/main/kotlin/com/navi/pay/management/common/sendmoney/ui/transaction/ledger/TxnLedgerScreen.kt index 395c443349..63e9f09b04 100644 --- a/android/navi-pay/src/main/kotlin/com/navi/pay/management/common/sendmoney/ui/transaction/ledger/TxnLedgerScreen.kt +++ b/android/navi-pay/src/main/kotlin/com/navi/pay/management/common/sendmoney/ui/transaction/ledger/TxnLedgerScreen.kt @@ -610,7 +610,10 @@ fun EmptyLedgerScreen( @Composable fun LoaderState() { Column(modifier = Modifier.fillMaxWidth()) { - repeat(2) { ShimmerRow(isStartAligned = it % 2 == 0) } + repeat(4) { + ShimmerRow(isStartAligned = it % 2 == 0) + Spacer(modifier = Modifier.height(16.dp)) + } } } diff --git a/android/navi-pay/src/main/kotlin/com/navi/pay/management/common/sendmoney/viewmodel/SendMoneyViewModel.kt b/android/navi-pay/src/main/kotlin/com/navi/pay/management/common/sendmoney/viewmodel/SendMoneyViewModel.kt index 8a8f43feef..d7843aeeb1 100644 --- a/android/navi-pay/src/main/kotlin/com/navi/pay/management/common/sendmoney/viewmodel/SendMoneyViewModel.kt +++ b/android/navi-pay/src/main/kotlin/com/navi/pay/management/common/sendmoney/viewmodel/SendMoneyViewModel.kt @@ -193,6 +193,7 @@ import com.navi.pay.utils.DEFAULT_BANK_UP_TIME_SUCCESS_RATE import com.navi.pay.utils.DEFAULT_CONFIG import com.navi.pay.utils.DEFAULT_UPI_PURPOSE import com.navi.pay.utils.DOT_PNG +import com.navi.pay.utils.ERR_FAILED_TO_FETCH_EXTERNAL_CUSTOMER_ID import com.navi.pay.utils.INTENT_OR_SCAN_PAY_TRANSACTION_ERROR import com.navi.pay.utils.INVALID_VPA import com.navi.pay.utils.KEY_IS_FIRST_TRANSACTION_SUCCESSFUL @@ -876,6 +877,8 @@ constructor( } private suspend fun checkIfTransactionLedgerIsAvailable(): Boolean { + val isValidExternalId = + payeeEntity.value.equals(ERR_FAILED_TO_FETCH_EXTERNAL_CUSTOMER_ID).not() val experimentResult = litmusExperimentsUseCase.execute( experimentName = LITMUS_EXPERIMENT_NAVIPAY_TRANSACTION_LEDGER @@ -891,7 +894,7 @@ constructor( PreferenceManager.getStringPreference(USER_EXTERNAL_ID).orEmpty() ) - return isMccCompatible && isExperimentEnabled && isNotSelfTransaction + return isMccCompatible && isExperimentEnabled && isNotSelfTransaction && isValidExternalId } private fun handleLedgerAvailableState() { @@ -1387,8 +1390,11 @@ constructor( } private fun updateScreenState(screenState: SendMoneyScreenState) { - // Remove loader On Pay button for Main Screen State - if (screenState is SendMoneyScreenState.MainScreen) { + // Remove loader On Pay button for Main Screen State or Ledger screen state + if ( + screenState is SendMoneyScreenState.MainScreen || + screenState is SendMoneyScreenState.TransactionLedgerScreen + ) { updateShowPayButtonLoader(false) } _screenState.update { screenState } @@ -2260,7 +2266,11 @@ constructor( if (pspEvaluationResult.isOnboardingTriggered) { updateTriggerDismissBottomSheet() } - updateScreenState(screenState = SendMoneyScreenState.MainScreen) + updateScreenState( + screenState = + if (transactionLedgerEnabled()) SendMoneyScreenState.TransactionLedgerScreen + else SendMoneyScreenState.MainScreen + ) notifyError(getNoInternetErrorConfig()) return } @@ -2887,7 +2897,11 @@ constructor( payeeVpa = payeeEntity.value.vpa, sendMoneyRegexValidationFailureType = sendMoneyRegexValidationFailureType, ) - updateScreenState(screenState = SendMoneyScreenState.MainScreen) + updateScreenState( + screenState = + if (transactionLedgerEnabled()) SendMoneyScreenState.TransactionLedgerScreen + else SendMoneyScreenState.MainScreen + ) when (sendMoneyRegexValidationFailureType) { SendMoneyRegexValidationFailureType.INVALID_UPI_REQUEST_ID -> { notifyError( diff --git a/android/navi-pay/src/main/kotlin/com/navi/pay/management/paytocontacts/viewmodel/PayToContactsViewModel.kt b/android/navi-pay/src/main/kotlin/com/navi/pay/management/paytocontacts/viewmodel/PayToContactsViewModel.kt index 729a9f004c..9ae5a9b756 100644 --- a/android/navi-pay/src/main/kotlin/com/navi/pay/management/paytocontacts/viewmodel/PayToContactsViewModel.kt +++ b/android/navi-pay/src/main/kotlin/com/navi/pay/management/paytocontacts/viewmodel/PayToContactsViewModel.kt @@ -11,6 +11,7 @@ import androidx.lifecycle.viewModelScope import com.google.gson.reflect.TypeToken import com.navi.base.model.CtaData import com.navi.base.utils.ResourceProvider +import com.navi.base.utils.isNotNullAndNotEmpty import com.navi.common.constants.EMPTY import com.navi.common.extensions.or import com.navi.common.extensions.removeSpaces @@ -50,6 +51,7 @@ import com.navi.pay.utils.NAVI_PAY_SEARCH_QUERY_API_DELAY import com.navi.pay.utils.NAVI_PAY_WIDGET_CLICKED_KEY import com.navi.pay.utils.NOT_LINKED_TO_UPI import com.navi.pay.utils.PHONE_NUMBER_LENGTH +import com.navi.pay.utils.REMOVE_WHITESPACE_REGEX import com.navi.pay.utils.isValidPhoneNumberLength import com.navi.pay.utils.isValidSearchQuery import com.ramcosta.composedestinations.spec.Direction @@ -444,9 +446,19 @@ constructor( screenName = screenName, ) + // Temporary fix for mobile number val payeeVpaToDisplay = - getNormalisedPhoneNumber(frequentOrderEntity.payeeInfo?.mobNo) - .or(frequentOrderEntity.orderDescription) + frequentOrderEntity.payeeInfo?.mobNo?.let { mobNo -> + val mobNoWithoutSpaces = mobNo.replace(REMOVE_WHITESPACE_REGEX, EMPTY) + if ( + mobNo.isNotNullAndNotEmpty() && + mobNoWithoutSpaces.count { it.isDigit() } >= PHONE_NUMBER_LENGTH + ) { + getNormalisedPhoneNumber(mobNoWithoutSpaces) + } else { + frequentOrderEntity.orderDescription + } + } ?: frequentOrderEntity.orderDescription if (response.isSuccessWithData()) { handleAPIResponseSuccessAndUpdateNextDestination( diff --git a/android/navi-pay/src/main/kotlin/com/navi/pay/tstore/details/viewmodel/OrderDetailsViewModel.kt b/android/navi-pay/src/main/kotlin/com/navi/pay/tstore/details/viewmodel/OrderDetailsViewModel.kt index f8e3f072b9..cbcfa6966d 100644 --- a/android/navi-pay/src/main/kotlin/com/navi/pay/tstore/details/viewmodel/OrderDetailsViewModel.kt +++ b/android/navi-pay/src/main/kotlin/com/navi/pay/tstore/details/viewmodel/OrderDetailsViewModel.kt @@ -85,6 +85,7 @@ import com.navi.pay.management.common.sendmoney.model.view.PayeeEntity import com.navi.pay.management.common.sendmoney.model.view.PayeeTransactionHistoryEntity import com.navi.pay.management.common.sendmoney.model.view.SendMoneyScreenSource import com.navi.pay.management.common.sendmoney.model.view.UpiTransactionType +import com.navi.pay.management.common.sendmoney.model.view.UpiTransactionType.Companion.getUpiTransactionType import com.navi.pay.management.common.transaction.model.network.TransactionInstrumentType import com.navi.pay.management.common.transaction.model.view.TransactionCategoryTags import com.navi.pay.management.common.transaction.model.view.TransactionPaymentModeTags @@ -1085,6 +1086,8 @@ constructor( naviPayActivityDataProvider.setSendMoneyScreenData( payeeEntity = payeeEntity, + transactionType = + getUpiTransactionType(naviPayTransactionDetailsMetadata?.txnType.orEmpty()), sendMoneyScreenSource = sendMoneyScreenSource, ) updateNavigationToNextScreen(SendMoneyScreenDestination()) diff --git a/android/navi-pay/src/main/kotlin/com/navi/pay/utils/NaviPayConstants.kt b/android/navi-pay/src/main/kotlin/com/navi/pay/utils/NaviPayConstants.kt index abf98eaead..3bbf7805ed 100644 --- a/android/navi-pay/src/main/kotlin/com/navi/pay/utils/NaviPayConstants.kt +++ b/android/navi-pay/src/main/kotlin/com/navi/pay/utils/NaviPayConstants.kt @@ -493,6 +493,7 @@ val UPI_ID_VALIDATION_REGEX = Regex(pattern = ".+@.{2,}") val SEARCH_QUERY_VALIDATION_REGEX = Regex("^\\+?\\d+\$") val PAYMENT_AMOUNT_VALIDATION_REGEX = Regex(pattern = "^[1-9]\\d*\\.\\d{2}\$") val UPI_REQUEST_ID_VALIDATION_REGEX = Regex(pattern = "^[a-zA-Z0-9]{35}\$") +val REMOVE_WHITESPACE_REGEX = Regex(pattern = "\\s") const val HEX_FORMAT = "%02x" const val SHA_256 = "SHA-256" @@ -559,3 +560,6 @@ const val OF = "of" const val PERCENTAGE = "%" const val MULTIPLY = "x" const val GOLD_ROUND_OFF_AMOUNT = "Round-off amount" + +// External id error +const val ERR_FAILED_TO_FETCH_EXTERNAL_CUSTOMER_ID = "ERR_FAILED_TO_FETCH_EXTERNAL_CUSTOMER_ID"