thesmallstar commented on a change in pull request #1770:
URL: https://github.com/apache/fineract/pull/1770#discussion_r698034995
##########
File path:
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAssembler.java
##########
@@ -209,7 +215,38 @@ private Loan assembleApplication(final JsonElement
element, final Long clientId,
loanProduct.maxTrancheCount(),
disbursementDetails.size());
}
}
- final Set<LoanCollateral> collateral =
this.loanCollateralAssembler.fromParsedJson(element);
+
+ final String loanTypeParameterName = "loanType";
+ final String loanTypeStr =
this.fromApiJsonHelper.extractStringNamed(loanTypeParameterName, element);
+ final EnumOptionData loanType =
AccountEnumerations.loanType(loanTypeStr);
+ Set<LoanCollateralManagement> collateral = new HashSet<>();
+
+ if (!StringUtils.isBlank(loanTypeStr)) {
+ final AccountType loanAccountType =
AccountType.fromName(loanTypeStr);
+
+ if (loanAccountType.isIndividualAccount()) {
+ collateral = this.collateralAssembler.fromParsedJson(element);
+
+ if (collateral.size() == 0) {
+ throw new InvalidAmountOfCollaterals(BigDecimal.ZERO);
+ }
+
+ BigDecimal totalValue = BigDecimal.ZERO;
+ for (LoanCollateralManagement collateralManagement :
collateral) {
+ final CollateralManagementDomain
collateralManagementDomain =
collateralManagement.getClientCollateralManagement()
+ .getCollaterals();
+ BigDecimal totalCollateral =
collateralManagement.getQuantity().multiply(collateralManagementDomain.getBasePrice())
+
.multiply(collateralManagementDomain.getPctToBase()).divide(BigDecimal.valueOf(100));
+ totalValue = totalValue.add(totalCollateral);
+ }
+
+ if (amount.compareTo(totalValue) > 0) {
+ throw new InvalidAmountOfCollaterals(totalValue);
+ }
+ }
+ }
+
+ // final Set<LoanCollateral> collateral =
this.loanCollateralAssembler.fromParsedJson(element);
Review comment:
?
--
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]