Skip to content

FINERACT-2399: Add global config to block transactions on closed/overpaid loans#5349

Open
airajena wants to merge 1 commit intoapache:developfrom
airajena:FINERACT-2399/block-transactions-closed-overpaid-loans
Open

FINERACT-2399: Add global config to block transactions on closed/overpaid loans#5349
airajena wants to merge 1 commit intoapache:developfrom
airajena:FINERACT-2399/block-transactions-closed-overpaid-loans

Conversation

@airajena
Copy link
Contributor

Description

Fixes FINERACT-2399

This PR adds a new global configuration block-transactions-on-closed-overpaid-loans that allows organizations to prevent monetary transactions on loan accounts with closed or overpaid status.

Problem

Currently, Fineract allows monetary transactions (repayments, refunds, charges, etc.) on loans that are in closed or overpaid status. This can cause:

  • Data integrity issues
  • Accounting reconciliation problems
  • Unintended transactions on settled accounts

Solution

Added a global configuration toggle:

  • When disabled (default): Current behavior preserved - transactions allowed on closed/overpaid loans
  • When enabled: Monetary transactions are blocked with appropriate error message

@adamsaghy
Copy link
Contributor

Please dont forget to run ./gradlew spotlessApply spotbugsMain spotbugsTest checkstyleMain checkstyleTest before ALL commits!

@airajena airajena force-pushed the FINERACT-2399/block-transactions-closed-overpaid-loans branch from 00f29ec to 7a00cba Compare January 21, 2026 18:46
@adamsaghy
Copy link
Contributor

adamsaghy commented Jan 23, 2026

Please dont forget to run ./gradlew spotlessApply spotbugsMain spotbugsTest checkstyleMain checkstyleTest before ALL commits!

@airajena
Copy link
Contributor Author

Please dont forget to run ./gradlew spotlessApply spotbugsMain spotbugsTest checkstyleMain checkstyleTest before ALL commits!

Thanks for the reminder! Just a quick clarification: Is it sufficient to run these checks specifically on the modules I've modified (e.g., ./gradlew :integration-tests:spotlessApply ...), or do you require them to be run on the entire project root? Running them on the root seems to trigger issues in unrelated modules.

@adamsaghy
Copy link
Contributor

Please dont forget to run ./gradlew spotlessApply spotbugsMain spotbugsTest checkstyleMain checkstyleTest before ALL commits!

Thanks for the reminder! Just a quick clarification: Is it sufficient to run these checks specifically on the modules I've modified (e.g., ./gradlew :integration-tests:spotlessApply ...), or do you require them to be run on the entire project root? Running them on the root seems to trigger issues in unrelated modules.

Its just easier to run this as i shared and fix all places ;)

@airajena airajena force-pushed the FINERACT-2399/block-transactions-closed-overpaid-loans branch from 7a00cba to b28f4e5 Compare January 24, 2026 06:33
Copy link
Contributor

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Credit Balance Refund txn cannot be blocked! That is for handle overpaid status correctly!

Comment on lines +26 to +28
<sql>
SELECT SETVAL('c_configuration_id_seq', COALESCE(MAX(id), 0)+1, false ) FROM c_configuration;
</sql>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we need this. Are you sure this should be here?

Copy link
Contributor

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add proper testing to ensure correct behavior!

@airajena airajena force-pushed the FINERACT-2399/block-transactions-closed-overpaid-loans branch 2 times, most recently from ebb2fc9 to eac6fa3 Compare February 3, 2026 06:48
@airajena
Copy link
Contributor Author

airajena commented Feb 3, 2026

Please add proper testing to ensure correct behavior!

Done

