FINERACT-2717: Check all currency usages before allowing currency removal - #6191
Open
Samer-Melhem-FOO wants to merge 3 commits into
Open
FINERACT-2717: Check all currency usages before allowing currency removal#6191Samer-Melhem-FOO wants to merge 3 commits into
Samer-Melhem-FOO wants to merge 3 commits into
Conversation
Contributor
Author
|
Two checks are currently failing here, both unrelated to this PR's change (
Could a maintainer re-run the failed jobs? Thanks! |
adamsaghy
reviewed
Aug 3, 2026
| public CurrencyInUseException(final String currencyCode) { | ||
| super("error.msg.currency.currencyCode.inUse", | ||
| "Cannot remove currency with identifier " + currencyCode + " while it is still in use", currencyCode); | ||
| "Currency cannot be removed because it is already used in existing transactions or accounts.", currencyCode); |
Contributor
There was a problem hiding this comment.
Any reason to change the exception message?
Contributor
Author
There was a problem hiding this comment.
No good reason — it wasn't needed for the actual fix and it drops the currency code from the human-readable message, which is a regression. Reverted to the original message.
…oval The currency-in-use check when removing an organisation currency only looked at loan products, savings products, and charges, so a currency still referenced by actual loans, savings/share accounts, client transactions, account transfers, cashier transactions, or GL journal entries could be silently removed. Broadened the check to cover all of those tables and gave CurrencyInUseException a clearer message. Added CurrencyWritePlatformServiceJpaRepositoryImplTest covering: a currency removed successfully when unused, CurrencyInUseException thrown when still referenced, and the usage check being skipped for currencies that remain allowed.
The message rewording wasn't needed for the fix and dropped the currencyCode from the human-readable text, per review feedback.
Samer-Melhem-FOO
force-pushed
the
port/CBS-589-currency-in-use-deletion-check
branch
from
August 4, 2026 08:26
ea2836b to
2f996ec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
CurrencyWritePlatformServiceJpaRepositoryImpl#updateAllowedCurrenciesallows removing a currency from the organisation's allowed-currency list. The existing in-use check only looked at loan products, savings products, and charges, so a currency still referenced by actual loans, savings/share accounts, client transactions, account transfers, cashier transactions, or GL journal entries could be silently removed.This broadens the check to a
JdbcTemplate-based scan across all relevant tables (m_product_loan,m_savings_product,m_share_product,m_charge,m_loan,m_savings_account,m_share_account,m_client_transaction,m_account_transfer_transaction,m_cashier_transactions,acc_gl_journal_entry) and improvesCurrencyInUseException's message to be clearer to end users.JIRA
https://issues.apache.org/jira/browse/FINERACT-2717
Test plan
./gradlew :fineract-core:compileJava :fineract-provider:compileJavapassesCurrencyWritePlatformServiceJpaRepositoryImplTest(no prior test existed for this class), covering:CurrencyInUseExceptionthrown when the removed currency is still referenced./gradlew :fineract-provider:test --tests "...CurrencyWritePlatformServiceJpaRepositoryImplTest"— all 3 tests pass