forked from apache/fineract
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FINERACT-1992-FINERACT-Installment-level-delinquency-calculation
- Loading branch information
Showing
14 changed files
with
827 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
.../db/changelog/tenant/module/loan/parts/1009_refactor_loan_Installment_delinquency_tag.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 author="fineract" id="1"> | ||
<renameTable oldTableName="m_loan_installment_delinquency_tag_history" newTableName="m_loan_installment_delinquency_tag"/> | ||
</changeSet> | ||
<changeSet author="fineract" id="2"> | ||
<dropForeignKeyConstraint baseTableName="m_loan_installment_delinquency_tag" constraintName="FK_m_delinquency_installment_tags_installment" /> | ||
</changeSet> | ||
</databaseChangeLog> |
39 changes: 39 additions & 0 deletions
39
...ava/org/apache/fineract/portfolio/delinquency/data/LoanInstallmentDelinquencyTagData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* 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.delinquency.data; | ||
|
||
import java.math.BigDecimal; | ||
|
||
public interface LoanInstallmentDelinquencyTagData { | ||
|
||
InstallmentDelinquencyRange getDelinquencyRange(); | ||
|
||
BigDecimal getOutstandingAmount(); | ||
|
||
interface InstallmentDelinquencyRange { | ||
|
||
Long getId(); | ||
|
||
String getClassification(); | ||
|
||
Integer getMinimumAgeDays(); | ||
|
||
Integer getMaximumAgeDays(); | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
.../java/org/apache/fineract/portfolio/delinquency/domain/LoanInstallmentDelinquencyTag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* 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.delinquency.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.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom; | ||
import org.apache.fineract.portfolio.loanaccount.domain.Loan; | ||
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@Entity | ||
@Table(name = "m_loan_installment_delinquency_tag") | ||
public class LoanInstallmentDelinquencyTag extends AbstractAuditableWithUTCDateTimeCustom { | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "delinquency_range_id", nullable = false) | ||
private DelinquencyRange delinquencyRange; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "loan_id", nullable = false) | ||
private Loan loan; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "installment_id", nullable = false) | ||
private LoanRepaymentScheduleInstallment installment; | ||
|
||
@Column(name = "addedon_date", nullable = false) | ||
private LocalDate addedOnDate; | ||
|
||
@Column(name = "liftedon_date", nullable = true) | ||
private LocalDate liftedOnDate; | ||
|
||
@Column(name = "first_overdue_date", nullable = false) | ||
private LocalDate firstOverdueDate; | ||
|
||
@Column(name = "outstanding_amount", scale = 6, precision = 19) | ||
private BigDecimal outstandingAmount; | ||
|
||
@Version | ||
private Long version; | ||
|
||
public LoanInstallmentDelinquencyTag(DelinquencyRange delinquencyRange, Loan loan, LoanRepaymentScheduleInstallment installment, | ||
LocalDate addedOnDate, LocalDate liftedOnDate, LocalDate firstOverdueDate, BigDecimal outstandingAmount) { | ||
this.delinquencyRange = delinquencyRange; | ||
this.loan = loan; | ||
this.installment = installment; | ||
this.addedOnDate = addedOnDate; | ||
this.liftedOnDate = liftedOnDate; | ||
this.firstOverdueDate = firstOverdueDate; | ||
this.outstandingAmount = outstandingAmount; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...apache/fineract/portfolio/delinquency/domain/LoanInstallmentDelinquencyTagRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* 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.delinquency.domain; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import org.apache.fineract.portfolio.delinquency.data.LoanInstallmentDelinquencyTagData; | ||
import org.apache.fineract.portfolio.loanaccount.domain.Loan; | ||
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface LoanInstallmentDelinquencyTagRepository | ||
extends JpaRepository<LoanInstallmentDelinquencyTag, Long>, JpaSpecificationExecutor<LoanInstallmentDelinquencyTag> { | ||
|
||
Optional<LoanInstallmentDelinquencyTag> findByLoanAndInstallment(Loan loan, LoanRepaymentScheduleInstallment installment); | ||
|
||
@Query("select i from LoanInstallmentDelinquencyTag i where i.loan.id = :loanId") | ||
List<LoanInstallmentDelinquencyTag> findByLoanId(@Param("loanId") Long loanId); | ||
|
||
// Fetching Installment Delinquency range and outstanding amount | ||
@Query("select i.delinquencyRange, i.outstandingAmount from LoanInstallmentDelinquencyTag i where i.loan.id = :loanId") | ||
List<LoanInstallmentDelinquencyTagData> findInstallmentDelinquencyTags(@Param("loanId") Long loanId); | ||
|
||
@Modifying(flushAutomatically = true) | ||
@Query("delete from LoanInstallmentDelinquencyTag i where i.loan.id = :loanId") | ||
void deleteAllLoanInstallmentsTags(@Param("loanId") Long loanId); | ||
|
||
@Modifying(flushAutomatically = true) | ||
@Query("delete from LoanInstallmentDelinquencyTag i where i.id IN :tagIds") | ||
void deleteAllLoanInstallmentsTagsByIds(@Param("tagIds") List<Long> tagIds); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.