FINERACT-1724

- Fixing the order of disbursement and downpayment transactions
This commit is contained in:
Peter Bagrij
2023-10-24 13:06:49 +02:00
committed by Arnold Gálovics
parent 7370dfdc73
commit f72f578d4b
2 changed files with 7 additions and 6 deletions
@@ -436,6 +436,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
actualDisbursementDate, txnExternalId); actualDisbursementDate, txnExternalId);
disbursementTransaction.updateLoan(loan); disbursementTransaction.updateLoan(loan);
loan.addLoanTransaction(disbursementTransaction); loan.addLoanTransaction(disbursementTransaction);
LoanTransaction savedLoanTransaction = loanTransactionRepository.saveAndFlush(disbursementTransaction);
} }
if (loan.getRepaymentScheduleInstallments().isEmpty()) { if (loan.getRepaymentScheduleInstallments().isEmpty()) {
/* /*
@@ -460,8 +461,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
businessEventNotifierService.notifyPreBusinessEvent(new LoanTransactionDownPaymentPreBusinessEvent(loan)); businessEventNotifierService.notifyPreBusinessEvent(new LoanTransactionDownPaymentPreBusinessEvent(loan));
LoanTransaction downPaymentTransaction = loan.handleDownPayment(amountToDisburse.getAmount(), command, LoanTransaction downPaymentTransaction = loan.handleDownPayment(amountToDisburse.getAmount(), command,
scheduleGeneratorDTO); scheduleGeneratorDTO);
businessEventNotifierService LoanTransaction savedLoanTransaction = loanTransactionRepository.saveAndFlush(downPaymentTransaction);
.notifyPostBusinessEvent(new LoanTransactionDownPaymentPostBusinessEvent(downPaymentTransaction)); businessEventNotifierService.notifyPostBusinessEvent(new LoanTransactionDownPaymentPostBusinessEvent(savedLoanTransaction));
businessEventNotifierService.notifyPostBusinessEvent(new LoanBalanceChangedBusinessEvent(loan)); businessEventNotifierService.notifyPostBusinessEvent(new LoanBalanceChangedBusinessEvent(loan));
} }
} }
@@ -128,6 +128,10 @@ import org.slf4j.LoggerFactory;
@ExtendWith(LoanTestLifecycleExtension.class) @ExtendWith(LoanTestLifecycleExtension.class)
public class ClientLoanIntegrationTest { public class ClientLoanIntegrationTest {
static {
Utils.initializeRESTAssured();
}
private static final String MINIMUM_OPENING_BALANCE = "1000.0"; private static final String MINIMUM_OPENING_BALANCE = "1000.0";
private static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; private static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
private static final Logger LOG = LoggerFactory.getLogger(ClientLoanIntegrationTest.class); private static final Logger LOG = LoggerFactory.getLogger(ClientLoanIntegrationTest.class);
@@ -172,10 +176,6 @@ public class ClientLoanIntegrationTest {
private static final ChargesHelper CHARGES_HELPER = new ChargesHelper(); private static final ChargesHelper CHARGES_HELPER = new ChargesHelper();
private static final ClientHelper CLIENT_HELPER = new ClientHelper(REQUEST_SPEC, RESPONSE_SPEC); private static final ClientHelper CLIENT_HELPER = new ClientHelper(REQUEST_SPEC, RESPONSE_SPEC);
static {
Utils.initializeRESTAssured();
}
private static RequestSpecification createRequestSpecification() { private static RequestSpecification createRequestSpecification() {
RequestSpecification request = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); RequestSpecification request = new RequestSpecBuilder().setContentType(ContentType.JSON).build();