@airajena airajena force-pushed the FINERACT-2399/block-transactions-closed-overpaid-loans branch 7 times, most recently from 7c54556 to 28ca56a Compare February 9, 2026 20:05
@airajena airajena force-pushed the FINERACT-2399/block-transactions-closed-overpaid-loans branch from 28ca56a to fb8055a Compare February 10, 2026 17:46
@adamsaghy
Copy link
Contributor

    (see https://errorprone.info/bugpattern/NonApiType)
/home/runner/work/fineract/fineract/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanTransactionValidatorImpl.java:671: error: [MissingOverride] validateLoanNotClosedOrOverpaidForTransactions implements method in LoanTransactionValidator; expected @Override
    public void validateLoanNotClosedOrOverpaidForTransactions(Loan loan) {

@airajena airajena force-pushed the FINERACT-2399/block-transactions-closed-overpaid-loans branch from fb8055a to 02a1d21 Compare February 11, 2026 14:17
@airajena
Copy link
Contributor Author

    (see https://errorprone.info/bugpattern/NonApiType)
/home/runner/work/fineract/fineract/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanTransactionValidatorImpl.java:671: error: [MissingOverride] validateLoanNotClosedOrOverpaidForTransactions implements method in LoanTransactionValidator; expected @Override
    public void validateLoanNotClosedOrOverpaidForTransactions(Loan loan) {

fixed

@airajena airajena force-pushed the FINERACT-2399/block-transactions-closed-overpaid-loans branch from 02a1d21 to 326bee7 Compare February 11, 2026 18:00
Copy link
Contributor

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing a great number of transactions here.

Probably an approach which prevents:

  • any new monetary transactions (repayment, refund, reage, etc.)

Reversal of existing transactions are allowed.

@airajena airajena force-pushed the FINERACT-2399/block-transactions-closed-overpaid-loans branch from 326bee7 to 19cfb82 Compare February 21, 2026 11:15
@airajena
Copy link
Contributor Author

You are missing a great number of transactions here.

Probably an approach which prevents:

  • any new monetary transactions (repayment, refund, reage, etc.)

Reversal of existing transactions are allowed.

Thanks for the review. I’ve addressed the requested changes and force-pushed the branch.
Rebased to latest develop and resolved merge conflicts.

@adamsaghy
Copy link
Contributor

@airajena Please rebase again (sorry... we are a high number of PRs nowadays).

@airajena
Copy link
Contributor Author

@airajena Please rebase again (sorry... we are a high number of PRs nowadays).

I understand, no worries, I will check everyday for rebasing and merge conflicts for my PRs, will keep them clean

@airajena airajena force-pushed the FINERACT-2399/block-transactions-closed-overpaid-loans branch from 19cfb82 to e836d79 Compare February 23, 2026 18:41
@airajena airajena force-pushed the FINERACT-2399/block-transactions-closed-overpaid-loans branch 3 times, most recently from b9f857d to 29368d4 Compare February 28, 2026 18:17
@airajena airajena force-pushed the FINERACT-2399/block-transactions-closed-overpaid-loans branch from 29368d4 to bddedee Compare March 3, 2026 19:31
@adamsaghy
Copy link
Contributor

@airajena Please rebase


final Long loanId = command.getLoanId();
Loan loan = this.loanAssembler.assembleFrom(loanId);
loanTransactionValidator.validateLoanNotClosedOrOverpaidForTransactions(loan, LoanTransactionType.INTEREST_PAYMENT_WAIVER);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont need to call multiple times the loanTransactionValidator. Lets do the necessary checks in loanTransactionValidator.validateLoanTransactionInterestPaymentWaiver

changes.put(LoanApiConstants.externalIdParameterName, txnExternalId);
}
Loan loan = this.loanAssembler.assembleFrom(loanId);
loanTransactionValidator.validateLoanNotClosedOrOverpaidForTransactions(loan, repaymentTransactionType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above.

for (final SingleRepaymentCommand singleLoanRepaymentCommand : repaymentCommand) {
if (singleLoanRepaymentCommand != null) {
final Loan loan = this.loanAssembler.assembleFrom(singleLoanRepaymentCommand.getLoanId());
loanTransactionValidator.validateLoanNotClosedOrOverpaidForTransactions(loan, LoanTransactionType.REPAYMENT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above.


Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan);
loanTransactionValidator.validateLoanNotClosedOrOverpaidForTransactions(loan, LoanTransactionType.WAIVE_INTEREST);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above.

changes.put(LoanApiConstants.externalIdParameterName, txnExternalId);

Loan loan = this.loanAssembler.assembleFrom(loanId);
loanTransactionValidator.validateLoanNotClosedOrOverpaidForTransactions(loan, loanTransactionType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above.

Copy link
Contributor

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All transaction types were covered?

@airajena airajena force-pushed the FINERACT-2399/block-transactions-closed-overpaid-loans branch from bddedee to 3826e11 Compare March 13, 2026 18:17
@airajena
Copy link
Contributor Author

All transaction types were covered?

yes — all monetary transaction types are covered now,

@adamsaghy
Copy link
Contributor

@airajena Please rebase this PR.

@airajena airajena force-pushed the FINERACT-2399/block-transactions-closed-overpaid-loans branch from 3826e11 to eb5f136 Compare March 19, 2026 04:50
@airajena
Copy link
Contributor Author

@airajena Please rebase this PR.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants