Skip to content

Commit 4c2929a

Browse files
committed
FINERACT-2455: Working Capital - Delinquency Management - Configuration
1 parent 5364ddb commit 4c2929a

39 files changed

Lines changed: 866 additions & 12 deletions

File tree

fineract-accounting/src/main/resources/jpa/static-weaving/module/fineract-accounting/persistence.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<class>org.apache.fineract.portfolio.calendar.domain.Calendar</class>
4949
<class>org.apache.fineract.portfolio.calendar.domain.CalendarHistory</class>
5050
<class>org.apache.fineract.portfolio.client.domain.ClientIdentifier</class>
51+
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyMinimumPaymentPeriodAndRule</class>
5152
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyBucket</class>
5253
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyRange</class>
5354
<class>org.apache.fineract.portfolio.group.domain.StaffAssignmentHistory</class>

fineract-branch/src/main/resources/jpa/static-weaving/module/fineract-branch/persistence.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<class>org.apache.fineract.portfolio.calendar.domain.Calendar</class>
4949
<class>org.apache.fineract.portfolio.calendar.domain.CalendarHistory</class>
5050
<class>org.apache.fineract.portfolio.client.domain.ClientIdentifier</class>
51+
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyMinimumPaymentPeriodAndRule</class>
5152
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyBucket</class>
5253
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyRange</class>
5354
<class>org.apache.fineract.portfolio.group.domain.StaffAssignmentHistory</class>

fineract-charge/src/main/resources/jpa/static-weaving/module/fineract-charge/persistence.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<class>org.apache.fineract.portfolio.calendar.domain.Calendar</class>
4949
<class>org.apache.fineract.portfolio.calendar.domain.CalendarHistory</class>
5050
<class>org.apache.fineract.portfolio.client.domain.ClientIdentifier</class>
51+
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyMinimumPaymentPeriodAndRule</class>
5152
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyBucket</class>
5253
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyRange</class>
5354
<class>org.apache.fineract.portfolio.group.domain.StaffAssignmentHistory</class>

fineract-cob/src/main/resources/jpa/static-weaving/module/fineract-cob/persistence.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<class>org.apache.fineract.portfolio.calendar.domain.Calendar</class>
4848
<class>org.apache.fineract.portfolio.calendar.domain.CalendarHistory</class>
4949
<class>org.apache.fineract.portfolio.client.domain.ClientIdentifier</class>
50+
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyMinimumPaymentPeriodAndRule</class>
5051
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyBucket</class>
5152
<class>org.apache.fineract.portfolio.delinquency.domain.DelinquencyRange</class>
5253
<class>org.apache.fineract.portfolio.group.domain.StaffAssignmentHistory</class>

fineract-core/src/main/java/org/apache/fineract/portfolio/delinquency/domain/DelinquencyBucket.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
*/
1919
package org.apache.fineract.portfolio.delinquency.domain;
2020

21+
import jakarta.persistence.CascadeType;
2122
import jakarta.persistence.Column;
2223
import jakarta.persistence.Entity;
24+
import jakarta.persistence.Enumerated;
2325
import jakarta.persistence.FetchType;
2426
import jakarta.persistence.JoinColumn;
2527
import jakarta.persistence.JoinTable;
2628
import jakarta.persistence.ManyToMany;
29+
import jakarta.persistence.OneToOne;
2730
import jakarta.persistence.Table;
2831
import jakarta.persistence.UniqueConstraint;
2932
import jakarta.persistence.Version;
@@ -48,6 +51,13 @@ public class DelinquencyBucket extends AbstractAuditableWithUTCDateTimeCustom<Lo
4851
@JoinTable(name = "m_delinquency_bucket_mappings", joinColumns = @JoinColumn(name = "delinquency_bucket_id"), inverseJoinColumns = @JoinColumn(name = "delinquency_range_id"))
4952
private List<DelinquencyRange> ranges;
5053

