FINERACT-1734: Added a new DisbursalTransactionBusinessEvent for disbursement txes

This commit is contained in:
Arnold Galovics
2022-09-22 09:46:11 +02:00
committed by Arnold Gálovics
parent 0f4d232897
commit 69f535731f
2 changed files with 39 additions and 1 deletions
@@ -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";
}
}
@@ -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);