FINERACT-1992: Paused delinquency actions persistence

This commit is contained in:
Ruchi Dhamankar
2023-10-31 13:48:14 +01:00
committed by Arnold Gálovics
parent 5ebeca0f2d
commit 3bb90a8987
5 changed files with 204 additions and 0 deletions
@@ -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
}
@@ -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;
}
}
@@ -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);
}