Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<class>org.apache.fineract.portfolio.calendar.domain.Calendar</class>
<class>org.apache.fineract.portfolio.calendar.domain.CalendarHistory</class>
<class>org.apache.fineract.portfolio.client.domain.ClientIdentifier</class>
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyMinimumPaymentPeriodAndRule</class>
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyBucket</class>
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyRange</class>
<class>org.apache.fineract.portfolio.group.domain.StaffAssignmentHistory</class>
Expand Down Expand Up @@ -86,6 +87,7 @@
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.weaving" value="static" />
<property name="eclipselink.weaving.internal" value="false"/>
</properties>
</persistence-unit>
</persistence>
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<class>org.apache.fineract.portfolio.calendar.domain.Calendar</class>
<class>org.apache.fineract.portfolio.calendar.domain.CalendarHistory</class>
<class>org.apache.fineract.portfolio.client.domain.ClientIdentifier</class>
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyMinimumPaymentPeriodAndRule</class>
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyBucket</class>
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyRange</class>
<class>org.apache.fineract.portfolio.group.domain.StaffAssignmentHistory</class>
Expand Down Expand Up @@ -93,6 +94,7 @@
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.weaving" value="static" />
<property name="eclipselink.weaving.internal" value="false"/>
</properties>
</persistence-unit>
</persistence>
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<class>org.apache.fineract.portfolio.calendar.domain.Calendar</class>
<class>org.apache.fineract.portfolio.calendar.domain.CalendarHistory</class>
<class>org.apache.fineract.portfolio.client.domain.ClientIdentifier</class>
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyMinimumPaymentPeriodAndRule</class>
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyBucket</class>
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyRange</class>
<class>org.apache.fineract.portfolio.group.domain.StaffAssignmentHistory</class>
Expand Down Expand Up @@ -86,6 +87,7 @@
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.weaving" value="static" />
<property name="eclipselink.weaving.internal" value="false"/>
</properties>
</persistence-unit>
</persistence>
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import jakarta.persistence.PrePersist;
import jakarta.persistence.Transient;
import jakarta.persistence.Version;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.OffsetDateTime;
Expand All @@ -38,47 +39,41 @@
import org.springframework.data.domain.Persistable;

