Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Fix for : EditTransactionViewModel.kt:859:24: This condition is too c…
Browse files Browse the repository at this point in the history
…omplex (4). Defined complexity threshold for conditions is set to '4' [ComplexCondition]
  • Loading branch information
shamim-emon committed Sep 14, 2024
1 parent 473f87a commit 5104802
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -856,9 +856,10 @@ class EditTransactionViewModel @Inject constructor(
}

val exRate = exchangeRate
?: if (
customExchangeRateState.showCard && toAccCurrencyCode == customExchangeRateState.toCurrencyCode &&
fromAccCurrencyCode == customExchangeRateState.fromCurrencyCode && !resetRate
?: if (isCustomExchangeRateCurrencyCodeMatchingWithSourceAndDestinationAccountCurrencyCode(
toAccCurrencyCode = toAccCurrencyCode,
fromAccCurrencyCode = fromAccCurrencyCode
) && !resetRate
) {
customExchangeRateState.exchangeRate
} else {
Expand Down Expand Up @@ -887,6 +888,15 @@ class EditTransactionViewModel @Inject constructor(
}
}

private fun isCustomExchangeRateCurrencyCodeMatchingWithSourceAndDestinationAccountCurrencyCode(
toAccCurrencyCode: String,
fromAccCurrencyCode: String
): Boolean {
return customExchangeRateState.showCard &&
toAccCurrencyCode == customExchangeRateState.toCurrencyCode &&
fromAccCurrencyCode == customExchangeRateState.fromCurrencyCode
}

private fun saveIfEditMode(closeScreen: Boolean = false) {
if (editMode) {
hasChanges = true
Expand Down

0 comments on commit 5104802

Please sign in to comment.