FINERACT-2325: Disable automatic Interest Refund calculation
This commit is contained in:
committed by
Adam Saghy
parent
e2f481f351
commit
aad7756bf5
+6
-4
@@ -25,6 +25,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -871,7 +872,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
|
||||
@Override
|
||||
public Pair<LoanTransaction, LoanTransaction> makeRefund(final Loan loan, final ScheduleGeneratorDTO scheduleGeneratorDTO,
|
||||
final LoanTransactionType loanTransactionType, final LocalDate transactionDate, final BigDecimal transactionAmount,
|
||||
final PaymentDetail paymentDetail, final ExternalId txnExternalId) {
|
||||
final PaymentDetail paymentDetail, final ExternalId txnExternalId, final Boolean interestRefundCalculationOverride) {
|
||||
// Pre-processing business event
|
||||
switch (loanTransactionType) {
|
||||
case MERCHANT_ISSUED_REFUND ->
|
||||
@@ -887,9 +888,10 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
|
||||
final boolean isTransactionChronologicallyLatest = loanTransactionService.isChronologicallyLatestRepaymentOrWaiver(loan,
|
||||
refundTransaction);
|
||||
|
||||
boolean shouldCreateInterestRefundTransaction = loan.getLoanProductRelatedDetail().getSupportedInterestRefundTypes().stream()
|
||||
.map(LoanSupportedInterestRefundTypes::getTransactionType)
|
||||
.anyMatch(transactionType -> transactionType.equals(loanTransactionType));
|
||||
final boolean shouldCreateInterestRefundTransaction = Objects.requireNonNullElseGet(interestRefundCalculationOverride,
|
||||
() -> loan.getLoanProductRelatedDetail().getSupportedInterestRefundTypes().stream()
|
||||
.map(LoanSupportedInterestRefundTypes::getTransactionType)
|
||||
.anyMatch(transactionType -> transactionType.equals(loanTransactionType)));
|
||||
LoanTransaction interestRefundTransaction = null;
|
||||
|
||||
if (shouldCreateInterestRefundTransaction) {
|
||||
|
||||
+3
-3
@@ -948,9 +948,9 @@ public final class LoanTransactionValidatorImpl implements LoanTransactionValida
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Set<String> transactionParameters = new HashSet<>(
|
||||
Arrays.asList("transactionDate", "transactionAmount", "externalId", "note", "locale", "dateFormat", "paymentTypeId",
|
||||
"accountNumber", "checkNumber", "routingCode", "receiptNumber", "bankNumber", "loanId", "numberOfRepayments"));
|
||||
final Set<String> transactionParameters = new HashSet<>(Arrays.asList("transactionDate", "transactionAmount", "externalId", "note",
|
||||
"locale", "dateFormat", "paymentTypeId", "accountNumber", "checkNumber", "routingCode", "receiptNumber", "bankNumber",
|
||||
"loanId", "numberOfRepayments", "interestRefundCalculation"));
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, transactionParameters);
|
||||
|
||||
+2
-1
@@ -2957,8 +2957,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
final List<Long> existingTransactionIds = loanTransactionRepository.findTransactionIdsByLoan(loan);
|
||||
final List<Long> existingReversedTransactionIds = loanTransactionRepository.findReversedTransactionIdsByLoan(loan);
|
||||
// Create refund transaction(s)
|
||||
final Boolean interestRefundCalculation = command.booleanObjectValueOfParameterNamed("interestRefundCalculation");
|
||||
Pair<LoanTransaction, LoanTransaction> refundTransactions = loanAccountDomainService.makeRefund(loan, scheduleGeneratorDTO,
|
||||
loanTransactionType, transactionDate, transactionAmount, paymentDetail, txnExternalId);
|
||||
loanTransactionType, transactionDate, transactionAmount, paymentDetail, txnExternalId, interestRefundCalculation);
|
||||
LoanTransaction refundTransaction = refundTransactions.getLeft();
|
||||
LoanTransaction interestRefundTransaction = refundTransactions.getRight();
|
||||
// Accrual reprocessing
|
||||
|
||||
Reference in New Issue
Block a user