FINERACT-2327: Allow to create Interest Refund transaction manually

This commit is contained in:
mariiaKraievska
2025-07-23 11:32:30 +02:00
committed by Aleksandar Vidakovic
parent 59409550a7
commit c2e19bb68f
22 changed files with 799 additions and 8 deletions
@@ -97,4 +97,7 @@ public interface LoanAccountDomainService {
LoanTransaction applyInterestRefund(Loan loan, LoanRefundRequestData loanRefundRequest);
void updateAndSaveLoanCollateralTransactionsForIndividualAccounts(Loan loan, LoanTransaction transaction);
LoanTransaction createManualInterestRefundWithAmount(Loan loan, LoanTransaction targetTransaction, BigDecimal amount,
PaymentDetail paymentDetail, ExternalId txnExternalId);
}
@@ -195,6 +195,11 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
return new LoanTransaction(loan, loan.getOffice(), LoanTransactionType.INTEREST_REFUND, null, amount, date, externalId);
}
public static LoanTransaction interestRefund(final Loan loan, final BigDecimal amount, final LocalDate date,
final PaymentDetail paymentDetail, final ExternalId externalId) {
return new LoanTransaction(loan, loan.getOffice(), LoanTransactionType.INTEREST_REFUND, paymentDetail, amount, date, externalId);
}
public static LoanTransaction chargeAdjustment(final Loan loan, final BigDecimal amount, final LocalDate transactionDate,
final ExternalId externalId, PaymentDetail paymentDetail) {
return new LoanTransaction(loan, loan.getOffice(), LoanTransactionType.CHARGE_ADJUSTMENT, paymentDetail, amount, transactionDate,
@@ -0,0 +1,42 @@
/**
* 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.portfolio.loanaccount.handler;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.portfolio.loanaccount.service.LoanWritePlatformService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
@CommandType(entity = "LOAN_TRANSACTION", action = "MANUAL_INTEREST_REFUND")
public class ManualInterestRefundCommandHandler implements NewCommandSourceHandler {
private final LoanWritePlatformService loanWritePlatformService;
@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return loanWritePlatformService.makeManualInterestRefund(command.getLoanId(), command.entityId(), command);
}
}
@@ -94,4 +94,6 @@ public interface LoanTransactionValidator {
void validateExternalId(DataValidatorBuilder baseDataValidator, JsonElement element);
void validateReversalExternalId(DataValidatorBuilder baseDataValidator, JsonElement element);
void validateManualInterestRefundTransaction(String json);
}
@@ -155,4 +155,6 @@ public interface LoanReadPlatformService {
List<Long> retrieveLoanIdsByExternalIds(List<ExternalId> externalIds);
boolean existsByLoanId(Long loanId);
LoanTransactionData retrieveManualInterestRefundTemplate(Long loanId, Long targetTransactionId);
}
@@ -125,4 +125,6 @@ public interface LoanWritePlatformService {
CommandProcessingResult undoChargeOff(JsonCommand command);
CommandProcessingResult makeRefund(Long loanId, LoanTransactionType loanTransactionType, JsonCommand command);
CommandProcessingResult makeManualInterestRefund(Long loanId, Long transactionId, JsonCommand command);
}