Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FINERACT-2081: Loan account data additional fields for summary and de… #3957

Merged

Conversation

alberto-art3ch
Copy link
Contributor

…linquency

Description

For including new fields in the Loan account data API, we need to modify the GET Loan by ID / external-id API to return those additional fields. API : /fineract-provider/api/v1/loans/{loanId}

FINERACT-2081

  • Delinquency data
Screenshot 2024-07-03 at 12 25 53 a m
  • Summary data
Screenshot 2024-07-03 at 12 33 49 a m

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.

@@ -63,8 +63,7 @@ public enum LoanTransactionType {
DOWN_PAYMENT(28, "loanTransactionType.downPayment"), //
REAGE(29, "loanTransactionType.reAge"), //
REAMORTIZE(30, "loanTransactionType.reAmortize"), //
INTEREST_PAYMENT_WAIVER(31, "loanTransactionType.interestPaymentWaiver"), //
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary change... would you mind to revert?

@@ -58,7 +58,7 @@ private LocalDate getEffectiveDate() {
}

private boolean isBackdatedCharge() {
return loanCharge.get().getDueDate().isBefore(loanCharge.get().getSubmittedOnDate());
return (loanCharge.get().getDueDate() != null && loanCharge.get().getDueDate().isBefore(loanCharge.get().getSubmittedOnDate()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary change. Would you mind to revert? If it is a fix for a bug ticket, please extract it into a new PR!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! removed

Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing changed here either.... :/

Copy link
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 check my review!

@alberto-art3ch alberto-art3ch force-pushed the enhancement/loan_data_new_attributes branch from d14403e to 6db3dab Compare July 7, 2024 05:13
@@ -4113,6 +4114,67 @@ public void uc137() {
});
}

// uc142: Loan Progressive processing type only with Advanced payment allocation
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix the description of this use case

Long repayment2TransactionId = addRepaymentForLoan(loanId, 251.0, "3 January 2023");
assertNotNull(repayment2TransactionId);
loanDetails = loanTransactionHelper.getLoanDetails(loanId);
LOG.info("Data {}", loanDetails.getSummary().getTotalUnpaidAccruedDueInterest());
Copy link
Contributor

Choose a reason for hiding this comment

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

Writing out with logger is not enough! Please user assertions to validate the proper amount was calculated and retrieved!

@alberto-art3ch alberto-art3ch force-pushed the enhancement/loan_data_new_attributes branch from 6db3dab to 33cd782 Compare July 8, 2024 15:57
@@ -110,6 +116,11 @@ public static LoanSummaryData withTransactionAmountsSummary(final LoanSummaryDat
BigDecimal totalCreditBalanceRefundReversed = BigDecimal.ZERO;
BigDecimal totalRepaymentTransaction = BigDecimal.ZERO;
BigDecimal totalRepaymentTransactionReversed = BigDecimal.ZERO;
BigDecimal totalInterestRefund = BigDecimal.ZERO;
Copy link
Contributor

@adamsaghy adamsaghy Jul 8, 2024

Choose a reason for hiding this comment

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

We dont need field yet (totalInterestRefund) -> hence not implemented yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! removed

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems it was not removed, it is still there :(

@alberto-art3ch alberto-art3ch force-pushed the enhancement/loan_data_new_attributes branch from 33cd782 to 766a003 Compare July 9, 2024 16:04
@@ -191,4 +222,31 @@ private static BigDecimal computeTotalRepaymentTransactionAmount(Collection<Loan
loanTransactions);
return totalRepaymentTransaction.add(totalDownPaymentTransaction);
}

private static BigDecimal computeTotalAccruedDueAmount(Collection<LoanSchedulePeriodData> periods) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename this to reflect it is calculating the accrued interest amount: computeTotalInterestAccruedDueAmount

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! method renamed

.map(period -> period.getInterestPaid()).reduce(BigDecimal.ZERO, BigDecimal::add);
}

private static BigDecimal fetchTotalAccruedNotDueAmount(Collection<LoanSchedulePeriodData> periods) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename this to reflect it is calculating the accrued interest: computeTotalInterestAccruedNotDueAmount

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! method renamed

.map(period -> period.getTotalAccruedInterest()).reduce(BigDecimal.ZERO, BigDecimal::add);
}

private static BigDecimal fetchTotalInterestNotDueAmount(Collection<LoanSchedulePeriodData> periods) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename this to reflect it is calculating the accrued interest: computeTotalInterestNotDueAmount

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! method renamed

private final Boolean downPaymentPeriod;
private final Boolean actualPeriod;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! removed

+ " ls.total_paid_late_derived as totalPaidLateForPeriod, ls.credits_amount as principalCredits, ls.credited_fee as feeCredits, ls.credited_penalty as penaltyCredits, ls.is_down_payment isDownPayment "
+ " from m_loan_repayment_schedule ls ";
+ " ls.total_paid_late_derived as totalPaidLateForPeriod, ls.credits_amount as principalCredits, ls.credited_fee as feeCredits, ls.credited_penalty as penaltyCredits, ls.is_down_payment isDownPayment, "
+ " ls.accrual_interest_derived as totalAccrualInterest " + " from m_loan_repayment_schedule ls ";
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldnt it be better to name InterestAccrued? (all the other interest related fields are interestDue, interestPaid, etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! renamed

@alberto-art3ch alberto-art3ch force-pushed the enhancement/loan_data_new_attributes branch from 766a003 to 2c9f868 Compare July 10, 2024 06:38
Copy link
Contributor Author

@alberto-art3ch alberto-art3ch left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -58,7 +58,7 @@ private LocalDate getEffectiveDate() {
}

private boolean isBackdatedCharge() {
return loanCharge.get().getDueDate().isBefore(loanCharge.get().getSubmittedOnDate());
return (loanCharge.get().getDueDate() != null && loanCharge.get().getDueDate().isBefore(loanCharge.get().getSubmittedOnDate()));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! removed

private final Boolean downPaymentPeriod;
private final Boolean actualPeriod;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! removed

@@ -110,6 +116,11 @@ public static LoanSummaryData withTransactionAmountsSummary(final LoanSummaryDat
BigDecimal totalCreditBalanceRefundReversed = BigDecimal.ZERO;
BigDecimal totalRepaymentTransaction = BigDecimal.ZERO;
BigDecimal totalRepaymentTransactionReversed = BigDecimal.ZERO;
BigDecimal totalInterestRefund = BigDecimal.ZERO;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! removed

@@ -191,4 +222,31 @@ private static BigDecimal computeTotalRepaymentTransactionAmount(Collection<Loan
loanTransactions);
return totalRepaymentTransaction.add(totalDownPaymentTransaction);
}

private static BigDecimal computeTotalAccruedDueAmount(Collection<LoanSchedulePeriodData> periods) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! method renamed

.map(period -> period.getInterestPaid()).reduce(BigDecimal.ZERO, BigDecimal::add);
}

private static BigDecimal fetchTotalAccruedNotDueAmount(Collection<LoanSchedulePeriodData> periods) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! method renamed

.map(period -> period.getTotalAccruedInterest()).reduce(BigDecimal.ZERO, BigDecimal::add);
}

private static BigDecimal fetchTotalInterestNotDueAmount(Collection<LoanSchedulePeriodData> periods) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! method renamed

+ " ls.total_paid_late_derived as totalPaidLateForPeriod, ls.credits_amount as principalCredits, ls.credited_fee as feeCredits, ls.credited_penalty as penaltyCredits, ls.is_down_payment isDownPayment "
+ " from m_loan_repayment_schedule ls ";
+ " ls.total_paid_late_derived as totalPaidLateForPeriod, ls.credits_amount as principalCredits, ls.credited_fee as feeCredits, ls.credited_penalty as penaltyCredits, ls.is_down_payment isDownPayment, "
+ " ls.accrual_interest_derived as totalAccrualInterest " + " from m_loan_repayment_schedule ls ";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! renamed

@alberto-art3ch alberto-art3ch force-pushed the enhancement/loan_data_new_attributes branch 2 times, most recently from b306fd2 to 6c01694 Compare July 10, 2024 13:23
Copy link
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

@alberto-art3ch alberto-art3ch force-pushed the enhancement/loan_data_new_attributes branch from 6c01694 to 23a096e Compare July 10, 2024 14:12
@alberto-art3ch alberto-art3ch force-pushed the enhancement/loan_data_new_attributes branch from 23a096e to 5652354 Compare July 10, 2024 17:11
@adamsaghy adamsaghy merged commit 79f32d3 into apache:develop Jul 11, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants