FINERACT-1661 Allow merchant_issued and payout refunds when fullyPaid/Overpaid

This commit is contained in:
John Woodlock
2022-07-08 14:44:45 +02:00
committed by Arnold Gálovics
parent 2bb92ae539
commit 0487bece0b
3 changed files with 60 additions and 11 deletions
@@ -3098,7 +3098,7 @@ public class Loan extends AbstractPersistableCustom {
if (!isHolidayValidationDone) {
holidayDetailDTO = scheduleGeneratorDTO.getHolidayDetailDTO();
}
validateAccountStatus(event);
validateRepaymentTypeAccountStatus(repaymentTransaction, event);
validateActivityNotBeforeClientOrGroupTransferDate(event, repaymentTransaction.getTransactionDate());
validateActivityNotBeforeLastTransactionDate(event, repaymentTransaction.getTransactionDate());
if (!isHolidayValidationDone) {
@@ -3116,6 +3116,24 @@ public class Loan extends AbstractPersistableCustom {
return changedTransactionDetail;
}
private void validateRepaymentTypeAccountStatus(LoanTransaction repaymentTransaction, LoanEvent event) {
if (repaymentTransaction.isGoodwillCredit() || repaymentTransaction.isMerchantIssuedRefund()
|| repaymentTransaction.isPayoutRefund()) {
if (!(isOpen() || isClosedObligationsMet() || isOverPaid())) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final String defaultUserMessage = "Loan must be Active, Fully Paid or Overpaid";
final ApiParameterError error = ApiParameterError.generalError("error.msg.loan.must.be.active.fully.paid.or.overpaid",
defaultUserMessage);
dataValidationErrors.add(error);
throw new PlatformApiDataValidationException(dataValidationErrors);
}
} else {
validateAccountStatus(event);
}
}
public void makeChargePayment(final Long chargeId, final LoanLifecycleStateMachine loanLifecycleStateMachine,
final List<Long> existingTransactionIds, final List<Long> existingReversedTransactionIds,
final HolidayDetailDTO holidayDetailDTO, final LoanTransaction paymentTransaction, final Integer installmentNumber) {