This is an automated email from the ASF dual-hosted git repository.

arnold pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new 3bb90a898 FINERACT-1992: Paused delinquency actions persistence
3bb90a898 is described below

commit 3bb90a898762ae477b80564bd4591aba14b0cc6d
Author: Ruchi Dhamankar <[email protected]>
AuthorDate: Tue Oct 31 13:01:43 2023 +0530

    FINERACT-1992: Paused delinquency actions persistence
---
 .../tenant/module/loan/module-changelog-master.xml |  1 +
 .../parts/1011_add_delinquency_actions_table.xml   | 80 ++++++++++++++++++++++
 .../delinquency/domain/DelinquencyAction.java      | 23 +++++++
 .../delinquency/domain/LoanDelinquencyAction.java  | 62 +++++++++++++++++
 .../domain/LoanDelinquencyActionRepository.java    | 38 ++++++++++
 5 files changed, 204 insertions(+)

diff --git 
a/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/module-changelog-master.xml
 
b/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/module-changelog-master.xml
index 5104d0784..fa3e74c5e 100644
--- 
a/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/module-changelog-master.xml
+++ 
b/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/module-changelog-master.xml
@@ -33,4 +33,5 @@
   <include relativeToChangelogFile="true" 
file="parts/1008_add_loan_installment_delinquency_tag.xml"/>
   <include relativeToChangelogFile="true" 
file="parts/1009_refactor_loan_Installment_delinquency_tag.xml"/>
   <include relativeToChangelogFile="true" 
file="parts/1010_introduce_loan_schedule_type_configuration.xml"/>
+  <include relativeToChangelogFile="true" 
file="parts/1011_add_delinquency_actions_table.xml"/>
 </databaseChangeLog>
diff --git 
a/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/parts/1011_add_delinquency_actions_table.xml
 
b/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/parts/1011_add_delinquency_actions_table.xml
new file mode 100644
index 000000000..2a86c4093
--- /dev/null
+++ 
b/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/parts/1011_add_delinquency_actions_table.xml
@@ -0,0 +1,80 @@
+<?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">
+        <createTable tableName="m_loan_delinquency_action">
+            <column autoIncrement="true" name="id" type="BIGINT">
+                <constraints nullable="false" primaryKey="true"/>
+            </column>
+            <column name="loan_id" type="BIGINT">
+                <constraints nullable="false" />
+            </column>
+            <column name="action" type="VARCHAR(128)">
+                <constraints nullable="false"/>
+            </column>
+            <column name="start_date" type="date">
+                <constraints nullable="false"/>
+            </column>
+            <column name="end_date" type="date"/>
+            <column name="created_by" type="BIGINT">
+                <constraints nullable="false" />
+            </column>
+            <column name="last_modified_by" type="BIGINT">
+                <constraints nullable="false" />
+            </column>
+        </createTable>
+    </changeSet>
+    <changeSet id="2" author="fineract" context="mysql">
+        <addColumn tableName="m_loan_delinquency_action">
+            <column name="created_on_utc" type="DATETIME(6)">
+                <constraints nullable="false"/>
+            </column>
+            <column name="last_modified_on_utc" type="DATETIME(6)">
+                <constraints nullable="false"/>
+            </column>
+        </addColumn>
+    </changeSet>
+    <changeSet id="3" author="fineract" context="postgresql">
+        <addColumn tableName="m_loan_delinquency_action">
+            <column name="created_on_utc" type="TIMESTAMP WITH TIME ZONE">
+                <constraints nullable="false"/>
+            </column>
+            <column name="last_modified_on_utc" type="TIMESTAMP WITH TIME 
ZONE">
+                <constraints nullable="false"/>
+            </column>
+        </addColumn>
+    </changeSet>
+    <changeSet id="4" author="fineract">
+        <addForeignKeyConstraint baseColumnNames="loan_id" 
baseTableName="m_loan_delinquency_action"
+                                 
constraintName="FK_m_loan_delinquency_action_loan" deferrable="false"
+                                 initiallyDeferred="false" onDelete="RESTRICT" 
onUpdate="RESTRICT"
+                                 referencedColumnNames="id" 
referencedTableName="m_loan" validate="true"/>
+
+    </changeSet>
+    <changeSet id="5" author="fineract">
+        <createIndex tableName="m_loan_delinquency_action" 
indexName="m_loan_delinquency_action_loan_id_index">
+            <column name="loan_id"/>
+        </createIndex>
+    </changeSet>
+</databaseChangeLog>
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/domain/DelinquencyAction.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/domain/DelinquencyAction.java
new file mode 100644
index 000000000..978e6edfe
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/domain/DelinquencyAction.java
@@ -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.portfolio.delinquency.domain;
+
+public enum DelinquencyAction {
+    PAUSE, RESUME
+}
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/domain/LoanDelinquencyAction.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/domain/LoanDelinquencyAction.java
new file mode 100644
index 000000000..fed9b5c8e
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/domain/LoanDelinquencyAction.java
@@ -0,0 +1,62 @@
+/**
+ * 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.EnumType;
+import jakarta.persistence.Enumerated;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.Table;
+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;
+
+@Getter
+@Setter
+@NoArgsConstructor
+@Entity
+@Table(name = "m_loan_delinquency_action")
+public class LoanDelinquencyAction extends 
AbstractAuditableWithUTCDateTimeCustom {
+
+    @ManyToOne
+    @JoinColumn(name = "loan_id", nullable = false)
+    private Loan loan;
+
+    @Enumerated(EnumType.STRING)
+    @Column(name = "action", nullable = false)
+    private DelinquencyAction action;
+
+    @Column(name = "start_date", nullable = false)
+    private LocalDate startDate;
+
+    @Column(name = "end_date", nullable = true)
+    private LocalDate endDate;
+
+    public LoanDelinquencyAction(Loan loan, DelinquencyAction action, 
LocalDate startDate, LocalDate endDate) {
+        this.loan = loan;
+        this.action = action;
+        this.startDate = startDate;
+        this.endDate = endDate;
+    }
+}
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/domain/LoanDelinquencyActionRepository.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/domain/LoanDelinquencyActionRepository.java
new file mode 100644
index 000000000..d8bef639e
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/domain/LoanDelinquencyActionRepository.java
@@ -0,0 +1,38 @@
+/**
+ * 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.time.LocalDate;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+
+public interface LoanDelinquencyActionRepository
+        extends JpaRepository<LoanDelinquencyAction, Long>, 
JpaSpecificationExecutor<LoanDelinquencyAction> {
+
+    @Query(value = "select da from LoanDelinquencyAction da where "
+            + "    ((da.action = 
org.apache.fineract.portfolio.delinquency.domain.DelinquencyAction.PAUSE and 
da.endDate is not null and :business_date >= da.startDate and :business_date <= 
da.endDate) or"
+            + "    (da.action = 
org.apache.fineract.portfolio.delinquency.domain.DelinquencyAction.RESUME and 
da.endDate is null and :business_date >= da.startDate)) and"
+            + "    da.loan.id = :loan_id  order by da.createdDate desc")
+    Page<LoanDelinquencyAction> 
getEffectiveDelinquencyActionForLoan(@Param("loan_id") Long loan_id,
+            @Param("business_date") LocalDate business_date, Pageable page);
+}

Reply via email to