FINERACT-2232: Capitalized income - transaction reversal
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.fineract.infrastructure.event.business.domain.loan.transaction;
|
||||||
|
|
||||||
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
|
||||||
|
|
||||||
|
public class LoanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent extends LoanTransactionBusinessEvent {
|
||||||
|
|
||||||
|
private static final String TYPE = "LoanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent";
|
||||||
|
|
||||||
|
public LoanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent(LoanTransaction value) {
|
||||||
|
super(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -56,5 +56,6 @@ public interface LoanTransactionApiConstants {
|
|||||||
capitalizedIncomeAmortization, //
|
capitalizedIncomeAmortization, //
|
||||||
capitalizedIncomeAdjustment, //
|
capitalizedIncomeAdjustment, //
|
||||||
contractTermination, //
|
contractTermination, //
|
||||||
|
capitalizedIncomeAmortizationAdjustment, //
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -70,6 +70,7 @@ public class LoanTransactionEnumData implements Serializable {
|
|||||||
private final boolean capitalizedIncome;
|
private final boolean capitalizedIncome;
|
||||||
private final boolean capitalizedIncomeAmortization;
|
private final boolean capitalizedIncomeAmortization;
|
||||||
private final boolean capitalizedIncomeAdjustment;
|
private final boolean capitalizedIncomeAdjustment;
|
||||||
|
private final boolean capitalizedIncomeAmortizationAdjustment;
|
||||||
|
|
||||||
public LoanTransactionEnumData(final Long id, final String code, final String value) {
|
public LoanTransactionEnumData(final Long id, final String code, final String value) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@@ -109,6 +110,8 @@ public class LoanTransactionEnumData implements Serializable {
|
|||||||
this.capitalizedIncome = Long.valueOf(LoanTransactionType.CAPITALIZED_INCOME.getValue()).equals(this.id);
|
this.capitalizedIncome = Long.valueOf(LoanTransactionType.CAPITALIZED_INCOME.getValue()).equals(this.id);
|
||||||
this.capitalizedIncomeAmortization = Long.valueOf(LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION.getValue()).equals(this.id);
|
this.capitalizedIncomeAmortization = Long.valueOf(LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION.getValue()).equals(this.id);
|
||||||
this.capitalizedIncomeAdjustment = Long.valueOf(LoanTransactionType.CAPITALIZED_INCOME_ADJUSTMENT.getValue()).equals(this.id);
|
this.capitalizedIncomeAdjustment = Long.valueOf(LoanTransactionType.CAPITALIZED_INCOME_ADJUSTMENT.getValue()).equals(this.id);
|
||||||
|
this.capitalizedIncomeAmortizationAdjustment = Long
|
||||||
|
.valueOf(LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION_ADJUSTMENT.getValue()).equals(this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRepaymentType() {
|
public boolean isRepaymentType() {
|
||||||
|
|||||||
+12
-1
@@ -332,6 +332,16 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
|||||||
amount.getAmount(), amount.getAmount(), null, null, null, null, false, paymentDetail, externalId);
|
amount.getAmount(), amount.getAmount(), null, null, null, null, false, paymentDetail, externalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LoanTransaction capitalizedIncomeAmortizationAdjustment(final Loan loan, final Money amount,
|
||||||
|
final LocalDate transactionDate, final ExternalId externalId) {
|
||||||
|
return switch (loan.getLoanProductRelatedDetail().getCapitalizedIncomeType()) {
|
||||||
|
case FEE -> new LoanTransaction(loan, loan.getOffice(), LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION_ADJUSTMENT,
|
||||||
|
transactionDate, amount.getAmount(), null, null, amount.getAmount(), null, null, false, null, externalId);
|
||||||
|
case INTEREST -> new LoanTransaction(loan, loan.getOffice(), LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION_ADJUSTMENT,
|
||||||
|
transactionDate, amount.getAmount(), null, amount.getAmount(), null, null, null, false, null, externalId);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public LoanTransaction copyTransactionPropertiesAndMappings() {
|
public LoanTransaction copyTransactionPropertiesAndMappings() {
|
||||||
LoanTransaction newTransaction = copyTransactionProperties(this);
|
LoanTransaction newTransaction = copyTransactionProperties(this);
|
||||||
newTransaction.updateLoanTransactionToRepaymentScheduleMappings(loanTransactionToRepaymentScheduleMappings);
|
newTransaction.updateLoanTransactionToRepaymentScheduleMappings(loanTransactionToRepaymentScheduleMappings);
|
||||||
@@ -789,7 +799,8 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
|||||||
|| type == LoanTransactionType.INITIATE_TRANSFER || type == LoanTransactionType.REJECT_TRANSFER
|
|| type == LoanTransactionType.INITIATE_TRANSFER || type == LoanTransactionType.REJECT_TRANSFER
|
||||||
|| type == LoanTransactionType.WITHDRAW_TRANSFER || type == LoanTransactionType.CHARGE_OFF
|
|| type == LoanTransactionType.WITHDRAW_TRANSFER || type == LoanTransactionType.CHARGE_OFF
|
||||||
|| type == LoanTransactionType.REAMORTIZE || type == LoanTransactionType.REAGE
|
|| type == LoanTransactionType.REAMORTIZE || type == LoanTransactionType.REAGE
|
||||||
|| type == LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION || type == LoanTransactionType.CONTRACT_TERMINATION);
|
|| type == LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION || type == LoanTransactionType.CONTRACT_TERMINATION
|
||||||
|
|| type == LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION_ADJUSTMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateOutstandingLoanBalance(BigDecimal outstandingLoanBalance) {
|
public void updateOutstandingLoanBalance(BigDecimal outstandingLoanBalance) {
|
||||||
|
|||||||
+2
@@ -70,6 +70,7 @@ public enum LoanTransactionType {
|
|||||||
CAPITALIZED_INCOME(35, "loanTransactionType.capitalizedIncome"), //
|
CAPITALIZED_INCOME(35, "loanTransactionType.capitalizedIncome"), //
|
||||||
CAPITALIZED_INCOME_AMORTIZATION(36, "loanTransactionType.capitalizedIncomeAmortization"), //
|
CAPITALIZED_INCOME_AMORTIZATION(36, "loanTransactionType.capitalizedIncomeAmortization"), //
|
||||||
CAPITALIZED_INCOME_ADJUSTMENT(37, "loanTransactionType.capitalizedIncomeAdjustment"), //
|
CAPITALIZED_INCOME_ADJUSTMENT(37, "loanTransactionType.capitalizedIncomeAdjustment"), //
|
||||||
|
CAPITALIZED_INCOME_AMORTIZATION_ADJUSTMENT(39, "loanTransactionType.capitalizedIncomeAmortizationAdjustment"), //
|
||||||
// Kind of Final Transactions
|
// Kind of Final Transactions
|
||||||
CONTRACT_TERMINATION(38, "loanTransactionType.contractTermination"), //
|
CONTRACT_TERMINATION(38, "loanTransactionType.contractTermination"), //
|
||||||
;
|
;
|
||||||
@@ -126,6 +127,7 @@ public enum LoanTransactionType {
|
|||||||
case 36 -> LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION;
|
case 36 -> LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION;
|
||||||
case 37 -> LoanTransactionType.CAPITALIZED_INCOME_ADJUSTMENT;
|
case 37 -> LoanTransactionType.CAPITALIZED_INCOME_ADJUSTMENT;
|
||||||
case 38 -> LoanTransactionType.CONTRACT_TERMINATION;
|
case 38 -> LoanTransactionType.CONTRACT_TERMINATION;
|
||||||
|
case 39 -> LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION_ADJUSTMENT;
|
||||||
default -> LoanTransactionType.INVALID;
|
default -> LoanTransactionType.INVALID;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -335,6 +335,9 @@ public final class LoanEnumerations {
|
|||||||
LoanTransactionType.CAPITALIZED_INCOME_ADJUSTMENT.getCode(), "Capitalized Income Adjustment");
|
LoanTransactionType.CAPITALIZED_INCOME_ADJUSTMENT.getCode(), "Capitalized Income Adjustment");
|
||||||
case CONTRACT_TERMINATION -> new LoanTransactionEnumData(LoanTransactionType.CONTRACT_TERMINATION.getValue().longValue(),
|
case CONTRACT_TERMINATION -> new LoanTransactionEnumData(LoanTransactionType.CONTRACT_TERMINATION.getValue().longValue(),
|
||||||
LoanTransactionType.CONTRACT_TERMINATION.getCode(), "Contract Termination");
|
LoanTransactionType.CONTRACT_TERMINATION.getCode(), "Contract Termination");
|
||||||
|
case CAPITALIZED_INCOME_AMORTIZATION_ADJUSTMENT -> new LoanTransactionEnumData(
|
||||||
|
LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION_ADJUSTMENT.getValue().longValue(),
|
||||||
|
LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION_ADJUSTMENT.getCode(), "Capitalized Income Amortization Adjustment");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+31
@@ -150,6 +150,10 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
if (transactionType.isCapitalizedIncomeAdjustment()) {
|
if (transactionType.isCapitalizedIncomeAdjustment()) {
|
||||||
createJournalEntriesForCapitalizedIncomeAdjustment(loanDTO, loanTransactionDTO, office);
|
createJournalEntriesForCapitalizedIncomeAdjustment(loanDTO, loanTransactionDTO, office);
|
||||||
}
|
}
|
||||||
|
// Capitalized Income Amortization Adjustment
|
||||||
|
if (transactionType.isCapitalizedIncomeAmortizationAdjustment()) {
|
||||||
|
createJournalEntriesForCapitalizedIncomeAmortizationAdjustment(loanDTO, loanTransactionDTO, office);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,6 +430,33 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createJournalEntriesForCapitalizedIncomeAmortizationAdjustment(final LoanDTO loanDTO,
|
||||||
|
final LoanTransactionDTO loanTransactionDTO, final Office office) {
|
||||||
|
GLAccountBalanceHolder glAccountBalanceHolder = new GLAccountBalanceHolder();
|
||||||
|
if (MathUtil.isGreaterThanZero(loanTransactionDTO.getAmount())) {
|
||||||
|
populateCreditDebitMaps(loanDTO.getLoanProductId(), loanTransactionDTO.getAmount(), loanTransactionDTO.getPaymentTypeId(),
|
||||||
|
AccrualAccountsForLoan.DEFERRED_INCOME_LIABILITY.getValue(),
|
||||||
|
AccrualAccountsForLoan.INCOME_FROM_CAPITALIZATION.getValue(), glAccountBalanceHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
// create credit entries
|
||||||
|
for (Map.Entry<Long, BigDecimal> creditEntry : glAccountBalanceHolder.getCreditBalances().entrySet()) {
|
||||||
|
if (MathUtil.isGreaterThanZero(creditEntry.getValue())) {
|
||||||
|
GLAccount glAccount = glAccountBalanceHolder.getGlAccountMap().get(creditEntry.getKey());
|
||||||
|
this.helper.createCreditJournalEntryForLoan(office, loanDTO.getCurrencyCode(), loanDTO.getLoanId(),
|
||||||
|
loanTransactionDTO.getTransactionId(), loanTransactionDTO.getTransactionDate(), creditEntry.getValue(), glAccount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// create debit entries
|
||||||
|
for (Map.Entry<Long, BigDecimal> debitEntry : glAccountBalanceHolder.getDebitBalances().entrySet()) {
|
||||||
|
if (MathUtil.isGreaterThanZero(debitEntry.getValue())) {
|
||||||
|
GLAccount glAccount = glAccountBalanceHolder.getGlAccountMap().get(debitEntry.getKey());
|
||||||
|
this.helper.createDebitJournalEntryForLoan(office, loanDTO.getCurrencyCode(), loanDTO.getLoanId(),
|
||||||
|
loanTransactionDTO.getTransactionId(), loanTransactionDTO.getTransactionDate(), debitEntry.getValue(), glAccount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void createJournalEntriesForInterestPaymentWaiverOrInterestRefund(LoanDTO loanDTO, LoanTransactionDTO loanTransactionDTO,
|
private void createJournalEntriesForInterestPaymentWaiverOrInterestRefund(LoanDTO loanDTO, LoanTransactionDTO loanTransactionDTO,
|
||||||
Office office) {
|
Office office) {
|
||||||
final Long loanProductId = loanDTO.getLoanProductId();
|
final Long loanProductId = loanDTO.getLoanProductId();
|
||||||
|
|||||||
+1
@@ -536,6 +536,7 @@ public class LoanTransactionsApiResource {
|
|||||||
case capitalizedIncomeAmortization -> LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION;
|
case capitalizedIncomeAmortization -> LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION;
|
||||||
case capitalizedIncomeAdjustment -> LoanTransactionType.CAPITALIZED_INCOME_ADJUSTMENT;
|
case capitalizedIncomeAdjustment -> LoanTransactionType.CAPITALIZED_INCOME_ADJUSTMENT;
|
||||||
case contractTermination -> LoanTransactionType.CONTRACT_TERMINATION;
|
case contractTermination -> LoanTransactionType.CONTRACT_TERMINATION;
|
||||||
|
case capitalizedIncomeAmortizationAdjustment -> LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION_ADJUSTMENT;
|
||||||
default ->
|
default ->
|
||||||
throw new InvalidLoanTransactionTypeException("transaction", transactionTypeParam.name(), "Unknown transaction type");
|
throw new InvalidLoanTransactionTypeException("transaction", transactionTypeParam.name(), "Unknown transaction type");
|
||||||
};
|
};
|
||||||
|
|||||||
+53
-3
@@ -33,8 +33,11 @@ import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
|
|||||||
import org.apache.fineract.infrastructure.core.domain.ExternalId;
|
import org.apache.fineract.infrastructure.core.domain.ExternalId;
|
||||||
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
|
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||||
|
import org.apache.fineract.infrastructure.core.service.ExternalIdFactory;
|
||||||
|
import org.apache.fineract.infrastructure.core.service.MathUtil;
|
||||||
import org.apache.fineract.infrastructure.event.business.domain.loan.LoanAdjustTransactionBusinessEvent;
|
import org.apache.fineract.infrastructure.event.business.domain.loan.LoanAdjustTransactionBusinessEvent;
|
||||||
import org.apache.fineract.infrastructure.event.business.domain.loan.LoanBalanceChangedBusinessEvent;
|
import org.apache.fineract.infrastructure.event.business.domain.loan.LoanBalanceChangedBusinessEvent;
|
||||||
|
import org.apache.fineract.infrastructure.event.business.domain.loan.transaction.LoanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent;
|
||||||
import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
|
import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
|
||||||
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
||||||
import org.apache.fineract.organisation.monetary.domain.Money;
|
import org.apache.fineract.organisation.monetary.domain.Money;
|
||||||
@@ -45,6 +48,7 @@ import org.apache.fineract.portfolio.loanaccount.data.HolidayDetailDTO;
|
|||||||
import org.apache.fineract.portfolio.loanaccount.data.ScheduleGeneratorDTO;
|
import org.apache.fineract.portfolio.loanaccount.data.ScheduleGeneratorDTO;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanAccountDomainService;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanAccountDomainService;
|
||||||
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanCapitalizedIncomeBalance;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanEvent;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanEvent;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanLifecycleStateMachine;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanLifecycleStateMachine;
|
||||||
@@ -56,6 +60,7 @@ import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionRepositor
|
|||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType;
|
||||||
import org.apache.fineract.portfolio.loanaccount.exception.InvalidLoanTransactionTypeException;
|
import org.apache.fineract.portfolio.loanaccount.exception.InvalidLoanTransactionTypeException;
|
||||||
import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType;
|
import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType;
|
||||||
|
import org.apache.fineract.portfolio.loanaccount.repository.LoanCapitalizedIncomeBalanceRepository;
|
||||||
import org.apache.fineract.portfolio.loanaccount.serialization.LoanChargeValidator;
|
import org.apache.fineract.portfolio.loanaccount.serialization.LoanChargeValidator;
|
||||||
import org.apache.fineract.portfolio.loanaccount.serialization.LoanTransactionValidator;
|
import org.apache.fineract.portfolio.loanaccount.serialization.LoanTransactionValidator;
|
||||||
import org.apache.fineract.portfolio.loanaccount.service.LoanAccrualTransactionBusinessEventService;
|
import org.apache.fineract.portfolio.loanaccount.service.LoanAccrualTransactionBusinessEventService;
|
||||||
@@ -95,6 +100,8 @@ public class LoanAdjustmentServiceImpl implements LoanAdjustmentService {
|
|||||||
private final LoanJournalEntryPoster journalEntryPoster;
|
private final LoanJournalEntryPoster journalEntryPoster;
|
||||||
private final LoanBalanceService loanBalanceService;
|
private final LoanBalanceService loanBalanceService;
|
||||||
private final ReprocessLoanTransactionsService reprocessLoanTransactionsService;
|
private final ReprocessLoanTransactionsService reprocessLoanTransactionsService;
|
||||||
|
private final LoanCapitalizedIncomeBalanceRepository loanCapitalizedIncomeBalanceRepository;
|
||||||
|
private final ExternalIdFactory externalIdFactory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult adjustLoanTransaction(Loan loan, LoanTransaction transactionToAdjust, LoanAdjustmentParameter parameter,
|
public CommandProcessingResult adjustLoanTransaction(Loan loan, LoanTransaction transactionToAdjust, LoanAdjustmentParameter parameter,
|
||||||
@@ -136,6 +143,39 @@ public class LoanAdjustmentServiceImpl implements LoanAdjustmentService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoanTransaction capitalizedIncomeAmortizationAdjustmentTransaction = null;
|
||||||
|
if (transactionToAdjust.isCapitalizedIncome()) {
|
||||||
|
if (newTransactionDetail.isNotZero()) {
|
||||||
|
throw new InvalidLoanTransactionTypeException("transaction", "capitalizedIncome.cannot.be.adjusted",
|
||||||
|
"Capitalized income transaction cannot be adjusted");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoanCapitalizedIncomeBalance capitalizedIncomeBalance = loanCapitalizedIncomeBalanceRepository
|
||||||
|
.findByLoanIdAndLoanTransactionId(loan.getId(), transactionToAdjust.getId());
|
||||||
|
if (MathUtil.isGreaterThanZero(capitalizedIncomeBalance.getAmountAdjustment())) {
|
||||||
|
throw new InvalidLoanTransactionTypeException("transaction", "capitalizedIncome.cannot.be.reversed.when.adjusted",
|
||||||
|
"Capitalized income transaction cannot be reversed when non-reversed adjustment exists for it.");
|
||||||
|
}
|
||||||
|
BigDecimal recognizedAmount = capitalizedIncomeBalance.getAmount().subtract(capitalizedIncomeBalance.getUnrecognizedAmount());
|
||||||
|
capitalizedIncomeAmortizationAdjustmentTransaction = LoanTransaction.capitalizedIncomeAmortizationAdjustment(loan,
|
||||||
|
Money.of(loan.getCurrency(), recognizedAmount), DateUtils.getBusinessLocalDate(), externalIdFactory.create());
|
||||||
|
loanCapitalizedIncomeBalanceRepository.delete(capitalizedIncomeBalance);
|
||||||
|
}
|
||||||
|
if (transactionToAdjust.isCapitalizedIncomeAdjustment()) {
|
||||||
|
if (newTransactionDetail.isNotZero()) {
|
||||||
|
throw new InvalidLoanTransactionTypeException("transaction", "capitalizedIncomeAdjustment.cannot.be.adjusted",
|
||||||
|
"Capitalized income adjustment transaction cannot be adjusted");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoanCapitalizedIncomeBalance capitalizedIncomeBalance = loanCapitalizedIncomeBalanceRepository
|
||||||
|
.findBalanceForAdjustment(transactionToAdjust.getId());
|
||||||
|
|
||||||
|
capitalizedIncomeBalance
|
||||||
|
.setAmountAdjustment(capitalizedIncomeBalance.getAmountAdjustment().subtract(transactionToAdjust.getAmount()));
|
||||||
|
capitalizedIncomeBalance
|
||||||
|
.setUnrecognizedAmount(capitalizedIncomeBalance.getUnrecognizedAmount().add(transactionToAdjust.getAmount()));
|
||||||
|
}
|
||||||
|
|
||||||
LocalDate recalculateFrom = null;
|
LocalDate recalculateFrom = null;
|
||||||
|
|
||||||
if (loan.isInterestBearingAndInterestRecalculationEnabled()) {
|
if (loan.isInterestBearingAndInterestRecalculationEnabled()) {
|
||||||
@@ -173,6 +213,15 @@ public class LoanAdjustmentServiceImpl implements LoanAdjustmentService {
|
|||||||
this.loanTransactionRepository.saveAndFlush(newTransactionDetail);
|
this.loanTransactionRepository.saveAndFlush(newTransactionDetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (capitalizedIncomeAmortizationAdjustmentTransaction != null && capitalizedIncomeAmortizationAdjustmentTransaction.isNotZero()) {
|
||||||
|
LoanTransaction savedCapitalizedIncomeAmortizationAdjustmentTransaction = loanTransactionRepository
|
||||||
|
.saveAndFlush(capitalizedIncomeAmortizationAdjustmentTransaction);
|
||||||
|
loan.addLoanTransaction(savedCapitalizedIncomeAmortizationAdjustmentTransaction);
|
||||||
|
businessEventNotifierService
|
||||||
|
.notifyPostBusinessEvent(new LoanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent(
|
||||||
|
capitalizedIncomeAmortizationAdjustmentTransaction));
|
||||||
|
}
|
||||||
|
|
||||||
loan = saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
|
loan = saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(noteText)) {
|
if (StringUtils.isNotBlank(noteText)) {
|
||||||
@@ -248,10 +297,11 @@ public class LoanAdjustmentServiceImpl implements LoanAdjustmentService {
|
|||||||
|
|
||||||
if (!transactionForAdjustment.isAccrualRelated() && transactionForAdjustment.isNotRepaymentLikeType()
|
if (!transactionForAdjustment.isAccrualRelated() && transactionForAdjustment.isNotRepaymentLikeType()
|
||||||
&& transactionForAdjustment.isNotWaiver() && transactionForAdjustment.isNotCreditBalanceRefund()
|
&& transactionForAdjustment.isNotWaiver() && transactionForAdjustment.isNotCreditBalanceRefund()
|
||||||
&& !transactionForAdjustment.isCapitalizedIncome()) {
|
&& !transactionForAdjustment.isCapitalizedIncome() && !transactionForAdjustment.isCapitalizedIncomeAdjustment()) {
|
||||||
final String errorMessage = "Only (non-reversed) transactions of type repayment, waiver, capitalized income, accrual or credit balance refund can be adjusted.";
|
final String errorMessage = "Only (non-reversed) transactions of type repayment, waiver, accrual, credit balance refund, capitalized income or capitalized income adjustment can be adjusted.";
|
||||||
throw new InvalidLoanTransactionTypeException("transaction",
|
throw new InvalidLoanTransactionTypeException("transaction",
|
||||||
"adjustment.is.only.allowed.to.repayment.or.waiver.or.creditbalancerefund.transactions", errorMessage);
|
"adjustment.is.only.allowed.to.repayment.or.waiver.or.creditbalancerefund.or.capitalizedIncome.or.capitalizedIncomeAdjustment.transactions",
|
||||||
|
errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
loanChargeValidator.validateRepaymentTypeTransactionNotBeforeAChargeRefund(transactionForAdjustment.getLoan(),
|
loanChargeValidator.validateRepaymentTypeTransactionNotBeforeAChargeRefund(transactionForAdjustment.getLoan(),
|
||||||
|
|||||||
@@ -199,4 +199,5 @@
|
|||||||
<include file="parts/0178_add_principal_from_capitalized_income_to_loan_summary.xml" relativeToChangelogFile="true" />
|
<include file="parts/0178_add_principal_from_capitalized_income_to_loan_summary.xml" relativeToChangelogFile="true" />
|
||||||
<include file="parts/0179_add_capitalized_income_adjustment_transaction.xml" relativeToChangelogFile="true" />
|
<include file="parts/0179_add_capitalized_income_adjustment_transaction.xml" relativeToChangelogFile="true" />
|
||||||
<include file="parts/0180_add_version_field_to_loan_transaction.xml" relativeToChangelogFile="true" />
|
<include file="parts/0180_add_version_field_to_loan_transaction.xml" relativeToChangelogFile="true" />
|
||||||
|
<include file="parts/0181_add_capitalized_income_amortization_adjustment_transaction.xml" relativeToChangelogFile="true" />
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
|
||||||
|
<changeSet id="1" author="fineract">
|
||||||
|
<insert tableName="m_external_event_configuration">
|
||||||
|
<column name="type" value="LoanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent"/>
|
||||||
|
<column name="enabled" valueBoolean="false"/>
|
||||||
|
</insert>
|
||||||
|
<insert tableName="r_enum_value">
|
||||||
|
<column name="enum_name" value="transaction_type_enum"/>
|
||||||
|
<column name="enum_id" valueNumeric="39"/>
|
||||||
|
<column name="enum_message_property" value="Capitalized Income Amortization Adjustment"/>
|
||||||
|
<column name="enum_value" value="Capitalized Income Amortization Adjustment"/>
|
||||||
|
<column name="enum_type" valueBoolean="false"/>
|
||||||
|
</insert>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
+4
-2
@@ -107,7 +107,8 @@ public class ExternalEventConfigurationValidationServiceTest {
|
|||||||
"LoanTransactionAccrualActivityPreBusinessEvent", "LoanTransactionInterestRefundPostBusinessEvent",
|
"LoanTransactionAccrualActivityPreBusinessEvent", "LoanTransactionInterestRefundPostBusinessEvent",
|
||||||
"LoanTransactionInterestRefundPreBusinessEvent", "LoanAccrualAdjustmentTransactionBusinessEvent",
|
"LoanTransactionInterestRefundPreBusinessEvent", "LoanAccrualAdjustmentTransactionBusinessEvent",
|
||||||
"LoanCapitalizedIncomeAmortizationTransactionCreatedBusinessEvent",
|
"LoanCapitalizedIncomeAmortizationTransactionCreatedBusinessEvent",
|
||||||
"LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent", "LoanTransactionContractTerminationPostBusinessEvent");
|
"LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent", "LoanTransactionContractTerminationPostBusinessEvent",
|
||||||
|
"LoanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent");
|
||||||
|
|
||||||
List<FineractPlatformTenant> tenants = Arrays
|
List<FineractPlatformTenant> tenants = Arrays
|
||||||
.asList(new FineractPlatformTenant(1L, "default", "Default Tenant", "Europe/Budapest", null));
|
.asList(new FineractPlatformTenant(1L, "default", "Default Tenant", "Europe/Budapest", null));
|
||||||
@@ -195,7 +196,8 @@ public class ExternalEventConfigurationValidationServiceTest {
|
|||||||
"LoanTransactionAccrualActivityPreBusinessEvent", "LoanTransactionInterestRefundPostBusinessEvent",
|
"LoanTransactionAccrualActivityPreBusinessEvent", "LoanTransactionInterestRefundPostBusinessEvent",
|
||||||
"LoanTransactionInterestRefundPreBusinessEvent", "LoanAccrualAdjustmentTransactionBusinessEvent",
|
"LoanTransactionInterestRefundPreBusinessEvent", "LoanAccrualAdjustmentTransactionBusinessEvent",
|
||||||
"LoanCapitalizedIncomeAmortizationTransactionCreatedBusinessEvent",
|
"LoanCapitalizedIncomeAmortizationTransactionCreatedBusinessEvent",
|
||||||
"LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent", "LoanTransactionContractTerminationPostBusinessEvent");
|
"LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent", "LoanTransactionContractTerminationPostBusinessEvent",
|
||||||
|
"LoanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent");
|
||||||
|
|
||||||
List<FineractPlatformTenant> tenants = Arrays
|
List<FineractPlatformTenant> tenants = Arrays
|
||||||
.asList(new FineractPlatformTenant(1L, "default", "Default Tenant", "Europe/Budapest", null));
|
.asList(new FineractPlatformTenant(1L, "default", "Default Tenant", "Europe/Budapest", null));
|
||||||
|
|||||||
+199
@@ -418,4 +418,203 @@ public class LoanCapitalizedIncomeTest extends BaseLoanIntegrationTest {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLoanCapitalizedIncomeReversal() {
|
||||||
|
final AtomicReference<Long> loanIdRef = new AtomicReference<>();
|
||||||
|
final AtomicReference<Long> capitalizedIncomeTransactionIdRef = new AtomicReference<>();
|
||||||
|
|
||||||
|
final PostClientsResponse client = clientHelper.createClient(ClientHelper.defaultClientCreationRequest());
|
||||||
|
|
||||||
|
final PostLoanProductsResponse loanProductsResponse = loanProductHelper
|
||||||
|
.createLoanProduct(create4IProgressive().enableIncomeCapitalization(true)
|
||||||
|
.capitalizedIncomeCalculationType(PostLoanProductsRequest.CapitalizedIncomeCalculationTypeEnum.FLAT)
|
||||||
|
.capitalizedIncomeStrategy(PostLoanProductsRequest.CapitalizedIncomeStrategyEnum.EQUAL_AMORTIZATION)
|
||||||
|
.deferredIncomeLiabilityAccountId(deferredIncomeLiabilityAccount.getAccountID().longValue())
|
||||||
|
.incomeFromCapitalizationAccountId(feeIncomeAccount.getAccountID().longValue())
|
||||||
|
.capitalizedIncomeType(PostLoanProductsRequest.CapitalizedIncomeTypeEnum.FEE));
|
||||||
|
|
||||||
|
runAt("1 January 2024", () -> {
|
||||||
|
Long loanId = applyAndApproveProgressiveLoan(client.getClientId(), loanProductsResponse.getResourceId(), "1 January 2024",
|
||||||
|
500.0, 7.0, 3, null);
|
||||||
|
loanIdRef.set(loanId);
|
||||||
|
|
||||||
|
disburseLoan(loanId, BigDecimal.valueOf(100), "1 January 2024");
|
||||||
|
Long capitalizedIncomeTransactionId = loanTransactionHelper.addCapitalizedIncome(loanId, "1 January 2024", 50.0)
|
||||||
|
.getResourceId();
|
||||||
|
capitalizedIncomeTransactionIdRef.set(capitalizedIncomeTransactionId);
|
||||||
|
});
|
||||||
|
runAt("2 January 2024", () -> {
|
||||||
|
Long loanId = loanIdRef.get();
|
||||||
|
executeInlineCOB(loanId);
|
||||||
|
|
||||||
|
verifyTransactions(loanId, //
|
||||||
|
transaction(100.0, "Disbursement", "01 January 2024"), //
|
||||||
|
transaction(50.0, "Capitalized Income", "01 January 2024"), //
|
||||||
|
transaction(0.55, "Capitalized Income Amortization", "01 January 2024") //
|
||||||
|
);
|
||||||
|
});
|
||||||
|
runAt("3 January 2024", () -> {
|
||||||
|
Long loanId = loanIdRef.get();
|
||||||
|
executeInlineCOB(loanId);
|
||||||
|
|
||||||
|
verifyTransactions(loanId, //
|
||||||
|
transaction(100.0, "Disbursement", "01 January 2024"), //
|
||||||
|
transaction(50.0, "Capitalized Income", "01 January 2024"), //
|
||||||
|
transaction(0.55, "Capitalized Income Amortization", "01 January 2024"), //
|
||||||
|
transaction(0.03, "Accrual", "02 January 2024"), //
|
||||||
|
transaction(0.55, "Capitalized Income Amortization", "02 January 2024") //
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyJournalEntries(loanId, //
|
||||||
|
journalEntry(100, loansReceivableAccount, "DEBIT"), //
|
||||||
|
journalEntry(100, fundSource, "CREDIT"), //
|
||||||
|
journalEntry(50, loansReceivableAccount, "DEBIT"), //
|
||||||
|
journalEntry(50, deferredIncomeLiabilityAccount, "CREDIT"), //
|
||||||
|
journalEntry(0.55, deferredIncomeLiabilityAccount, "DEBIT"), //
|
||||||
|
journalEntry(0.55, feeIncomeAccount, "CREDIT"), //
|
||||||
|
journalEntry(0.03, interestReceivableAccount, "DEBIT"), //
|
||||||
|
journalEntry(0.03, interestIncomeAccount, "CREDIT"), //
|
||||||
|
journalEntry(0.55, deferredIncomeLiabilityAccount, "DEBIT"), //
|
||||||
|
journalEntry(0.55, feeIncomeAccount, "CREDIT") //
|
||||||
|
);
|
||||||
|
|
||||||
|
loanTransactionHelper.reverseLoanTransaction(loanId, capitalizedIncomeTransactionIdRef.get(), "3 January 2024");
|
||||||
|
|
||||||
|
verifyTransactions(loanId, //
|
||||||
|
transaction(100.0, "Disbursement", "01 January 2024"), //
|
||||||
|
transaction(50.0, "Capitalized Income", "01 January 2024"), //
|
||||||
|
transaction(0.55, "Capitalized Income Amortization", "01 January 2024"), //
|
||||||
|
transaction(0.03, "Accrual", "02 January 2024"), //
|
||||||
|
transaction(0.55, "Capitalized Income Amortization", "02 January 2024"), //
|
||||||
|
transaction(1.10, "Capitalized Income Amortization Adjustment", "03 January 2024") //
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyJournalEntries(loanId, //
|
||||||
|
journalEntry(100, loansReceivableAccount, "DEBIT"), //
|
||||||
|
journalEntry(100, fundSource, "CREDIT"), //
|
||||||
|
journalEntry(50, loansReceivableAccount, "DEBIT"), //
|
||||||
|
journalEntry(50, deferredIncomeLiabilityAccount, "CREDIT"), //
|
||||||
|
journalEntry(0.55, deferredIncomeLiabilityAccount, "DEBIT"), //
|
||||||
|
journalEntry(0.55, feeIncomeAccount, "CREDIT"), //
|
||||||
|
journalEntry(0.03, interestReceivableAccount, "DEBIT"), //
|
||||||
|
journalEntry(0.03, interestIncomeAccount, "CREDIT"), //
|
||||||
|
journalEntry(0.55, deferredIncomeLiabilityAccount, "DEBIT"), //
|
||||||
|
journalEntry(0.55, feeIncomeAccount, "CREDIT"), //
|
||||||
|
journalEntry(50, deferredIncomeLiabilityAccount, "DEBIT"), //
|
||||||
|
journalEntry(50, loansReceivableAccount, "CREDIT"), //
|
||||||
|
journalEntry(1.10, feeIncomeAccount, "DEBIT"), //
|
||||||
|
journalEntry(1.10, deferredIncomeLiabilityAccount, "CREDIT") //
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLoanCapitalizedIncomeAdjustmentReversal() {
|
||||||
|
final AtomicReference<Long> loanIdRef = new AtomicReference<>();
|
||||||
|
final AtomicReference<Long> capitalizedIncomeIdRef = new AtomicReference<>();
|
||||||
|
|
||||||
|
final PostClientsResponse client = clientHelper.createClient(ClientHelper.defaultClientCreationRequest());
|
||||||
|
|
||||||
|
final PostLoanProductsResponse loanProductsResponse = loanProductHelper
|
||||||
|
.createLoanProduct(create4IProgressive().enableIncomeCapitalization(true)
|
||||||
|
.capitalizedIncomeCalculationType(PostLoanProductsRequest.CapitalizedIncomeCalculationTypeEnum.FLAT)
|
||||||
|
.capitalizedIncomeStrategy(PostLoanProductsRequest.CapitalizedIncomeStrategyEnum.EQUAL_AMORTIZATION)
|
||||||
|
.deferredIncomeLiabilityAccountId(deferredIncomeLiabilityAccount.getAccountID().longValue())
|
||||||
|
.incomeFromCapitalizationAccountId(feeIncomeAccount.getAccountID().longValue())
|
||||||
|
.capitalizedIncomeType(PostLoanProductsRequest.CapitalizedIncomeTypeEnum.FEE));
|
||||||
|
|
||||||
|
runAt("1 April 2024", () -> {
|
||||||
|
Long loanId = applyAndApproveProgressiveLoan(client.getClientId(), loanProductsResponse.getResourceId(), "1 January 2024",
|
||||||
|
500.0, 7.0, 3, null);
|
||||||
|
loanIdRef.set(loanId);
|
||||||
|
|
||||||
|
disburseLoan(loanId, BigDecimal.valueOf(100), "1 January 2024");
|
||||||
|
PostLoansLoanIdTransactionsResponse capitalizedIncomeResponse = loanTransactionHelper.addCapitalizedIncome(loanId,
|
||||||
|
"1 January 2024", 50.0);
|
||||||
|
capitalizedIncomeIdRef.set(capitalizedIncomeResponse.getResourceId());
|
||||||
|
|
||||||
|
final PostLoansLoanIdTransactionsResponse capitalizedIncomeAdjustmentResponse = loanTransactionHelper
|
||||||
|
.capitalizedIncomeAdjustment(loanId, capitalizedIncomeIdRef.get(), "1 April 2024", 50.0);
|
||||||
|
final Long capitalizedIncomeAdjustmentTransactionId = capitalizedIncomeAdjustmentResponse.getResourceId();
|
||||||
|
|
||||||
|
verifyTransactions(loanId, //
|
||||||
|
transaction(100.0, "Disbursement", "01 January 2024"), //
|
||||||
|
transaction(50.0, "Capitalized Income", "01 January 2024"), //
|
||||||
|
transaction(50.0, "Capitalized Income Adjustment", "01 April 2024") //
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyJournalEntries(loanId, //
|
||||||
|
journalEntry(100, loansReceivableAccount, "DEBIT"), //
|
||||||
|
journalEntry(100, fundSource, "CREDIT"), //
|
||||||
|
journalEntry(50, loansReceivableAccount, "DEBIT"), //
|
||||||
|
journalEntry(50, deferredIncomeLiabilityAccount, "CREDIT"), //
|
||||||
|
journalEntry(50.0, deferredIncomeLiabilityAccount, "DEBIT"), //
|
||||||
|
journalEntry(49.71, loansReceivableAccount, "CREDIT"), //
|
||||||
|
journalEntry(0.29, interestReceivableAccount, "CREDIT") //
|
||||||
|
);
|
||||||
|
|
||||||
|
loanTransactionHelper.reverseLoanTransaction(loanId, capitalizedIncomeAdjustmentTransactionId, "1 April 2024");
|
||||||
|
|
||||||
|
verifyJournalEntries(loanId, //
|
||||||
|
journalEntry(100, loansReceivableAccount, "DEBIT"), //
|
||||||
|
journalEntry(100, fundSource, "CREDIT"), //
|
||||||
|
journalEntry(50, loansReceivableAccount, "DEBIT"), //
|
||||||
|
journalEntry(50, deferredIncomeLiabilityAccount, "CREDIT"), //
|
||||||
|
journalEntry(50.0, deferredIncomeLiabilityAccount, "DEBIT"), //
|
||||||
|
journalEntry(49.71, loansReceivableAccount, "CREDIT"), //
|
||||||
|
journalEntry(0.29, interestReceivableAccount, "CREDIT"), //
|
||||||
|
journalEntry(50.0, deferredIncomeLiabilityAccount, "CREDIT"), //
|
||||||
|
journalEntry(49.71, loansReceivableAccount, "DEBIT"), //
|
||||||
|
journalEntry(0.29, interestReceivableAccount, "DEBIT") //
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLoanCapitalizedIncomeReversalFailsIfAdjustmentExistsForIt() {
|
||||||
|
final AtomicReference<Long> loanIdRef = new AtomicReference<>();
|
||||||
|
final AtomicReference<Long> capitalizedIncomeTransactionIdRef = new AtomicReference<>();
|
||||||
|
|
||||||
|
final PostClientsResponse client = clientHelper.createClient(ClientHelper.defaultClientCreationRequest());
|
||||||
|
|
||||||
|
final PostLoanProductsResponse loanProductsResponse = loanProductHelper
|
||||||
|
.createLoanProduct(create4IProgressive().enableIncomeCapitalization(true)
|
||||||
|
.capitalizedIncomeCalculationType(PostLoanProductsRequest.CapitalizedIncomeCalculationTypeEnum.FLAT)
|
||||||
|
.capitalizedIncomeStrategy(PostLoanProductsRequest.CapitalizedIncomeStrategyEnum.EQUAL_AMORTIZATION)
|
||||||
|
.deferredIncomeLiabilityAccountId(deferredIncomeLiabilityAccount.getAccountID().longValue())
|
||||||
|
.incomeFromCapitalizationAccountId(feeIncomeAccount.getAccountID().longValue())
|
||||||
|
.capitalizedIncomeType(PostLoanProductsRequest.CapitalizedIncomeTypeEnum.FEE));
|
||||||
|
|
||||||
|
runAt("1 January 2024", () -> {
|
||||||
|
Long loanId = applyAndApproveProgressiveLoan(client.getClientId(), loanProductsResponse.getResourceId(), "1 January 2024",
|
||||||
|
500.0, 7.0, 3, null);
|
||||||
|
loanIdRef.set(loanId);
|
||||||
|
|
||||||
|
disburseLoan(loanId, BigDecimal.valueOf(100), "1 January 2024");
|
||||||
|
Long capitalizedIncomeTransactionId = loanTransactionHelper.addCapitalizedIncome(loanId, "1 January 2024", 50.0)
|
||||||
|
.getResourceId();
|
||||||
|
capitalizedIncomeTransactionIdRef.set(capitalizedIncomeTransactionId);
|
||||||
|
});
|
||||||
|
runAt("2 January 2024", () -> {
|
||||||
|
Long loanId = loanIdRef.get();
|
||||||
|
executeInlineCOB(loanId);
|
||||||
|
|
||||||
|
verifyTransactions(loanId, //
|
||||||
|
transaction(100.0, "Disbursement", "01 January 2024"), //
|
||||||
|
transaction(50.0, "Capitalized Income", "01 January 2024"), //
|
||||||
|
transaction(0.55, "Capitalized Income Amortization", "01 January 2024") //
|
||||||
|
);
|
||||||
|
});
|
||||||
|
runAt("3 January 2024", () -> {
|
||||||
|
Long loanId = loanIdRef.get();
|
||||||
|
executeInlineCOB(loanId);
|
||||||
|
|
||||||
|
loanTransactionHelper.capitalizedIncomeAdjustment(loanId, capitalizedIncomeTransactionIdRef.get(), "3 January 2024", 40.0);
|
||||||
|
|
||||||
|
Assertions.assertThrows(RuntimeException.class, () -> {
|
||||||
|
loanTransactionHelper.reverseLoanTransaction(loanId, capitalizedIncomeTransactionIdRef.get(), "3 January 2024");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -600,6 +600,12 @@ public class ExternalEventConfigurationHelper {
|
|||||||
loanTransactionContractTerminationPostBusinessEvent.put("enabled", false);
|
loanTransactionContractTerminationPostBusinessEvent.put("enabled", false);
|
||||||
defaults.add(loanTransactionContractTerminationPostBusinessEvent);
|
defaults.add(loanTransactionContractTerminationPostBusinessEvent);
|
||||||
|
|
||||||
|
Map<String, Object> loanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent = new HashMap<>();
|
||||||
|
loanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent.put("type",
|
||||||
|
"LoanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent");
|
||||||
|
loanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent.put("enabled", false);
|
||||||
|
defaults.add(loanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent);
|
||||||
|
|
||||||
return defaults;
|
return defaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user