Skip to content

Commit

Permalink
SU-477 (#1348)
Browse files Browse the repository at this point in the history
* SU-477 add logic to handle flat aval charge for migration
  • Loading branch information
faheem205 authored Dec 7, 2024
1 parent 2f595d7 commit 3c8ae43
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Set<LoanCharge> fromParsedJson(final JsonElement element, List<LoanDisbur
}

final Set<LoanCharge> loanCharges = new LinkedHashSet<>();
final BigDecimal principal = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("principal", element);
BigDecimal principal = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("principal", element);
final Integer numberOfRepayments = this.fromApiJsonHelper.extractIntegerWithLocaleNamed("numberOfRepayments", element);
final Long productId = this.fromApiJsonHelper.extractLongNamed("productId", element);
final LoanProduct loanProduct = this.loanProductRepository.findById(productId)
Expand Down Expand Up @@ -227,6 +227,17 @@ public Set<LoanCharge> fromParsedJson(final JsonElement element, List<LoanDisbur
}

if (!isMultiDisbursal) {
if (chargeDefinition.isPercentageOfAnotherCharge()) {
final Charge parentCharge = this.chargeRepository
.findOneWithNotFoundDetection(chargeDefinition.getParentChargeId());
if (parentCharge.isAvalChargeFlatForMigration()) {
for (LoanCharge loanCharge : loanCharges) {
if (loanCharge.getCharge().getId().equals(chargeDefinition.getParentChargeId())) {
principal = loanCharge.amountOrPercentage();
}
}
}
}
final LoanCharge loanCharge = createNewWithoutLoan(chargeDefinition, principal, amount, chargeTime,
chargeCalculation, dueDate, chargePaymentModeEnum, numberOfRepayments, externalId,
getPercentageAmountFromTable, applicableFromInstallment, expDate, isEndorsed, insuranceName,
Expand Down

0 comments on commit 3c8ae43

Please sign in to comment.