FINERACT-2311: Add buy down fee balance entity and db table, create balance on transaction

This commit is contained in:
mark.vituska
2025-07-04 14:23:28 +02:00
committed by Adam Saghy
parent 71e763115e
commit 4feee70a7a
7 changed files with 230 additions and 2 deletions
@@ -88,6 +88,7 @@ import org.apache.fineract.portfolio.loanaccount.mapper.LoanChargeMapper;
import org.apache.fineract.portfolio.loanaccount.mapper.LoanCollateralManagementMapper;
import org.apache.fineract.portfolio.loanaccount.mapper.LoanMapper;
import org.apache.fineract.portfolio.loanaccount.mapper.LoanTransactionMapper;
import org.apache.fineract.portfolio.loanaccount.repository.LoanBuyDownFeesBalanceRepository;
import org.apache.fineract.portfolio.loanaccount.repository.LoanCapitalizedIncomeBalanceRepository;
import org.apache.fineract.portfolio.loanaccount.rescheduleloan.domain.LoanTermVariationsRepository;
import org.apache.fineract.portfolio.loanaccount.serialization.LoanApplicationTransitionValidator;
@@ -381,9 +382,11 @@ public class LoanAccountConfiguration {
public BuyDownFeePlatformService buyDownFeePlatformService(ProgressiveLoanTransactionValidator loanTransactionValidator,
LoanAssembler loanAssembler, LoanTransactionRepository loanTransactionRepository,
PaymentDetailWritePlatformService paymentDetailWritePlatformService, LoanJournalEntryPoster loanJournalEntryPoster,
NoteWritePlatformService noteWritePlatformService, ExternalIdFactory externalIdFactory) {
NoteWritePlatformService noteWritePlatformService, ExternalIdFactory externalIdFactory,
LoanBuyDownFeesBalanceRepository loanBuyDownFeesBalanceRepository) {
return new BuyDownFeeWritePlatformServiceImpl(loanTransactionValidator, loanAssembler, loanTransactionRepository,
paymentDetailWritePlatformService, loanJournalEntryPoster, noteWritePlatformService, externalIdFactory);
paymentDetailWritePlatformService, loanJournalEntryPoster, noteWritePlatformService, externalIdFactory,
loanBuyDownFeesBalanceRepository);
}
@Bean
@@ -206,4 +206,5 @@
<include file="parts/0185_loan_buy_down_fee.xml" relativeToChangelogFile="true" />
<include file="parts/0186_add_buy_down_fee_to_loan_product.xml" relativeToChangelogFile="true" />
<include file="parts/0187_add_Loan_modified_and_withdrawn_event_configuration.xml" relativeToChangelogFile="true" />
<include file="parts/0188_create_loan_buy_down_fee_balance.xml" relativeToChangelogFile="true" />
</databaseChangeLog>
@@ -0,0 +1,117 @@
<?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.3.xsd">
<changeSet author="fineract" id="1" context="postgresql">
<createTable tableName="m_loan_buy_down_fee_balance">
<column autoIncrement="true" name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true" primaryKeyName="pk_m_loan_buy_down_fee_balance"/>
</column>
<column name="version" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="loan_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="loan_transaction_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="amount" type="DECIMAL(19, 6)">
<constraints nullable="false"/>
</column>
<column name="date" type="DATE">
<constraints nullable="false"/>
</column>
<column name="unrecognized_amount" type="DECIMAL(19, 6)">
<constraints nullable="false"/>
</column>
<column name="charged_off_amount" type="DECIMAL(19, 6)" />
<column name="amount_adjustment" type="DECIMAL(19, 6)" />
<column name="created_by" type="BIGINT"/>
<column name="created_on_utc" type="timestamp with time zone"/>
<column name="last_modified_by" type="BIGINT"/>
<column name="last_modified_on_utc" type="timestamp with time zone"/>
</createTable>
</changeSet>
<changeSet author="fineract" id="2" context="mysql">
<createTable tableName="m_loan_buy_down_fee_balance">
<column autoIncrement="true" name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true" primaryKeyName="pk_m_loan_buy_down_fee_balance"/>
</column>
<column name="version" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="loan_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="loan_transaction_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="amount" type="DECIMAL(19, 6)">
<constraints nullable="false"/>
</column>
<column name="date" type="DATE">
<constraints nullable="false"/>
</column>
<column name="unrecognized_amount" type="DECIMAL(19, 6)">
<constraints nullable="false"/>
</column>
<column name="charged_off_amount" type="DECIMAL(19, 6)" />
<column name="amount_adjustment" type="DECIMAL(19, 6)" />
<column name="created_by" type="BIGINT"/>
<column name="created_on_utc" type="DATETIME"/>
<column name="last_modified_by" type="BIGINT"/>
<column name="last_modified_on_utc" type="DATETIME"/>
</createTable>
</changeSet>
<changeSet author="fineract" id="3">
<addForeignKeyConstraint baseColumnNames="created_by" baseTableName="m_loan_buy_down_fee_balance"
constraintName="FK_loan_buy_down_fees_balance_created_by" deferrable="false" initiallyDeferred="false"
onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id"
referencedTableName="m_appuser" validate="true"/>
<addForeignKeyConstraint baseColumnNames="last_modified_by" baseTableName="m_loan_buy_down_fee_balance"
constraintName="FK_loan_buy_down_fees_balance_last_modified_by" deferrable="false" initiallyDeferred="false"
onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id"
referencedTableName="m_appuser" validate="true"/>
<addForeignKeyConstraint baseColumnNames="loan_id" baseTableName="m_loan_buy_down_fee_balance"
constraintName="FK_loan_buy_down_fees_balance_loan_id" deferrable="false" initiallyDeferred="false"
onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id"
referencedTableName="m_loan" validate="true"/>
<addForeignKeyConstraint baseColumnNames="loan_transaction_id" baseTableName="m_loan_buy_down_fee_balance"
constraintName="FK_loan_buy_down_fees_balance_transaction_id" deferrable="false" initiallyDeferred="false"
onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id"
referencedTableName="m_loan_transaction" validate="true"/>
</changeSet>
<changeSet author="fineract" id="4" runInTransaction="false" context="postgresql">
<sql>
create unique index concurrently if not exists m_loan_buy_down_fee_balance_idx_1 on m_loan_buy_down_fee_balance(loan_id,loan_transaction_id);
create index concurrently if not exists m_loan_buy_down_fee_balance_idx_2 on m_loan_buy_down_fee_balance(loan_id);
</sql>
</changeSet>
<changeSet author="fineract" id="5" context="mysql">
<sql>
create unique index m_loan_buy_down_fee_balance_idx_1 on m_loan_buy_down_fee_balance(loan_id,loan_transaction_id);
create index m_loan_buy_down_fee_balance_idx_2 on m_loan_buy_down_fee_balance(loan_id);
</sql>
</changeSet>
</databaseChangeLog>