TP-40568 | loan repayment options fragment on click crash (#7783)

This commit is contained in:
Anupam Kumar
2023-09-06 18:00:04 +05:30
committed by GitHub
parent 4be6370962
commit 0fd035f46a

View File

@@ -29,6 +29,7 @@ import com.navi.base.model.LineItem
import com.navi.base.utils.BaseUtils
import com.navi.base.utils.isNotNull
import com.navi.base.utils.isNotNullAndNotEmpty
import com.navi.base.utils.isNull
import com.navi.base.utils.orFalse
import com.navi.base.utils.orElse
import com.navi.design.font.FontWeightEnum
@@ -461,8 +462,8 @@ constructor(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(co
setDefaultLabel(this.repaymentOption?.amountInput?.errorMessage?.min)
return false
}
if (isValidCustomAmount.not()) {
val amount = originalText.toDoubleOrNull()
if (isValidCustomAmount.not() || amount.isNull()) {
setError(
this.repaymentOption?.amountInput?.errorMessage?.invalidAmount
?: RepaymentErrorMessage(
@@ -477,15 +478,17 @@ constructor(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(co
)
return false
}
val amount = originalText.toDouble()
if (amount > this.repaymentOption?.amountInput?.maxAmount.orElse(Int.MAX_VALUE)) {
if (amount != null && amount > this.repaymentOption?.amountInput?.maxAmount.orElse(Int.MAX_VALUE)) {
setError(this.repaymentOption?.amountInput?.errorMessage?.max)
return false
} else if (amount < this.repaymentOption?.amountInput?.minAmount.orElse(Int.MIN_VALUE)) {
} else if (amount != null && amount < this.repaymentOption?.amountInput?.minAmount.orElse(
Int.MIN_VALUE
)
) {
setError(this.repaymentOption?.amountInput?.errorMessage?.min)
return false
}
showAmountInWords(amount)
amount?.let { showAmountInWords(it) }
return true
}