From 69f535731fe5abcf3a0f7b998ad15f1d5932e801 Mon Sep 17 00:00:00 2001 From: Arnold Galovics Date: Tue, 20 Sep 2022 21:02:25 +0200 Subject: [PATCH] FINERACT-1734: Added a new DisbursalTransactionBusinessEvent for disbursement txes --- ...LoanDisbursalTransactionBusinessEvent.java | 33 +++++++++++++++++++ ...WritePlatformServiceJpaRepositoryImpl.java | 7 +++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 fineract-provider/src/main/java/org/apache/fineract/infrastructure/event/business/domain/loan/transaction/LoanDisbursalTransactionBusinessEvent.java diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/event/business/domain/loan/transaction/LoanDisbursalTransactionBusinessEvent.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/event/business/domain/loan/transaction/LoanDisbursalTransactionBusinessEvent.java new file mode 100644 index 000000000..9d5814b74 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/event/business/domain/loan/transaction/LoanDisbursalTransactionBusinessEvent.java @@ -0,0 +1,33 @@ +/** + * 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 LoanDisbursalTransactionBusinessEvent extends LoanTransactionBusinessEvent { + + public LoanDisbursalTransactionBusinessEvent(LoanTransaction value) { + super(value); + } + + @Override + public String getType() { + return "LoanDisbursalTransactionBusinessEvent"; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java index 4ed29ed93..58ff84cbb 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java @@ -78,6 +78,7 @@ import org.apache.fineract.infrastructure.event.business.domain.loan.charge.Loan import org.apache.fineract.infrastructure.event.business.domain.loan.charge.LoanWaiveChargeBusinessEvent; import org.apache.fineract.infrastructure.event.business.domain.loan.charge.LoanWaiveChargeUndoBusinessEvent; import org.apache.fineract.infrastructure.event.business.domain.loan.transaction.LoanChargeRefundBusinessEvent; +import org.apache.fineract.infrastructure.event.business.domain.loan.transaction.LoanDisbursalTransactionBusinessEvent; import org.apache.fineract.infrastructure.event.business.domain.loan.transaction.LoanUndoWrittenOffBusinessEvent; import org.apache.fineract.infrastructure.event.business.domain.loan.transaction.LoanWaiveInterestBusinessEvent; import org.apache.fineract.infrastructure.event.business.domain.loan.transaction.LoanWrittenOffPostBusinessEvent; @@ -539,7 +540,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf // During a disbursement, the entityId should be the disbursement transaction id if (!isAccountTransfer) { - entityId = loan.getLoanTransactions().get(loan.getLoanTransactions().size() - 1).getId(); + LoanTransaction disbursalTransaction = loan.getLoanTransactions().get(loan.getLoanTransactions().size() - 1); + entityId = disbursalTransaction.getId(); + businessEventNotifierService.notifyPostBusinessEvent(new LoanDisbursalTransactionBusinessEvent(disbursalTransaction)); } return new CommandProcessingResultBuilder() // @@ -730,6 +733,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf actualDisbursementDate, txnExternalId); disbursementTransaction.updateLoan(loan); loan.addLoanTransaction(disbursementTransaction); + businessEventNotifierService + .notifyPostBusinessEvent(new LoanDisbursalTransactionBusinessEvent(disbursementTransaction)); } LocalDate recalculateFrom = null; final ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom);