diff --git a/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionViewModel.kt b/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionViewModel.kt index 775eec5f37..6574d4d36e 100644 --- a/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionViewModel.kt +++ b/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionViewModel.kt @@ -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 { @@ -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