FINERACT-2279: Contract Termination - Undo

This commit is contained in:
mariiaKraievska
2025-06-18 16:19:33 +02:00
committed by Adam Saghy
parent 11cecb0d45
commit ee29ce23ac
23 changed files with 412 additions and 3 deletions
@@ -0,0 +1,35 @@
/**
* 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 LoanUndoContractTerminationBusinessEvent extends LoanTransactionBusinessEvent {
private static final String TYPE = "LoanUndoContractTerminationBusinessEvent";
public LoanUndoContractTerminationBusinessEvent(LoanTransaction value) {
super(value);
}
@Override
public String getType() {
return TYPE;
}
}
@@ -180,6 +180,7 @@ public interface LoanApiConstants {
String CAPITALIZED_INCOME_TRANSACTION_COMMAND = "capitalizedIncome";
String CAPITALIZED_INCOME_ADJUSTMENT_TRANSACTION_COMMAND = "capitalizedIncomeAdjustment";
String CONTRACT_TERMINATION_COMMAND = "contractTermination";
String UNDO_CONTRACT_TERMINATION_COMMAND = "undoContractTermination";
// Data Validator names
String LOAN_FRAUD_DATAVALIDATOR_PREFIX = "loans.fraud";
@@ -71,6 +71,7 @@ public class LoanTransactionEnumData implements Serializable {
private final boolean capitalizedIncomeAmortization;
private final boolean capitalizedIncomeAdjustment;
private final boolean capitalizedIncomeAmortizationAdjustment;
private final boolean contractTermination;
public LoanTransactionEnumData(final Long id, final String code, final String value) {
this.id = id;
@@ -112,6 +113,7 @@ public class LoanTransactionEnumData implements Serializable {
this.capitalizedIncomeAdjustment = Long.valueOf(LoanTransactionType.CAPITALIZED_INCOME_ADJUSTMENT.getValue()).equals(this.id);
this.capitalizedIncomeAmortizationAdjustment = Long
.valueOf(LoanTransactionType.CAPITALIZED_INCOME_AMORTIZATION_ADJUSTMENT.getValue()).equals(this.id);
this.contractTermination = Long.valueOf(LoanTransactionType.CONTRACT_TERMINATION.getValue()).equals(this.id);
}
public boolean isRepaymentType() {
@@ -1789,6 +1789,10 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom<Long> {
return getLoanTransaction(e -> e.isNotReversed() && e.isChargeOff());
}
public LoanTransaction findContractTerminationTransaction() {
return getLoanTransaction(e -> e.isNotReversed() && e.isContractTermination());
}
public void handleMaturityDateActivate() {
if (this.expectedMaturityDate != null && !this.expectedMaturityDate.equals(this.actualMaturityDate)) {
this.actualMaturityDate = this.expectedMaturityDate;
@@ -92,4 +92,6 @@ public interface LoanTransactionValidator {
void validateNote(DataValidatorBuilder baseDataValidator, JsonElement element);
void validateExternalId(DataValidatorBuilder baseDataValidator, JsonElement element);
void validateReversalExternalId(DataValidatorBuilder baseDataValidator, JsonElement element);
}
@@ -52,4 +52,5 @@
<include relativeToChangelogFile="true" file="parts/1027_add_capitalized_income_transaction_type.xml"/>
<include relativeToChangelogFile="true" file="parts/1028_add_missing_indexes.xml"/>
<include relativeToChangelogFile="true" file="parts/1029_add_installment_amount_in_multiples_of_to_loan.xml"/>
<include relativeToChangelogFile="true" file="parts/1030_add_loan_undo_contract_termination_event.xml"/>
</databaseChangeLog>
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
<changeSet id="1" author="fineract">
<insert tableName="m_external_event_configuration">
<column name="type" value="LoanUndoContractTerminationBusinessEvent"/>
<column name="enabled" valueBoolean="false"/>
</insert>
</changeSet>
</databaseChangeLog>