Skip to content

Commit

Permalink
SU-477 (#1371)
Browse files Browse the repository at this point in the history
* SU-477
  • Loading branch information
faheem205 authored Dec 10, 2024
1 parent 035aaa5 commit 0b76027
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,39 @@ public LoanChargeData(final Long id, final LocalDate dueAsOfDate, final BigDecim
this.externalId = ExternalId.empty();
}

public LoanChargeData(final Long id, final BigDecimal amount) {
this.id = null;
this.chargeId = id;
this.name = null;
this.currency = null;
this.amount = amount;
this.amountPaid = null;
this.amountWaived = null;
this.amountWrittenOff = null;
this.amountOutstanding = null;
this.chargeTimeType = null;
this.submittedOnDate = null;
this.dueDate = null;
this.chargeCalculationType = null;
this.percentage = null;
this.amountPercentageAppliedTo = null;
this.penalty = false;
this.chargePaymentMode = null;
this.paid = false;
this.waived = false;
this.amountOrPercentage = null;
this.chargeOptions = null;
this.chargePayable = false;
this.loanId = null;
this.externalLoanId = ExternalId.empty();
this.minCap = null;
this.maxCap = null;
this.installmentChargeData = null;
this.amountAccrued = null;
this.amountUnrecognized = null;
this.externalId = ExternalId.empty();
}

public boolean isChargePayable() {
boolean isAccountTransfer = false;
if (this.chargePaymentMode != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,43 +295,52 @@ private LoanAccountData readLoan(final Workbook workbook, final Row row, final L

if (chargeOneId != null) {
if (ImportHandlerUtils.readAsDouble(LoanConstants.CHARGE_AMOUNT_1, row) != null) {
EnumOptionData chargeOneTimeTypeEnum = ImportHandlerUtils
.getChargeTimeTypeEmun(workbook.getSheet(TemplatePopulateImportConstants.CHARGE_SHEET_NAME), chargeOneName);
EnumOptionData chargeOneAmountTypeEnum = ImportHandlerUtils
.getChargeAmountTypeEnum(ImportHandlerUtils.readAsString(LoanConstants.CHARGE_AMOUNT_TYPE_1, row));

BigDecimal chargeAmount;
BigDecimal amountOrPercentage = BigDecimal.valueOf(ImportHandlerUtils.readAsDouble(LoanConstants.CHARGE_AMOUNT_1, row));
if (chargeOneAmountTypeEnum.getValue().equalsIgnoreCase("1")) {
chargeAmount = amountOrPercentage;
if (!isMigratedLoan) {
EnumOptionData chargeOneTimeTypeEnum = ImportHandlerUtils
.getChargeTimeTypeEmun(workbook.getSheet(TemplatePopulateImportConstants.CHARGE_SHEET_NAME), chargeOneName);
EnumOptionData chargeOneAmountTypeEnum = ImportHandlerUtils
.getChargeAmountTypeEnum(ImportHandlerUtils.readAsString(LoanConstants.CHARGE_AMOUNT_TYPE_1, row));

BigDecimal chargeAmount;
BigDecimal amountOrPercentage = BigDecimal.valueOf(ImportHandlerUtils.readAsDouble(LoanConstants.CHARGE_AMOUNT_1, row));
if (chargeOneAmountTypeEnum.getValue().equalsIgnoreCase("1")) {
chargeAmount = amountOrPercentage;
} else {
chargeAmount = LoanCharge.percentageOf(principal, amountOrPercentage);
}
charges.add(new LoanChargeData(chargeOneId, ImportHandlerUtils.readAsDate(LoanConstants.CHARGE_DUE_DATE_1, row),
chargeAmount, chargeOneAmountTypeEnum, chargeOneTimeTypeEnum));
} else {
chargeAmount = LoanCharge.percentageOf(principal, amountOrPercentage);
BigDecimal amountOrPercentage = BigDecimal.valueOf(ImportHandlerUtils.readAsDouble(LoanConstants.CHARGE_AMOUNT_1, row));
charges.add(new LoanChargeData(chargeOneId, amountOrPercentage));
}

charges.add(new LoanChargeData(chargeOneId, ImportHandlerUtils.readAsDate(LoanConstants.CHARGE_DUE_DATE_1, row),
chargeAmount, chargeOneAmountTypeEnum, chargeOneTimeTypeEnum));
} else {
charges.add(new LoanChargeData(chargeOneId, ImportHandlerUtils.readAsDate(LoanConstants.CHARGE_DUE_DATE_1, row), null));
}
}

if (chargeTwoId != null) {
if (ImportHandlerUtils.readAsDouble(LoanConstants.CHARGE_AMOUNT_2, row) != null) {
EnumOptionData chargeTwoTimeTypeEnum = ImportHandlerUtils
.getChargeTimeTypeEmun(workbook.getSheet(TemplatePopulateImportConstants.CHARGE_SHEET_NAME), chargeTwoName);
EnumOptionData chargeTwoAmountTypeEnum = ImportHandlerUtils
.getChargeAmountTypeEnum(ImportHandlerUtils.readAsString(LoanConstants.CHARGE_AMOUNT_TYPE_2, row));

BigDecimal chargeAmount;
BigDecimal amountOrPercentage = BigDecimal.valueOf(ImportHandlerUtils.readAsDouble(LoanConstants.CHARGE_AMOUNT_2, row));
if (chargeTwoTimeTypeEnum.getValue().equalsIgnoreCase("1")) {
chargeAmount = amountOrPercentage;
if (!isMigratedLoan) {
EnumOptionData chargeTwoTimeTypeEnum = ImportHandlerUtils
.getChargeTimeTypeEmun(workbook.getSheet(TemplatePopulateImportConstants.CHARGE_SHEET_NAME), chargeTwoName);
EnumOptionData chargeTwoAmountTypeEnum = ImportHandlerUtils
.getChargeAmountTypeEnum(ImportHandlerUtils.readAsString(LoanConstants.CHARGE_AMOUNT_TYPE_2, row));

BigDecimal chargeAmount;
BigDecimal amountOrPercentage = BigDecimal.valueOf(ImportHandlerUtils.readAsDouble(LoanConstants.CHARGE_AMOUNT_2, row));
if (chargeTwoTimeTypeEnum.getValue().equalsIgnoreCase("1")) {
chargeAmount = amountOrPercentage;
} else {
chargeAmount = LoanCharge.percentageOf(principal, amountOrPercentage);
}

charges.add(new LoanChargeData(chargeTwoId, ImportHandlerUtils.readAsDate(LoanConstants.CHARGE_DUE_DATE_2, row),
chargeAmount, chargeTwoAmountTypeEnum, chargeTwoTimeTypeEnum));
} else {
chargeAmount = LoanCharge.percentageOf(principal, amountOrPercentage);
BigDecimal amountOrPercentage = BigDecimal.valueOf(ImportHandlerUtils.readAsDouble(LoanConstants.CHARGE_AMOUNT_2, row));
charges.add(new LoanChargeData(chargeTwoId, amountOrPercentage));
}

charges.add(new LoanChargeData(chargeTwoId, ImportHandlerUtils.readAsDate(LoanConstants.CHARGE_DUE_DATE_2, row),
chargeAmount, chargeTwoAmountTypeEnum, chargeTwoTimeTypeEnum));
} else {
charges.add(new LoanChargeData(chargeTwoId, ImportHandlerUtils.readAsDate(LoanConstants.CHARGE_DUE_DATE_2, row), null));
}
Expand Down

0 comments on commit 0b76027

Please sign in to comment.