[FINERACT-1958] Business events for down payment installments
This commit is contained in:
+21
-24
@@ -2946,34 +2946,31 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
|
||||
|
||||
}
|
||||
|
||||
public void handleDownPayment(final BigDecimal disbursedAmount, final JsonCommand command,
|
||||
public LoanTransaction handleDownPayment(final BigDecimal disbursedAmount, final JsonCommand command,
|
||||
final ScheduleGeneratorDTO scheduleGeneratorDTO) {
|
||||
if (isAutoRepaymentForDownPaymentEnabled()) {
|
||||
LocalDate disbursedOn = command.localDateValueOfParameterNamed(ACTUAL_DISBURSEMENT_DATE);
|
||||
BigDecimal disbursedAmountPercentageForDownPayment = this.loanRepaymentScheduleDetail
|
||||
.getDisbursedAmountPercentageForDownPayment();
|
||||
ExternalId externalId = ExternalId.empty();
|
||||
if (TemporaryConfigurationServiceContainer.isExternalIdAutoGenerationEnabled()) {
|
||||
externalId = ExternalId.generate();
|
||||
}
|
||||
Money downPaymentMoney = Money.of(getCurrency(),
|
||||
MathUtil.percentageOf(disbursedAmount, disbursedAmountPercentageForDownPayment, 19));
|
||||
LoanTransaction downPaymentTransaction = LoanTransaction.downPayment(getOffice(), downPaymentMoney, null, disbursedOn,
|
||||
externalId);
|
||||
|
||||
LoanEvent event = LoanEvent.LOAN_REPAYMENT_OR_WAIVER;
|
||||
validateRepaymentTypeAccountStatus(downPaymentTransaction, event);
|
||||
HolidayDetailDTO holidayDetailDTO = scheduleGeneratorDTO.getHolidayDetailDTO();
|
||||
validateRepaymentDateIsOnHoliday(downPaymentTransaction.getTransactionDate(), holidayDetailDTO.isAllowTransactionsOnHoliday(),
|
||||
holidayDetailDTO.getHolidays());
|
||||
validateRepaymentDateIsOnNonWorkingDay(downPaymentTransaction.getTransactionDate(), holidayDetailDTO.getWorkingDays(),
|
||||
holidayDetailDTO.isAllowTransactionsOnNonWorkingDay());
|
||||
|
||||
handleRepaymentOrRecoveryOrWaiverTransaction(downPaymentTransaction, loanLifecycleStateMachine, null, scheduleGeneratorDTO);
|
||||
LocalDate disbursedOn = command.localDateValueOfParameterNamed(ACTUAL_DISBURSEMENT_DATE);
|
||||
BigDecimal disbursedAmountPercentageForDownPayment = this.loanRepaymentScheduleDetail.getDisbursedAmountPercentageForDownPayment();
|
||||
ExternalId externalId = ExternalId.empty();
|
||||
if (TemporaryConfigurationServiceContainer.isExternalIdAutoGenerationEnabled()) {
|
||||
externalId = ExternalId.generate();
|
||||
}
|
||||
Money downPaymentMoney = Money.of(getCurrency(),
|
||||
MathUtil.percentageOf(disbursedAmount, disbursedAmountPercentageForDownPayment, 19));
|
||||
LoanTransaction downPaymentTransaction = LoanTransaction.downPayment(getOffice(), downPaymentMoney, null, disbursedOn, externalId);
|
||||
|
||||
LoanEvent event = LoanEvent.LOAN_REPAYMENT_OR_WAIVER;
|
||||
validateRepaymentTypeAccountStatus(downPaymentTransaction, event);
|
||||
HolidayDetailDTO holidayDetailDTO = scheduleGeneratorDTO.getHolidayDetailDTO();
|
||||
validateRepaymentDateIsOnHoliday(downPaymentTransaction.getTransactionDate(), holidayDetailDTO.isAllowTransactionsOnHoliday(),
|
||||
holidayDetailDTO.getHolidays());
|
||||
validateRepaymentDateIsOnNonWorkingDay(downPaymentTransaction.getTransactionDate(), holidayDetailDTO.getWorkingDays(),
|
||||
holidayDetailDTO.isAllowTransactionsOnNonWorkingDay());
|
||||
|
||||
handleRepaymentOrRecoveryOrWaiverTransaction(downPaymentTransaction, loanLifecycleStateMachine, null, scheduleGeneratorDTO);
|
||||
return downPaymentTransaction;
|
||||
}
|
||||
|
||||
private boolean isAutoRepaymentForDownPaymentEnabled() {
|
||||
public boolean isAutoRepaymentForDownPaymentEnabled() {
|
||||
return this.loanRepaymentScheduleDetail.isEnableDownPayment()
|
||||
&& this.loanRepaymentScheduleDetail.isEnableAutoRepaymentForDownPayment();
|
||||
}
|
||||
|
||||
+8
@@ -72,6 +72,7 @@ public final class LoanSchedulePeriodData {
|
||||
private final BigDecimal totalActualCostOfLoanForPeriod;
|
||||
private final BigDecimal totalInstallmentAmountForPeriod;
|
||||
private final BigDecimal totalCredits;
|
||||
private final Boolean downPaymentPeriod;
|
||||
|
||||
public static LoanSchedulePeriodData disbursementOnlyPeriod(final LocalDate disbursementDate, final BigDecimal principalDisbursed,
|
||||
final BigDecimal feeChargesDueAtTimeOfDisbursement, final boolean isDisbursed) {
|
||||
@@ -205,6 +206,7 @@ public final class LoanSchedulePeriodData {
|
||||
this.totalOverdue = null;
|
||||
}
|
||||
this.totalCredits = BigDecimal.ZERO;
|
||||
this.downPaymentPeriod = false;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -268,9 +270,13 @@ public final class LoanSchedulePeriodData {
|
||||
this.totalOverdue = null;
|
||||
}
|
||||
this.totalCredits = BigDecimal.ZERO;
|
||||
this.downPaymentPeriod = false;
|
||||
}
|
||||
|
||||
// TODO refactor the class to builder pattern
|
||||
/*
|
||||
* used for down payment only period when creating an empty loan schedule for preview etc
|
||||
*/
|
||||
private LoanSchedulePeriodData(Integer periodNumber, LocalDate fromDate, LocalDate dueDate, BigDecimal principalDue,
|
||||
BigDecimal principalOutstanding) {
|
||||
this.period = periodNumber;
|
||||
@@ -323,6 +329,7 @@ public final class LoanSchedulePeriodData {
|
||||
this.totalOverdue = null;
|
||||
}
|
||||
this.totalCredits = BigDecimal.ZERO;
|
||||
this.downPaymentPeriod = true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -396,6 +403,7 @@ public final class LoanSchedulePeriodData {
|
||||
this.totalOverdue = null;
|
||||
}
|
||||
this.totalCredits = totalCredits;
|
||||
this.downPaymentPeriod = false;
|
||||
}
|
||||
|
||||
private BigDecimal defaultToZeroIfNull(final BigDecimal possibleNullValue) {
|
||||
|
||||
Reference in New Issue
Block a user