54+
@OneToOne(mappedBy = "bucket", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
55+
private DelinquencyMinimumPaymentPeriodAndRule minimumPaymentPeriodAndRule;
56+
57+
@Enumerated
58+
@Column(name = "bucket_type")
59+
private DelinquencyBucketType bucketType;
60+
5161
@Version
5262
private Long version;
5363

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.fineract.portfolio.delinquency.domain;
21+
22+
import java.util.Arrays;
23+
import lombok.Getter;
24+
25+
public enum DelinquencyBucketType {
26+
27+
REGULAR(1L, "bucketType.regular"), //
28+
WORKING_CAPITAL(2L, "bucketType.workingCapital");
29+
30+
@Getter
31+
private final Long value;
32+
33+
@Getter
34+
private final String code;
35+
36+
DelinquencyBucketType(Long value, String code) {
37+
this.value = value;
38+
this.code = code;
39+
}
40+
41+
public static DelinquencyBucketType fromLong(Long value) {
42+
if (value == null) {
43+
return null;
44+
}
45+
return Arrays.stream(DelinquencyBucketType.values()).filter(v -> v.getValue().equals(value)).findAny().orElse(REGULAR);
46+
}
47+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.fineract.portfolio.delinquency.domain;
21+
22+
import jakarta.persistence.AttributeConverter;
23+
import jakarta.persistence.Converter;
24+
import java.util.Optional;
25+
26+
@Converter(autoApply = true)
27+
public class DelinquencyBucketTypeConverter implements AttributeConverter<DelinquencyBucketType, Long> {
28+
29+
@Override
30+
public Long convertToDatabaseColumn(DelinquencyBucketType delinquencyBucketType) {
31+
return Optional.ofNullable(delinquencyBucketType).map(DelinquencyBucketType::getValue).orElse(null);
32+
}
33+
34+
@Override
35+
public DelinquencyBucketType convertToEntityAttribute(Long aLong) {
36+
return DelinquencyBucketType.fromLong(aLong);
37+
}
38+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.fineract.portfolio.delinquency.domain;
21+
22+
import java.util.Arrays;
23+
import lombok.Getter;
24+
25+
public enum DelinquencyFrequencyType {
26+
27+
DAYS(0, "delinquencyFrequencyType.days"), //
28+
WEEKS(1, "delinquencyFrequencyType.weeks"), //
29+
MONTHS(2, "delinquencyFrequencyType.months"), //
30+
YEARS(3, "delinquencyFrequencyType.years");
31+
32+
@Getter
33+
private final Integer value;
34+
@Getter
35+
private final String code;
36+
37+
DelinquencyFrequencyType(final Integer value, final String code) {
38+
this.value = value;
39+
this.code = code;
40+
}
41+
42+
public static DelinquencyFrequencyType fromInt(final Integer v) {
43+
if (v == null) {
44+
return null;
45+
}
46+
return Arrays.stream(values()).filter(e -> e.getValue().equals(v)).findAny()
47+
.orElseThrow(() -> new IllegalArgumentException("Invalid value of DelinquencyFrequencyType: " + v));
48+
}
49+
50+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.fineract.portfolio.delinquency.domain;
21+
22+
import jakarta.persistence.AttributeConverter;
23+
import jakarta.persistence.Converter;
24+
import java.util.Optional;
25+
26+
@Converter(autoApply = true)
27+
public class DelinquencyFrequencyTypeConverter implements AttributeConverter<DelinquencyFrequencyType, Integer> {
28+
29+
@Override
30+
public Integer convertToDatabaseColumn(DelinquencyFrequencyType delinquencyFrequencyType) {
31+
return Optional.ofNullable(delinquencyFrequencyType).map(DelinquencyFrequencyType::getValue).orElse(null);
32+
}
33+
34+
@Override
35+
public DelinquencyFrequencyType convertToEntityAttribute(Integer intValue) {
36+
return DelinquencyFrequencyType.fromInt(intValue);
37+
38+
}
39+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.fineract.portfolio.delinquency.domain;
20+
21+
import java.util.Arrays;
22+
import lombok.Getter;
23+
24+
public enum DelinquencyMinimumPayment {
25+
26+
PERCENTAGE(1L, "delinquencyMinimumPayment.percentage"), //
27+
FLAT(2L, "delinquencyMinimumPayment.flat");
28+
29+
@Getter
30+
private final Long value;
31+
@Getter
32+
private final String code;
33+
34+
DelinquencyMinimumPayment(Long value, String code) {
35+
this.value = value;
36+
this.code = code;
37+
}
38+
39+
public static DelinquencyMinimumPayment fromLong(Long value) {
40+
if (value == null) {
41+
return null;
42+
}
43+
return Arrays.stream(DelinquencyMinimumPayment.values()).filter(v -> v.getValue().equals(value)).findAny().orElse(null);
44+
}
45+
}

0 commit comments

Comments
 (0)