adamsaghy commented on code in PR #2882:
URL: https://github.com/apache/fineract/pull/2882#discussion_r1086494570
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java:
##########
@@ -6301,26 +6307,31 @@ public Map<String, Object>
undoLastDisbursal(ScheduleGeneratorDTO scheduleGenera
List<Long> existingReversedTransactionIds, Loan loan) {
validateAccountStatus(LoanEvent.LOAN_DISBURSAL_UNDO_LAST);
+
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_DISBURSAL_UNDO_LAST,
getDisbursementDate());
+
+ final Map<String, Object> actualChanges = new LinkedHashMap<>();
+ List<LoanTransaction> loanTransactions =
retrieveListOfTransactionsByType(LoanTransactionType.DISBURSEMENT);
+ loanTransactions.sort(Comparator.comparing(LoanTransaction::getId));
+ final LoanTransaction lastDisbursalTransaction =
loanTransactions.get(loanTransactions.size() - 1);
+ final LocalDate lastTransactionDate =
lastDisbursalTransaction.getTransactionDate();
+
existingTransactionIds.addAll(findExistingTransactionIds());
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
- final Map<String, Object> actualChanges = new LinkedHashMap<>();
-
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_DISBURSAL_UNDO_LAST,
getDisbursementDate());
- LocalDate actualDisbursementDate = null;
- LocalDate lastTransactionDate = getDisbursementDate();
- List<LoanTransaction> loanTransactions =
retrieveListOfTransactionsExcludeAccruals();
+
+ loanTransactions = retrieveListOfTransactionsExcludeAccruals();
Collections.reverse(loanTransactions);
for (final LoanTransaction previousTransaction : loanTransactions) {
if
(lastTransactionDate.isBefore(previousTransaction.getTransactionDate())
&& (previousTransaction.isRepaymentType() ||
previousTransaction.isWaiver() || previousTransaction.isChargePayment())) {
throw new
UndoLastTrancheDisbursementException(previousTransaction.getId());
}
- if (previousTransaction.isDisbursement()) {
- lastTransactionDate = previousTransaction.getTransactionDate();
+ if
(previousTransaction.getId().compareTo(lastDisbursalTransaction.getId()) < 0) {
break;
}
}
- actualDisbursementDate = lastTransactionDate;
- updateLoanToLastDisbursalState(actualDisbursementDate);
+ final LoanDisbursementDetails disbursementDetail =
loan.getDisbursementDetails(actualDisbursementDate,
Review Comment:
What is the value of actualDisbursementDate? Shouldnt it be
lastTransactionDate instead?
--
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]