-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
FINERACT-2081: Loan account data additional fields for summary and de… #3957
Conversation
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanSummaryData.java
Show resolved
Hide resolved
@@ -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"), // |
There was a problem hiding this comment.
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())); |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing changed here either.... :/
...der/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResourceSwagger.java
Outdated
Show resolved
Hide resolved
...pache/fineract/portfolio/deliquency/DelinquencyWritePlatformServiceRangeChangeEventTest.java
Show resolved
Hide resolved
There was a problem hiding this 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!
d14403e
to
6db3dab
Compare
@@ -4113,6 +4114,67 @@ public void uc137() { | |||
}); | |||
} | |||
|
|||
// uc142: Loan Progressive processing type only with Advanced payment allocation |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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!
6db3dab
to
33cd782
Compare
@@ -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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! removed
There was a problem hiding this comment.
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 :(
33cd782
to
766a003
Compare
@@ -191,4 +222,31 @@ private static BigDecimal computeTotalRepaymentTransactionAmount(Collection<Loan | |||
loanTransactions); | |||
return totalRepaymentTransaction.add(totalDownPaymentTransaction); | |||
} | |||
|
|||
private static BigDecimal computeTotalAccruedDueAmount(Collection<LoanSchedulePeriodData> periods) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! method renamed
.../main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/data/LoanScheduleData.java
Outdated
Show resolved
Hide resolved
private final Boolean downPaymentPeriod; | ||
private final Boolean actualPeriod; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 "; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! renamed
766a003
to
2c9f868
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
...der/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResourceSwagger.java
Outdated
Show resolved
Hide resolved
@@ -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())); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! method renamed
.../main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/data/LoanScheduleData.java
Outdated
Show resolved
Hide resolved
+ " 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 "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! renamed
...pache/fineract/portfolio/deliquency/DelinquencyWritePlatformServiceRangeChangeEventTest.java
Show resolved
Hide resolved
b306fd2
to
6c01694
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
6c01694
to
23a096e
Compare
23a096e
to
5652354
Compare
…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
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.