ruchiD commented on code in PR #3367:
URL: https://github.com/apache/fineract/pull/3367#discussion_r1293071854
##########
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java:
##########
@@ -2954,6 +2956,51 @@ private void handleDisbursementTransaction(final
LocalDate disbursedOn, final Pa
}
+ public void 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(),
percentageOf(disbursedAmount, disbursedAmountPercentageForDownPayment));
+ LoanTransaction downPaymentTransaction =
LoanTransaction.downPayment(getOffice(), downPaymentMoney, null, disbursedOn,
+ externalId);
+ /**
+ * Currently mapping down payment transaction as repayment
transaction to loan repayment schedule for
+ * consistency. Need to replace below logic for creating new
installment for down payment and mapping.
+ */
+
+ 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);
+ }
+ }
+
+ private BigDecimal percentageOf(final BigDecimal value, final BigDecimal
percentage) {
Review Comment:
Moved method to MathUtil as operation is performed on BigDecimal amount.
@reluxa I checked amount saved in db for this example disbursedAmount =
99.19, percentage is 19. Downpayment amount is saved as 18.85 as rounding of
and numbers after decimal for amount are derived for currency settings. For
this test number of digits to be considered after decimal for currency was set
as 2.
--
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]