Skip to content

Conversation

@alberto-art3ch
Copy link
Contributor

@alberto-art3ch alberto-art3ch commented Dec 11, 2025

Description

Let's allow to reprocess Interest Refund txn amount even if no transaction was changed (reverse-replayed) before

FINERACT-2421

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per https://github.com/apache/fineract/#pull-requests
  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
  • Create/update unit or integration tests for verifying the changes made.
  • Follow coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions.
  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
  • Submission is not a "code dump". (Large changes can be made "in repository" via a branch. Ask on the developer mailing list for guidance, if required.)

FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.


loanTransactionHelper.reverseLoanTransaction(loanId, repaymentResponse.getResourceId(),
new PostLoansLoanIdTransactionsTransactionIdRequest().dateFormat(DATETIME_PATTERN)
.transactionDate("25 January 2021").transactionAmount(0.0).locale("en"));
Copy link
Contributor

@ruzeynalov ruzeynalov Dec 11, 2025

Choose a reason for hiding this comment

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

@alberto-art3ch I think transaction date is incorrect here - I assume it should be 20 January 2025

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved, thanks!

final Money newAmount = interestBeforeRefund.minus(progCtx.getSumOfInterestRefundAmount()).minus(interestAfterRefund);
loanTransaction.updateAmount(newAmount.getAmount());
}
final Money interestAfterRefund = interestRefundService.totalInterestByTransactions(this, loan.getId(), targetDate,
Copy link
Contributor

Choose a reason for hiding this comment

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

I am seeing you have removed the condition check for !modifiedTransactions.isEmpty(), is there is any specific usecase for it?

Copy link
Contributor

Choose a reason for hiding this comment

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

@Aman-Mittal This check was preventing any recalculation in case no transactions were changed prior interest refund. While in many situations it can be considered as "optimization", but there are edge cases where it would be crucial to recalculate interest refund amount anyway, so it is safer to remove this optimization and allow the system to recalculate.

@alberto-art3ch alberto-art3ch force-pushed the FINERACT-2389/allow-to-reprocess-interest-refund-txn-even-if-no-transaction-was-changed branch 2 times, most recently from 64c4403 to 5a4160f Compare December 18, 2025 03:07
@adamsaghy
Copy link
Contributor

Please change PR and commit to use: https://issues.apache.org/jira/browse/FINERACT-2421

@ruzeynalov ruzeynalov deleted the FINERACT-2389/allow-to-reprocess-interest-refund-txn-even-if-no-transaction-was-changed branch December 18, 2025 16:07
@ruzeynalov ruzeynalov force-pushed the FINERACT-2389/allow-to-reprocess-interest-refund-txn-even-if-no-transaction-was-changed branch from 556694f to e616b69 Compare December 18, 2025 16:41
@alberto-art3ch alberto-art3ch force-pushed the FINERACT-2389/allow-to-reprocess-interest-refund-txn-even-if-no-transaction-was-changed branch 2 times, most recently from 8b917f0 to 1a25b9d Compare December 19, 2025 04:14
@alberto-art3ch alberto-art3ch changed the title FINERACT-2389: Reprocess Interest Refund txn amount if no txn was changed FINERACT-2421: Reprocess Interest Refund txn amount if no txn was changed Dec 19, 2025
@alberto-art3ch
Copy link
Contributor Author

Please change PR and commit to use: https://issues.apache.org/jira/browse/FINERACT-2421

Done!

@adamsaghy
Copy link
Contributor

> Task :fineract-rates:spotbugsMain
/home/runner/work/fineract/fineract/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:40: error: [WildcardImport] Wildcard imports, static or otherwise, should not be used
import java.util.*;
^
    (see https://google.github.io/styleguide/javaguide.html?cl=head#s3.3.1-wildcard-imports)

> Task :fineract-progressive-loan:compileJava
1 error
10 warnings

@alberto-art3ch alberto-art3ch force-pushed the FINERACT-2389/allow-to-reprocess-interest-refund-txn-even-if-no-transaction-was-changed branch from 1a25b9d to 221a2db Compare December 19, 2025 13:43
@alberto-art3ch alberto-art3ch force-pushed the FINERACT-2389/allow-to-reprocess-interest-refund-txn-even-if-no-transaction-was-changed branch from 221a2db to f001eda Compare December 19, 2025 13:44
@alberto-art3ch
Copy link
Contributor Author

import java.util.*;

Done! Thanks

@alberto-art3ch alberto-art3ch force-pushed the FINERACT-2389/allow-to-reprocess-interest-refund-txn-even-if-no-transaction-was-changed branch from f001eda to b9d2adb Compare December 19, 2025 20:00
Comment on lines +39 to +42
final MonetaryCurrency currency = loanTransaction.getLoan().getCurrency();
return (oldTransaction.getId() != null && oldTransaction.getTypeOf().equals(loanTransaction.getTypeOf()) //
&& oldTransaction.getTransactionDate().equals(loanTransaction.getTransactionDate()) //
&& (oldTransaction.getAmount(currency).compareTo(loanTransaction.getAmount(currency)) == 0));
Copy link
Contributor

Choose a reason for hiding this comment

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

A simple getId() is enought. I see no reason for the rest of the checks...

transaction(2.88, "Interest Refund", "22 January 2021"), //
transaction(4.66, "Accrual", "22 January 2021") //
);
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

why to comment out?

| 4 | 30 | 01 May 2024 | 01 February 2024 | 319.66 | 169.66 | 1.83 | 0.0 | 0.0 | 171.49 | 171.49 | 171.49 | 0.0 | 0.0 |
| 5 | 31 | 01 June 2024 | 01 February 2024 | 148.17 | 171.49 | 0.0 | 0.0 | 0.0 | 171.49 | 171.49 | 171.49 | 0.0 | 0.0 |
| 6 | 30 | 01 July 2024 | | 0.0 | 148.17 | 2.77 | 0.0 | 0.0 | 150.94 | 80.6 | 80.6 | 0.0 | 70.34 |
| 6 | 30 | 01 July 2024 | | 0.0 | 148.17 | 2.77 | 0.0 | 0.0 | 150.94 | 80.59 | 80.59 | 0.0 | 70.35 |
Copy link
Contributor

Choose a reason for hiding this comment

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

why is the change?

transaction(1.44, "Interest Refund", "22 January 2021"), //
transaction(400.0, "Payout Refund", "26 January 2021"), //
transaction(2.58, "Interest Refund", "26 January 2021") //
transaction(2.57, "Interest Refund", "26 January 2021") //
Copy link
Contributor

Choose a reason for hiding this comment

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

why the change?

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.

4 participants