Skip to content

FINERACT-1992-FINERACT-Installment-level-delinquency-calculation#3515

Merged
adamsaghy merged 1 commit intoapache:developfrom
ruchiD:FINERACT-1992-FINERACT-Installment-level-delinquency-calculation
Oct 27, 2023
Merged

FINERACT-1992-FINERACT-Installment-level-delinquency-calculation#3515
adamsaghy merged 1 commit intoapache:developfrom
ruchiD:FINERACT-1992-FINERACT-Installment-level-delinquency-calculation

Conversation

@ruchiD
Copy link
Copy Markdown
Contributor

@ruchiD ruchiD commented Oct 18, 2023

Description

Changes for calculating and persisting installment level delinquency data.

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 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we would not keep this entries, rather regenerate them, please remove the "History" from everywhere

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you help me understand more what is "firstOverdueDate"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As i understood it, firstOverdueDate is the date when installment became delinquent for the first time. It can be installment due date or chargeback transaction date ,which we get after delinquency calculation. I am storing it when the record is getting created for the first time and if delinquency range changes i copy it from previous record and save it in new one.
This column was defined as requirement in db ticket and this ticket as well.

@ruchiD ruchiD force-pushed the FINERACT-1992-FINERACT-Installment-level-delinquency-calculation branch from a9ead0d to c8f0f8e Compare October 19, 2023 08:34
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When the loan delinquency gets calculated, the installment level delinquency can be also calculated. Would you consider to do merge them together?

Copy link
Copy Markdown
Contributor Author

@ruchiD ruchiD Oct 19, 2023

Choose a reason for hiding this comment

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

When Loan level delinquency gets calculated it calculates overdueSince date till oldest overdue installment or chargeback date for first non due installment if exists and does not calculates for rest of them. so we need to calculate for all installments separately.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i was just wondering when we are calculating the loan delinquency and we are going through on the installments one by one, we can calculate the delinquency for installment as well. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Loan and installment delinquency calculation logic merged.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We dont need to fetch the delinquency tags to be deleted. Please write a query which deletes all tags based on the loan.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@ruchiD ruchiD force-pushed the FINERACT-1992-FINERACT-Installment-level-delinquency-calculation branch from c8f0f8e to ae321e3 Compare October 25, 2023 13:18
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We dont keep any history, please "m_loan_installment_delinquency_tag_history" rename this table!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why to drop the FK for the loan? and for the range?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done. dropped FK for installment only

Copy link
Copy Markdown
Contributor

@adamsaghy adamsaghy Oct 25, 2023

Choose a reason for hiding this comment

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

Still loading the loan for no reason (by fetching LoanInstallmentDelinquencyTag you are fetching the loan as well hence the ManyToOne relation is by default using eager fetching).

Please fetch the required loanInstallmentsDelinquencyData (LoanInstallmentDelinquencyTagData) via the repository using JPA projections:

https://www.baeldung.com/spring-data-jpa-projections

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done. Fetching only Delinquency Range and outstanding amount for installments

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can be optimised a little bit:
Iterate through the installments of the loan and get by id from the installmentCollectionData the entry. If there is none, go next.

This way you only iterate through on the installments only once.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

@adamsaghy adamsaghy Oct 25, 2023

Choose a reason for hiding this comment

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

currentInstallmentDelinquencyTag is kind of meaningless... please review this logic again

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i am not fully sure why we need this:

  • Either you are deleting all of the tags and recalculate all of them and store
    or
  • You are removing which is not delinquent anymore / not existing (when you calculated the new entries, you have all the information to remove the "old" ones)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved this logic to delinquency calculation service.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please undo this. There must be a different place and way to handle it!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

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

Please kindly see my comments!

@ruchiD ruchiD force-pushed the FINERACT-1992-FINERACT-Installment-level-delinquency-calculation branch from ae321e3 to 0f6c22f Compare October 26, 2023 17:52
Copy link
Copy Markdown
Contributor

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

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

LGTM

@adamsaghy adamsaghy merged commit 8cea837 into apache:develop Oct 27, 2023
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.

2 participants