FINERACT-2418: Extend disbursal and reage events with changed terms flag

This commit is contained in:
Oleksii Novikov
2026-02-18 09:27:59 +00:00
committed by Adam Saghy
parent 136a966fc3
commit 1feb1d730f
17 changed files with 279 additions and 18 deletions
@@ -28,6 +28,10 @@ public class LoanDisbursalTransactionBusinessEvent extends LoanTransactionBusine
super(value);
}
public LoanDisbursalTransactionBusinessEvent(final LoanTransaction value, final LoanTransactionFlagsData flags) {
super(value, flags);
}
@Override
public String getType() {
return TYPE;
@@ -18,15 +18,24 @@
*/
package org.apache.fineract.infrastructure.event.business.domain.loan.transaction;
import lombok.Getter;
import org.apache.fineract.infrastructure.event.business.domain.AbstractBusinessEvent;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
@Getter
public abstract class LoanTransactionBusinessEvent extends AbstractBusinessEvent<LoanTransaction> {
private static final String CATEGORY = "Loan";
private final LoanTransactionFlagsData flags;
public LoanTransactionBusinessEvent(LoanTransaction value) {
this(value, null);
}
public LoanTransactionBusinessEvent(LoanTransaction value, LoanTransactionFlagsData flags) {
super(value);
this.flags = flags;
}
@Override
@@ -0,0 +1,23 @@
/**
* 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;
public record LoanTransactionFlagsData(boolean changedTerms) {
}
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.event.business.domain.loan.transaction.reaging;
import org.apache.fineract.infrastructure.event.business.domain.loan.transaction.LoanTransactionBusinessEvent;
import org.apache.fineract.infrastructure.event.business.domain.loan.transaction.LoanTransactionFlagsData;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
public class LoanReAgeTransactionBusinessEvent extends LoanTransactionBusinessEvent {
@@ -29,6 +30,10 @@ public class LoanReAgeTransactionBusinessEvent extends LoanTransactionBusinessEv
super(value);
}
public LoanReAgeTransactionBusinessEvent(LoanTransaction value, LoanTransactionFlagsData flags) {
super(value, flags);
}
@Override
public String getType() {
return TYPE;
@@ -1836,19 +1836,12 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom<Long> {
return false;
}
public boolean hasChargeOffTransaction() {
return getLoanTransactions().stream().anyMatch(LoanTransaction::isChargeOff);
}
public boolean hasAccelerateChargeOffStrategy() {
return LoanChargeOffBehaviour.ACCELERATE_MATURITY.equals(getLoanProductRelatedDetail().getChargeOffBehaviour());
}
public boolean hasContractTerminationTransaction() {
return getLoanTransactions().stream().anyMatch(t -> t.isContractTermination() && t.isNotReversed());
}
public boolean hasReAgingTransaction() {
return getLoanTransactions().stream().anyMatch(t -> t.isReAge() && t.isNotReversed());
public long getTermsCount() {
return getRepaymentScheduleInstallments().stream().filter(i -> !i.isDownPayment() && !i.isAdditional()).count();
}
}