budaidev commented on code in PR #4973:
URL: https://github.com/apache/fineract/pull/4973#discussion_r2293290875
##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java:
##########
@@ -1818,4 +1818,40 @@ public boolean hasContractTerminationTransaction() {
return getLoanTransactions().stream().anyMatch(t ->
t.isContractTermination() && t.isNotReversed());
}
+ public BigDecimal calculateAvailableDisbursementAmountWithOverApplied() {
+ final LoanProduct loanProduct = this.getLoanProduct();
+
+ // Start with approved principal
+ BigDecimal approvedWithOverApplied = this.getApprovedPrincipal();
+
+ if (loanProduct.isAllowApprovedDisbursedAmountsOverApplied()) {
+ if (loanProduct.getOverAppliedCalculationType() != null) {
+ // If over applied amount is enabled, calculate the maximum
allowed amount
+ if
(LoanOverAppliedCalculationType.valueOf(loanProduct.getOverAppliedCalculationType().toUpperCase()).isPercentage())
{
Review Comment:
this can lead to illegal argument exception if not handled properly.
##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java:
##########
@@ -1818,4 +1818,40 @@ public boolean hasContractTerminationTransaction() {
return getLoanTransactions().stream().anyMatch(t ->
t.isContractTermination() && t.isNotReversed());
}
+ public BigDecimal calculateAvailableDisbursementAmountWithOverApplied() {
+ final LoanProduct loanProduct = this.getLoanProduct();
+
+ // Start with approved principal
+ BigDecimal approvedWithOverApplied = this.getApprovedPrincipal();
+
+ if (loanProduct.isAllowApprovedDisbursedAmountsOverApplied()) {
+ if (loanProduct.getOverAppliedCalculationType() != null) {
+ // If over applied amount is enabled, calculate the maximum
allowed amount
+ if
(LoanOverAppliedCalculationType.valueOf(loanProduct.getOverAppliedCalculationType().toUpperCase()).isPercentage())
{
+ final BigDecimal overAppliedNumber =
BigDecimal.valueOf(loanProduct.getOverAppliedNumber());
+ final BigDecimal totalPercentage =
BigDecimal.valueOf(1).add(overAppliedNumber.divide(BigDecimal.valueOf(100)));
Review Comment:
Consider to add math context when dividing BigDecimals
--
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]