josehernandezfintecheandomx commented on code in PR #2739:
URL: https://github.com/apache/fineract/pull/2739#discussion_r1025228167
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -152,61 +149,9 @@ public LoanScheduleDelinquencyData
calculateDelinquencyData(LoanScheduleDelinque
if (loan == null) {
loan =
this.loanRepository.findOneWithNotFoundDetection(loanScheduleDelinquencyData.getLoanId());
}
-
- final Integer graceOnArrearAgeing =
loan.getLoanProduct().getLoanProductRelatedDetail().getGraceOnArrearsAgeing();
- final LocalDate overdueSinceDate = getOverdueSinceDate(loan,
businessDate, graceOnArrearAgeing);
- final Long overdueDays = calculateOverdueDays(businessDate,
overdueSinceDate);
- return new LoanScheduleDelinquencyData(loan.getId(), overdueSinceDate,
overdueDays, loan);
- }
-
- @Override
- public LocalDate getOverdueSinceDate(final Loan loan, final LocalDate
businessDate, final Integer graceOnArrearAgeing) {
- LoanRepaymentScheduleInstallment loanRepaymentSchedule = null;
- for (LoanRepaymentScheduleInstallment installment :
loan.getRepaymentScheduleInstallments()) {
- if (installment.getDueDate().isBefore(businessDate) &&
installment.isNotFullyPaidOff()) {
- loanRepaymentSchedule = installment;
- break;
- }
- }
-
- LocalDate overdueSinceDate = null;
- final MonetaryCurrency loanCurrency = loan.getCurrency();
- final List<LoanTransaction> loanTransactions =
loan.retrieveListOfTransactionsByType(LoanTransactionType.CHARGEBACK);
- if (loanRepaymentSchedule != null) {
- // Default Due date
- overdueSinceDate = loanRepaymentSchedule.getDueDate();
- }
-
- // If there is some Loan Transaction Chargeback
- for (LoanTransaction loanTransaction : loanTransactions) {
- if
(loanTransaction.getLoanTransactionToRepaymentScheduleMappings().iterator().hasNext())
{
- final LoanTransactionToRepaymentScheduleMapping
transactionMapping = loanTransaction
-
.getLoanTransactionToRepaymentScheduleMappings().iterator().next();
-
- if (transactionMapping != null
- &&
!transactionMapping.getLoanRepaymentScheduleInstallment().isPrincipalCompleted(loanCurrency))
{
- overdueSinceDate = loanTransaction.getTransactionDate();
- break;
- }
- }
- }
-
- // Include grace days If It's defined
- if (overdueSinceDate != null && graceOnArrearAgeing != null) {
- overdueSinceDate =
overdueSinceDate.plusDays(graceOnArrearAgeing.longValue());
- }
- return overdueSinceDate;
- }
-
- private Long calculateOverdueDays(final LocalDate businessDate, LocalDate
overdueSinceDate) {
- Long overdueDays = 0L;
- if (overdueSinceDate != null) {
- overdueDays = DateUtils.getDifferenceInDays(overdueSinceDate,
businessDate);
- if (overdueDays < 0) {
- overdueDays = 0L;
- }
- }
- return overdueDays;
+ final CollectionData collectionData =
this.loanCollectionDomainService.getOverdueCollectionData(loan, businessDate);
+ log.debug("Delinquency {}", collectionData.toString());
Review Comment:
Removed
--
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]