From 269c2b1f28bbb54bf0d48d8b4e00613df45906f5 Mon Sep 17 00:00:00 2001 From: "adam.magyari" Date: Tue, 15 Apr 2025 10:20:36 +0200 Subject: [PATCH] FINERACT-2232: Create LoanCapitalizedIncomeBalance entity and table --- .../domain/LoanCapitalizedIncomeBalance.java | 64 ++++++++++ ...oanCapitalizedIncomeBalanceRepository.java | 31 +++++ .../db/changelog/tenant/changelog-tenant.xml | 1 + ...create_loan_capitalized_income_balance.xml | 117 ++++++++++++++++++ 4 files changed, 213 insertions(+) create mode 100644 fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCapitalizedIncomeBalance.java create mode 100644 fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCapitalizedIncomeBalanceRepository.java create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0172_create_loan_capitalized_income_balance.xml diff --git a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCapitalizedIncomeBalance.java b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCapitalizedIncomeBalance.java new file mode 100644 index 000000000..5e8b2c128 --- /dev/null +++ b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCapitalizedIncomeBalance.java @@ -0,0 +1,64 @@ +/** + * 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.portfolio.loanaccount.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.persistence.Version; +import java.math.BigDecimal; +import java.time.LocalDate; +import lombok.Getter; +import lombok.Setter; +import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom; + +@Entity +@Table(name = "m_loan_capitalized_income_balance") +@Getter +@Setter +public class LoanCapitalizedIncomeBalance extends AbstractAuditableWithUTCDateTimeCustom { + + @Version + private Long version; + + @ManyToOne + @JoinColumn(name = "loan_id", nullable = false) + private Loan loan; + + @ManyToOne + @JoinColumn(name = "loan_transaction_id", nullable = false) + private LoanTransaction loanTransaction; + + @Column(name = "amount", scale = 6, precision = 19, nullable = false) + private BigDecimal amount; + + @Column(name = "date", nullable = false) + private LocalDate date; + + @Column(name = "unrecognized_amount", scale = 6, precision = 19, nullable = false) + private BigDecimal unrecognizedAmount; + + @Column(name = "charged_off_amount", scale = 6, precision = 19) + private BigDecimal chargedOffAmount; + + @Column(name = "amount_adjustment", scale = 6, precision = 19) + private BigDecimal amountAdjustment; +} diff --git a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCapitalizedIncomeBalanceRepository.java b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCapitalizedIncomeBalanceRepository.java new file mode 100644 index 000000000..f0d84fa65 --- /dev/null +++ b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCapitalizedIncomeBalanceRepository.java @@ -0,0 +1,31 @@ +/** + * 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.portfolio.loanaccount.domain; + +import java.util.List; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +public interface LoanCapitalizedIncomeBalanceRepository + extends JpaRepository, JpaSpecificationExecutor { + + List findAllByLoanId(Long loanId); + + LoanCapitalizedIncomeBalance findByLoanIdAndLoanTransactionId(Long loanId, Long transactionId); +} diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml index 09a9f0e42..80abde2c2 100644 --- a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml +++ b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml @@ -190,4 +190,5 @@ + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0172_create_loan_capitalized_income_balance.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0172_create_loan_capitalized_income_balance.xml new file mode 100644 index 000000000..f305e0c53 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0172_create_loan_capitalized_income_balance.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + create unique index concurrently if not exists m_loan_capitalized_income_balance_idx_1 on m_loan_capitalized_income_balance(loan_id,loan_transaction_id); + create index concurrently if not exists m_loan_capitalized_income_balance_idx_2 on m_loan_capitalized_income_balance(loan_id); + + + + + create unique index m_loan_capitalized_income_balance_idx_1 on m_loan_capitalized_income_balance(loan_id,loan_transaction_id); + create index m_loan_capitalized_income_balance_idx_2 on m_loan_capitalized_income_balance(loan_id); + + +