You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fineract.apache.org by "somasorosdpc (via GitHub)" <gi...@apache.org> on 2026/09/16 12:06:28 UTC
[PR] FINERACT-2455: WC - Undo disbursal reverses the discount fee and amortization journal entries [fineract]
somasorosdpc opened a new pull request, #6457:
URL: https://github.com/apache/fineract/pull/6457
## Description
Describe the changes made and why they were made. (Ignore if these details are present on the associated Apache Fineract JIRA ticket.)
## Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
- [ ] Write the commit message as per [our guidelines](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#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](https://fineract.apache.org/docs/current/#_testing) for verifying the changes made.
- [ ] Follow our [coding conventions](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
- [ ] [This PR must not be a "code dump"](https://cwiki.apache.org/confluence/display/FINERACT/Pull+Request+Size+Limit). Large changes can be made in a branch, with assistance. Ask for help on the [developer mailing list](https://fineract.apache.org/#contribute).
- [ ] If merging this PR resolves a JIRA issue, I will mark that issue as resolved and set "Fix Version/s" appropriately.
- [ ] I followed the [AI Policy](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#ai-policy).
Your assigned reviewer(s) will follow our [guidelines for code reviews](https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2455: WC - Undo disbursal reverses the discount fee and amortization journal entries [fineract]
Posted by "somasorosdpc (via GitHub)" <gi...@apache.org>.
somasorosdpc commented on code in PR #6457:
URL: https://github.com/apache/fineract/pull/6457#discussion_r4071300782
##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanWritePlatformServiceImpl.java:
##########
@@ -1307,18 +1307,19 @@ private WorkingCapitalLoanTransaction reverseDisbursementTransactionAndResetBala
final List<WorkingCapitalLoanTransaction> accrualsToReverse = transactions.stream()
.filter(t -> t.getTypeOf() == LoanTransactionType.ACCRUAL && !t.isReversed()).toList();
- transactions.forEach(this::markReversed);
-
- if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) {
- accountingProcessor.postReversalJournalEntries(loan, txn);
- }
+ transactions.stream().filter(t -> !t.isReversed()) // reverse only unreversed transaction
+ .peek(this::markReversed) // mark them reversed
+ .forEach(t -> { // post journal entries if accounting is enabled
+ if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) {
Review Comment:
I think accounting processor should handle only the specific accounting "type". The proper solution should be a WorkingCapitalAccountingDelegatorService ( or something like that ) what handles the lookup of accounting processors and decides which Accounting processor to use according the loan(product) configuration, and call processor accordingly. What do you think @adamsaghy ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2455: WC - Undo disbursal reverses the discount fee and amortization journal entries [fineract]
Posted by "somasorosdpc (via GitHub)" <gi...@apache.org>.
somasorosdpc commented on code in PR #6457:
URL: https://github.com/apache/fineract/pull/6457#discussion_r4071300782
##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanWritePlatformServiceImpl.java:
##########
@@ -1307,18 +1307,19 @@ private WorkingCapitalLoanTransaction reverseDisbursementTransactionAndResetBala
final List<WorkingCapitalLoanTransaction> accrualsToReverse = transactions.stream()
.filter(t -> t.getTypeOf() == LoanTransactionType.ACCRUAL && !t.isReversed()).toList();
- transactions.forEach(this::markReversed);
-
- if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) {
- accountingProcessor.postReversalJournalEntries(loan, txn);
- }
+ transactions.stream().filter(t -> !t.isReversed()) // reverse only unreversed transaction
+ .peek(this::markReversed) // mark them reversed
+ .forEach(t -> { // post journal entries if accounting is enabled
+ if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) {
Review Comment:
I think accounting processor should handle only the specific accounting "type". The proper solution should be a WorkingCapitalAccountingDelegatorService ( or something like that ) what handles the lookup of accounting processors and decides which Accounting processor to use according the loan(product) configuration, and call processor accordingly. What do you think @adamsaghy ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2455: WC - Undo disbursal reverses the discount fee and amortization journal entries [fineract]
Posted by "somasorosdpc (via GitHub)" <gi...@apache.org>.
somasorosdpc commented on code in PR #6457:
URL: https://github.com/apache/fineract/pull/6457#discussion_r4071248123
##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanWritePlatformServiceImpl.java:
##########
@@ -1307,18 +1307,19 @@ private WorkingCapitalLoanTransaction reverseDisbursementTransactionAndResetBala
final List<WorkingCapitalLoanTransaction> accrualsToReverse = transactions.stream()
.filter(t -> t.getTypeOf() == LoanTransactionType.ACCRUAL && !t.isReversed()).toList();
- transactions.forEach(this::markReversed);
-
- if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) {
- accountingProcessor.postReversalJournalEntries(loan, txn);
- }
+ transactions.stream().filter(t -> !t.isReversed()) // reverse only unreversed transaction
+ .peek(this::markReversed) // mark them reversed
+ .forEach(t -> { // post journal entries if accounting is enabled
+ if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) {
+ accountingProcessor.postReversalJournalEntries(loan, t);
+ }
+ });
this.transactionRepository.saveAll(transactions);
this.transactionRepository.flush();
// Reverse the journal entries of any charge accrual so the recognized income/receivable is backed out with the
// disbursement; marking the transaction reversed alone would leave the GL postings in place.
- accrualsToReverse.forEach(accrual -> accountingProcessor.postReversalJournalEntries(loan, accrual));
Review Comment:
the original solution above
```transactions.forEach(this::markReversed)```
reversed all the transactions. Now That step also reverses journal entries if there are.
We don't want to handle here. The solution is common enough, to not break if there is no journal entry handling implemented for a transaction type.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2455: WC - Undo disbursal reverses the discount fee and amortization journal entries [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #6457:
URL: https://github.com/apache/fineract/pull/6457#discussion_r4064493028
##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanWritePlatformServiceImpl.java:
##########
@@ -1307,18 +1307,19 @@ private WorkingCapitalLoanTransaction reverseDisbursementTransactionAndResetBala
final List<WorkingCapitalLoanTransaction> accrualsToReverse = transactions.stream()
.filter(t -> t.getTypeOf() == LoanTransactionType.ACCRUAL && !t.isReversed()).toList();
- transactions.forEach(this::markReversed);
-
- if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) {
- accountingProcessor.postReversalJournalEntries(loan, txn);
- }
+ transactions.stream().filter(t -> !t.isReversed()) // reverse only unreversed transaction
+ .peek(this::markReversed) // mark them reversed
+ .forEach(t -> { // post journal entries if accounting is enabled
+ if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) {
+ accountingProcessor.postReversalJournalEntries(loan, t);
+ }
+ });
this.transactionRepository.saveAll(transactions);
this.transactionRepository.flush();
// Reverse the journal entries of any charge accrual so the recognized income/receivable is backed out with the
// disbursement; marking the transaction reversed alone would leave the GL postings in place.
- accrualsToReverse.forEach(accrual -> accountingProcessor.postReversalJournalEntries(loan, accrual));
Review Comment:
Any reason not to do it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2455: WC - Undo disbursal reverses the discount fee and amortization journal entries [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy merged PR #6457:
URL: https://github.com/apache/fineract/pull/6457
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2455: WC - Undo disbursal reverses the discount fee and amortization journal entries [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #6457:
URL: https://github.com/apache/fineract/pull/6457#discussion_r4064486181
##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanWritePlatformServiceImpl.java:
##########
@@ -1307,18 +1307,19 @@ private WorkingCapitalLoanTransaction reverseDisbursementTransactionAndResetBala
final List<WorkingCapitalLoanTransaction> accrualsToReverse = transactions.stream()
.filter(t -> t.getTypeOf() == LoanTransactionType.ACCRUAL && !t.isReversed()).toList();
- transactions.forEach(this::markReversed);
-
- if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) {
- accountingProcessor.postReversalJournalEntries(loan, txn);
- }
+ transactions.stream().filter(t -> !t.isReversed()) // reverse only unreversed transaction
+ .peek(this::markReversed) // mark them reversed
+ .forEach(t -> { // post journal entries if accounting is enabled
+ if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) {
Review Comment:
Lets swap this:
`accountingProcessor` should check whether accounting is enabled or not... we should always call it but internally decides whether to do anything or NO-OP
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2455: WC - Undo disbursal reverses the discount fee and amortization journal entries [fineract]
Posted by "somasorosdpc (via GitHub)" <gi...@apache.org>.
somasorosdpc commented on code in PR #6457:
URL: https://github.com/apache/fineract/pull/6457#discussion_r4074128306
##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanWritePlatformServiceImpl.java:
##########
@@ -1307,18 +1307,19 @@ private WorkingCapitalLoanTransaction reverseDisbursementTransactionAndResetBala
final List<WorkingCapitalLoanTransaction> accrualsToReverse = transactions.stream()
.filter(t -> t.getTypeOf() == LoanTransactionType.ACCRUAL && !t.isReversed()).toList();
- transactions.forEach(this::markReversed);
-
- if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) {
- accountingProcessor.postReversalJournalEntries(loan, txn);
- }
+ transactions.stream().filter(t -> !t.isReversed()) // reverse only unreversed transaction
+ .peek(this::markReversed) // mark them reversed
+ .forEach(t -> { // post journal entries if accounting is enabled
+ if (loan.getLoanProduct().getAccountingRule().isAccrualWithDeferredRevenueAmortization()) {
Review Comment:
I made the refactor, that pulls the check into the `AccrualWithDeferredRevenueAmortizationAccountingProcessorForWorkingCapitalLoan` implementation. All the public API checks at the first step if it is enabled or not.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org