TP-60712 | isLiteAccountEligible logic fix (#10120)
This commit is contained in:
@@ -896,7 +896,8 @@ constructor(
|
||||
// If transaction via Upi Lite
|
||||
return if (
|
||||
source.isTransactionViaUpiLite &&
|
||||
shouldUseLiteAccount(
|
||||
linkedAccounts.size > 0 &&
|
||||
isLiteAccountEligible(
|
||||
linkedAccounts = linkedAccounts,
|
||||
accountsEligibility = accountsEligibility
|
||||
)
|
||||
@@ -992,11 +993,13 @@ constructor(
|
||||
): LinkedAccountEntity {
|
||||
|
||||
// First preference is lite account
|
||||
val linkedAccountsSize = linkedAccounts.size
|
||||
if (
|
||||
shouldUseLiteAccount(
|
||||
linkedAccounts = linkedAccounts,
|
||||
accountsEligibility = accountsEligibility
|
||||
)
|
||||
linkedAccountsSize > 0 &&
|
||||
isLiteAccountEligible(
|
||||
linkedAccounts = linkedAccounts,
|
||||
accountsEligibility = accountsEligibility
|
||||
)
|
||||
) {
|
||||
return linkedAccounts.first()
|
||||
}
|
||||
@@ -1012,16 +1015,6 @@ constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun shouldUseLiteAccount(
|
||||
linkedAccounts: List<LinkedAccountEntity>,
|
||||
accountsEligibility: Map<String, LinkedAccountEntityState>
|
||||
): Boolean {
|
||||
return _isActiveLiteAccountPresent.value &&
|
||||
linkedAccounts.isNotEmpty() &&
|
||||
(_liteAccountBalance.value.toDoubleOrNull() ?: 0.0) > 0.0 &&
|
||||
accountsEligibility[linkedAccounts[0].accountId]?.isAccountEligible == true
|
||||
}
|
||||
|
||||
private fun isAccountEligible(
|
||||
accountId: String,
|
||||
accountsEligibility: Map<String, LinkedAccountEntityState>
|
||||
@@ -1048,22 +1041,29 @@ constructor(
|
||||
accountsEligibility: Map<String, LinkedAccountEntityState>
|
||||
): LinkedAccountEntity {
|
||||
val linkedAccountsSize = linkedAccounts.size
|
||||
|
||||
fun isLiteAccountEligible(): Boolean {
|
||||
return isActiveLiteAccountPresent.value &&
|
||||
linkedAccountsSize > 0 &&
|
||||
(liteAccountBalance.value.toDoubleOrNull() ?: 0.0) >=
|
||||
(paymentAmount.value.toDoubleOrNull() ?: 0.0) &&
|
||||
accountsEligibility[linkedAccounts[0].accountId]?.isAccountEligible == true
|
||||
}
|
||||
|
||||
return if (isLiteAccountEligible()) {
|
||||
return if (
|
||||
linkedAccountsSize > 0 &&
|
||||
isLiteAccountEligible(
|
||||
linkedAccounts = linkedAccounts,
|
||||
accountsEligibility = accountsEligibility
|
||||
)
|
||||
) {
|
||||
linkedAccounts.first()
|
||||
} else {
|
||||
linkedAccounts.getOrElse(1) { linkedAccounts.first() }
|
||||
}
|
||||
}
|
||||
|
||||
private fun isLiteAccountEligible(
|
||||
linkedAccounts: List<LinkedAccountEntity>,
|
||||
accountsEligibility: Map<String, LinkedAccountEntityState>
|
||||
): Boolean {
|
||||
return isActiveLiteAccountPresent.value &&
|
||||
(liteAccountBalance.value.toDoubleOrNull() ?: 0.0) >=
|
||||
(paymentAmount.value.toDoubleOrNull() ?: 0.0) &&
|
||||
accountsEligibility[linkedAccounts[0].accountId]?.isAccountEligible == true
|
||||
}
|
||||
|
||||
private fun checkIsInternetAvailableOrShowError(): Boolean {
|
||||
if (!naviPayNetworkConnectivity.isInternetConnected()) {
|
||||
notifyError(getNoInternetErrorConfig())
|
||||
|
||||
Reference in New Issue
Block a user