@Getter
@Setter
@MappedSuperclass
@NoArgsConstructor
public abstract class AccountLock implements Persistable<Long>, Serializable {

protected static final long serialVersionUID = 2272591907035824317L;
@Serial
private static final long serialVersionUID = 1L;

@Id
@Getter
@Column(name = "loan_id", nullable = false)
protected Long loanId;
private Long loanId;

@Version
@Getter
@Column(name = "version")
protected Long version;
private Long version;

@Enumerated(EnumType.STRING)
@Getter
@Column(name = "lock_owner", nullable = false)
protected LockOwner lockOwner;
private LockOwner lockOwner;

@Column(name = "lock_placed_on", nullable = false)
@Getter
protected OffsetDateTime lockPlacedOn;
private OffsetDateTime lockPlacedOn;

@Column(name = "error")
@Getter
protected String error;
private String error;

@Column(name = "stacktrace")
@Getter
protected String stacktrace;
private String stacktrace;

@Column(name = "lock_placed_on_cob_business_date")
@Getter
protected LocalDate lockPlacedOnCobBusinessDate;
private LocalDate lockPlacedOnCobBusinessDate;

@Transient
@Setter(value = AccessLevel.NONE)
@Getter
protected boolean isNew = true;
private boolean isNew = true;

@PrePersist
@PostLoad
Expand All @@ -88,7 +83,7 @@ void markNotNew() {

@Override
public Long getId() {
return getLoanId();
return loanId;
}

public AccountLock(Long loanId, LockOwner lockOwner, LocalDate lockPlacedOnCobBusinessDate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ public LinkedBlockingQueue<Long> filterRemainingData(@NonNull StepExecution step
private List<Long> getLoanIdsLockedWithChunkProcessingLock(List<Long> loanIds) {
List<T> accountLocks = new ArrayList<>(
loanLockingService.findAllByLoanIdInAndLockOwner(loanIds, LockOwner.LOAN_COB_CHUNK_PROCESSING));
return accountLocks.stream().map(T::getLoanId).toList();
return accountLocks.stream().map(T::getId).toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public RepeatStatus execute(@NonNull StepContribution contribution, @NonNull Chu
loanIdPartitions.forEach(loanIdPartition -> accountLocks.addAll(loanLockingService.findAllByLoanIdIn(loanIdPartition)));

List<Long> toBeProcessedLoanIds = new ArrayList<>(loanIds);
List<Long> alreadyLockedAccountIds = accountLocks.stream().map(AccountLock::getLoanId).toList();
List<Long> alreadyLockedAccountIds = accountLocks.stream().map(AccountLock::getId).toList();

toBeProcessedLoanIds.removeAll(alreadyLockedAccountIds);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<class>org.apache.fineract.portfolio.calendar.domain.Calendar</class>
<class>org.apache.fineract.portfolio.calendar.domain.CalendarHistory</class>
<class>org.apache.fineract.portfolio.client.domain.ClientIdentifier</class>
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyMinimumPaymentPeriodAndRule</class>
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyBucket</class>
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyRange</class>
<class>org.apache.fineract.portfolio.group.domain.StaffAssignmentHistory</class>
Expand All @@ -65,10 +66,12 @@
<class>org.apache.fineract.infrastructure.codes.domain.CodeValue</class>

<!-- COB Module Entities -->

<class>org.apache.fineract.cob.domain.AccountLock</class>
<class>org.apache.fineract.cob.domain.BatchBusinessStep</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.weaving" value="static" />
<property name="eclipselink.weaving.internal" value="false"/>
</properties>
</persistence-unit>
</persistence>
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,8 @@ public <T extends Enum<T>> T enumValueOfParameterNamed(String parameterName, fin
"Enum value not exists: ", enumType.getName(), value)), e);
}
}

public Integer extractIntegerNamed(String paramName, JsonObject element) {
return extractIntegerNamed(paramName, element, new HashSet<>());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
*/
package org.apache.fineract.portfolio.delinquency.domain;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
Expand All @@ -48,6 +52,13 @@ public class DelinquencyBucket extends AbstractAuditableWithUTCDateTimeCustom<Lo
@JoinTable(name = "m_delinquency_bucket_mappings", joinColumns = @JoinColumn(name = "delinquency_bucket_id"), inverseJoinColumns = @JoinColumn(name = "delinquency_range_id"))
private List<DelinquencyRange> ranges;

@OneToOne(mappedBy = "bucket", cascade = CascadeType.ALL, orphanRemoval = true)
private DelinquencyMinimumPaymentPeriodAndRule minimumPaymentPeriodAndRule;

@Enumerated(EnumType.STRING)
@Column(name = "bucket_type")
private DelinquencyBucketType bucketType;

@Version
private Long version;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* 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.Arrays;
import java.util.List;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.data.StringEnumOptionData;

@Getter
@RequiredArgsConstructor
public enum DelinquencyBucketType {

REGULAR(1L, "bucketType.regular", "Reqular Loan Product"), //
WORKING_CAPITAL(2L, "bucketType.workingCapital", "Working Capital Loan Product");

private final Long id;
private final String code;
private final String description;

public static List<StringEnumOptionData> toStringEnumOptions() {
return Arrays.stream(values()).map(DelinquencyBucketType::toData).toList();
}

public StringEnumOptionData toData() {
return new StringEnumOptionData(name(), getCode(), getDescription());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* 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.Arrays;
import java.util.List;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.data.StringEnumOptionData;

@Getter
@RequiredArgsConstructor
public enum DelinquencyFrequencyType {

DAYS(0L, "delinquencyFrequencyType.days", "Days frequency"), //
WEEKS(1L, "delinquencyFrequencyType.weeks", "Week frequency"), //
MONTHS(2L, "delinquencyFrequencyType.months", "Month frequency"), //
YEARS(3L, "delinquencyFrequencyType.years", "Year frequency");

private final Long id;
private final String code;
private final String description;

public static List<StringEnumOptionData> toStringEnumOptions() {
return Arrays.stream(values()).map(DelinquencyFrequencyType::toData).toList();
}

public StringEnumOptionData toData() {
return new StringEnumOptionData(name(), getCode(), getDescription());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* 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.OneToOne;
import jakarta.persistence.Table;
import java.io.Serial;
import java.math.BigDecimal;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;

@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "m_delinquency_payment_rule")
public class DelinquencyMinimumPaymentPeriodAndRule extends AbstractAuditableWithUTCDateTimeCustom<Long> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we store the following values: frequency, frequency type, minimum payment type
My question: where do we store the actual value of minimum payment? Like the amount and not the type of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Ther is a minimumPaymentType and a minimumPayment for its value


@Serial
private static final long serialVersionUID = -9204385885041120403L;

@OneToOne
@JoinColumn(name = "bucket_id", nullable = false, unique = true)
private DelinquencyBucket bucket;

@Column(name = "frequency", nullable = false)
private Integer frequency;

@Enumerated(EnumType.STRING)
@Column(name = "frequency_type", nullable = false)
private DelinquencyFrequencyType frequencyType;

@Column(name = "minimum_payment", scale = 6, precision = 19, nullable = false)
private BigDecimal minimumPayment;

@Enumerated(EnumType.STRING)
@Column(name = "minimum_payment_type", nullable = false)
private DelinquencyMinimumPaymentType minimumPaymentType;
}
Loading
Loading