adamsaghy commented on code in PR #4443:
URL: https://github.com/apache/fineract/pull/4443#discussion_r1987702927
##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java:
##########
@@ -2453,14 +2463,16 @@ public void addLoanTransaction(final LoanTransaction
loanTransaction) {
}
public LocalDate getLastUserTransactionDate() {
- LocalDate currentTransactionDate = getDisbursementDate();
- for (final LoanTransaction previousTransaction :
this.loanTransactions) {
- if (!(previousTransaction.isReversed() ||
previousTransaction.isAccrualRelated() || previousTransaction.isIncomePosting())
- && DateUtils.isBefore(currentTransactionDate,
previousTransaction.getTransactionDate())) {
- currentTransactionDate =
previousTransaction.getTransactionDate();
- }
- }
- return currentTransactionDate;
+ return this.loanTransactions.stream()
+ .filter(this::isValidTransaction)
+ .map(LoanTransaction::getTransactionDate)
+ .filter(date -> DateUtils.isBefore(getDisbursementDate(),
date))
+ .max(LocalDate::compareTo)
+ .orElse(getDisbursementDate());
+ }
+
+ private boolean isValidTransaction(LoanTransaction transaction) {
Review Comment:
I dont really like the name of this method... `isValidTransaction` is
misleading... income posting and accrual related transactions are all "valid"
transactions, however here they should not be considered... Maybe you want to
use something that more descriptive about the filtering, like: "filter reverse
and accrual related transactions" or something like that...
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]