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

adamsaghy 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 07122fd10 FINERACT-1968: Advanced repayment allocation strategy - data 
model - [x] m_loan_product_payment_allocation_rule table created - [x] 
m_loan_payment_allocation_rule table created - [x] 
LoanProductPaymentAllocationRule entity - [x] LoanPaymentAllocationRule entity 
- [x] List of enum converter to String converter to use `AllocationType` list
07122fd10 is described below

commit 07122fd10ae838f5edc6bd96888ae30d98310b10
Author: Janos Haber <[email protected]>
AuthorDate: Thu Aug 10 19:25:47 2023 +0200

    FINERACT-1968: Advanced repayment allocation strategy - data model
    - [x] m_loan_product_payment_allocation_rule table created
    - [x] m_loan_payment_allocation_rule table created
    - [x] LoanProductPaymentAllocationRule entity
    - [x] LoanPaymentAllocationRule entity
    - [x] List of enum converter to String converter to use `AllocationType` 
list
---
 .../core/data/GenericEnumListConverter.java        |  66 ++++++++++
 .../domain/LoanPaymentAllocationRule.java          |  66 ++++++++++
 .../loanproduct/domain/AllocationType.java         |  26 ++++
 .../domain/AllocationTypeListConverter.java        |  36 ++++++
 .../portfolio/loanproduct/domain/DueType.java      |  25 ++++
 .../domain/FutureInstallmentAllocationRule.java    |  25 ++++
 .../domain/LoanProductPaymentAllocationRule.java   |  63 +++++++++
 .../domain/PaymentAllocationTransactionType.java   |  33 +++++
 .../loanproduct/domain/PaymentAllocationType.java  |  52 ++++++++
 .../tenant/module/loan/module-changelog-master.xml |   1 +
 .../parts/1002_add_payment_allocation_rule.xml     | 141 +++++++++++++++++++++
 .../src/main/resources/jpa/persistence.xml         |   8 ++
 12 files changed, 542 insertions(+)

diff --git 
a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/GenericEnumListConverter.java
 
b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/GenericEnumListConverter.java
new file mode 100644
index 000000000..a8f5f99e9
--- /dev/null
+++ 
b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/GenericEnumListConverter.java
@@ -0,0 +1,66 @@
+/**
+ * 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.infrastructure.core.data;
+
+import jakarta.persistence.AttributeConverter;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.commons.lang3.StringUtils;
+
+public abstract class GenericEnumListConverter<E extends Enum<E>> implements 
AttributeConverter<List<E>, String> {
+
+    private static final String SPLIT_CHAR = ",";
+
+    private final Class<E> clazz;
+
+    protected boolean isUnique() {
+        return false;
+    }
+
+    protected GenericEnumListConverter(Class<E> clazz) {
+        this.clazz = clazz;
+    }
+
+    @Override
+    public String convertToDatabaseColumn(List<E> values) {
+        if (values.isEmpty()) {
+            return null;
+        }
+        Stream<E> valueStream;
+        if (isUnique()) {
+            valueStream = values.stream().distinct();
+        } else {
+            valueStream = values.stream();
+        }
+        return 
valueStream.map(Enum::name).collect(Collectors.joining(SPLIT_CHAR));
+    }
+
+    @Override
+    public List<E> convertToEntityAttribute(String string) {
+        if (StringUtils.isBlank(string)) {
+            return List.of();
+        }
+        Stream<E> stream = Stream.of(string.split(SPLIT_CHAR)).map(e -> 
Enum.valueOf(clazz, e));
+        if (isUnique()) {
+            return stream.distinct().toList();
+        }
+        return stream.toList();
+    }
+}
diff --git 
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanPaymentAllocationRule.java
 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanPaymentAllocationRule.java
new file mode 100644
index 000000000..a16b80f50
--- /dev/null
+++ 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanPaymentAllocationRule.java
@@ -0,0 +1,66 @@
+/**
+ * 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.loanaccount.domain;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.ElementCollection;
+import jakarta.persistence.Entity;
+import jakarta.persistence.EnumType;
+import jakarta.persistence.Enumerated;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.Table;
+import jakarta.persistence.UniqueConstraint;
+import java.util.List;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
+import 
org.apache.fineract.portfolio.loanproduct.domain.FutureInstallmentAllocationRule;
+import 
org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationTransactionType;
+import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType;
+
+@Getter
+@Setter
+@Entity
+@Table(name = "m_loan_payment_allocation", uniqueConstraints = {
+        @UniqueConstraint(columnNames = { "loan_id", "transaction_type" }, 
name = "uq_m_loan_payment_allocation_rule") })
+@AllArgsConstructor
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
+public class LoanPaymentAllocationRule extends 
AbstractAuditableWithUTCDateTimeCustom {
+
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "loan_id", nullable = false)
+    private Loan loan;
+
+    @Column(name = "transaction_type", nullable = false)
+    @Enumerated(EnumType.STRING)
+    private PaymentAllocationTransactionType transactionType;
+
+    @ElementCollection(fetch = FetchType.EAGER)
+    @Column(name = "allocation_types", nullable = false)
+    private List<PaymentAllocationType> allocationTypes;
+
+    @Column(name = "future_installment_allocation_rule", nullable = false)
+    @Enumerated(EnumType.STRING)
+    private FutureInstallmentAllocationRule futureInstallmentAllocationRule;
+}
diff --git 
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/AllocationType.java
 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/AllocationType.java
new file mode 100644
index 000000000..af9d894d4
--- /dev/null
+++ 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/AllocationType.java
@@ -0,0 +1,26 @@
+/**
+ * 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.loanproduct.domain;
+
+public enum AllocationType {
+    PENALTY, //
+    FEE, //
+    PRINCIPAL, //
+    INTEREST //
+}
diff --git 
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/AllocationTypeListConverter.java
 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/AllocationTypeListConverter.java
new file mode 100644
index 000000000..580590e01
--- /dev/null
+++ 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/AllocationTypeListConverter.java
@@ -0,0 +1,36 @@
+/**
+ * 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.loanproduct.domain;
+
+import jakarta.persistence.Converter;
+import org.apache.fineract.infrastructure.core.data.GenericEnumListConverter;
+
+@Converter(autoApply = true)
+public class AllocationTypeListConverter extends 
GenericEnumListConverter<PaymentAllocationType> {
+
+    @Override
+    protected boolean isUnique() {
+        return true;
+    }
+
+    protected AllocationTypeListConverter() {
+        super(PaymentAllocationType.class);
+    }
+
+}
diff --git 
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/DueType.java
 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/DueType.java
new file mode 100644
index 000000000..493f6e6e8
--- /dev/null
+++ 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/DueType.java
@@ -0,0 +1,25 @@
+/**
+ * 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.loanproduct.domain;
+
+public enum DueType {
+    PAST_DUE, //
+    DUE, //
+    IN_ADVANCE //
+}
diff --git 
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/FutureInstallmentAllocationRule.java
 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/FutureInstallmentAllocationRule.java
new file mode 100644
index 000000000..3fbe4ab83
--- /dev/null
+++ 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/FutureInstallmentAllocationRule.java
@@ -0,0 +1,25 @@
+/**
+ * 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.loanproduct.domain;
+
+public enum FutureInstallmentAllocationRule {
+    NEXT_INSTALLMENT, //
+    LAST_INSTALLMENT, //
+    REAMORTIZATION //
+}
diff --git 
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductPaymentAllocationRule.java
 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductPaymentAllocationRule.java
new file mode 100644
index 000000000..7a33f0973
--- /dev/null
+++ 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductPaymentAllocationRule.java
@@ -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.loanproduct.domain;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.ElementCollection;
+import jakarta.persistence.Entity;
+import jakarta.persistence.EnumType;
+import jakarta.persistence.Enumerated;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.Table;
+import jakarta.persistence.UniqueConstraint;
+import java.util.List;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import 
org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
+
+@Getter
+@Setter
+@Entity
+@Table(name = "m_loan_product_payment_allocation", uniqueConstraints = {
+        @UniqueConstraint(columnNames = { "loan_product_id", 
"transaction_type" }, name = "uq_m_loan_product_payment_allocation_rule") })
+@AllArgsConstructor
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
+public class LoanProductPaymentAllocationRule extends 
AbstractAuditableWithUTCDateTimeCustom {
+
+    @ManyToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "loan_product_id", nullable = false)
+    private LoanProduct loanProduct;
+
+    @Column(name = "transaction_type", nullable = false)
+    @Enumerated(EnumType.STRING)
+    private PaymentAllocationTransactionType transactionType;
+
+    @ElementCollection(fetch = FetchType.EAGER)
+    @Column(name = "allocation_types", nullable = false)
+    private List<PaymentAllocationType> allocationTypes;
+
+    @Enumerated(EnumType.STRING)
+    @Column(name = "future_installment_allocation_rule", nullable = false)
+    private FutureInstallmentAllocationRule futureInstallmentAllocationRule;
+}
diff --git 
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/PaymentAllocationTransactionType.java
 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/PaymentAllocationTransactionType.java
new file mode 100644
index 000000000..ba0493a53
--- /dev/null
+++ 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/PaymentAllocationTransactionType.java
@@ -0,0 +1,33 @@
+/**
+ * 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.loanproduct.domain;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType;
+
+@Getter
+@RequiredArgsConstructor
+public enum PaymentAllocationTransactionType {
+
+    DEFAULT(null), //
+    REPAYMENT(LoanTransactionType.REPAYMENT); //
+
+    private final LoanTransactionType loanTransactionType;
+}
diff --git 
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/PaymentAllocationType.java
 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/PaymentAllocationType.java
new file mode 100644
index 000000000..2ddca9dbb
--- /dev/null
+++ 
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/PaymentAllocationType.java
@@ -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.loanproduct.domain;
+
+import static 
org.apache.fineract.portfolio.loanproduct.domain.AllocationType.FEE;
+import static 
org.apache.fineract.portfolio.loanproduct.domain.AllocationType.INTEREST;
+import static 
org.apache.fineract.portfolio.loanproduct.domain.AllocationType.PENALTY;
+import static 
org.apache.fineract.portfolio.loanproduct.domain.AllocationType.PRINCIPAL;
+import static org.apache.fineract.portfolio.loanproduct.domain.DueType.DUE;
+import static 
org.apache.fineract.portfolio.loanproduct.domain.DueType.IN_ADVANCE;
+import static 
org.apache.fineract.portfolio.loanproduct.domain.DueType.PAST_DUE;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+@Getter
+@RequiredArgsConstructor
+public enum PaymentAllocationType {
+
+    PAST_DUE_PENALTY(PAST_DUE, PENALTY), //
+    PAST_DUE_FEE(PAST_DUE, FEE), //
+    PAST_DUE_PRINCIPAL(PAST_DUE, PRINCIPAL), //
+    PAST_DUE_INTEREST(PAST_DUE, INTEREST), //
+    DUE_PENALTY(DUE, PENALTY), //
+    DUE_FEE(DUE, FEE), //
+    DUE_PRINCIPAL(DUE, PRINCIPAL), //
+    DUE_INTEREST(DUE, INTEREST), //
+    IN_ADVANCE_PENALTY(IN_ADVANCE, PENALTY), //
+    IN_ADVANCE_FEE(IN_ADVANCE, FEE), //
+    IN_ADVANCE_PRINCIPAL(IN_ADVANCE, PRINCIPAL), //
+    IN_ADVANCE_INTEREST(IN_ADVANCE, INTEREST); //
+
+    private final DueType dueType;
+    private final AllocationType allocationType;
+
+}
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 77aacf807..ca7acea64 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
@@ -24,4 +24,5 @@
   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog 
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd";>
   <!-- Sequence is starting from 1000 to make it easier to move existing 
liquibase changesets here -->
   <include relativeToChangelogFile="true" 
file="parts/1001_add_audit_fields_to_loan_charge.xml"/>
+  <include relativeToChangelogFile="true" 
file="parts/1002_add_payment_allocation_rule.xml"/>
 </databaseChangeLog>
diff --git 
a/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/parts/1002_add_payment_allocation_rule.xml
 
b/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/parts/1002_add_payment_allocation_rule.xml
new file mode 100644
index 000000000..ae59865f1
--- /dev/null
+++ 
b/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/parts/1002_add_payment_allocation_rule.xml
@@ -0,0 +1,141 @@
+<?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.3.xsd";>
+    <changeSet author="fineract" id="1002-1">
+        <createTable tableName="m_loan_product_payment_allocation_rule">
+            <column autoIncrement="true" name="id" type="BIGINT">
+                <constraints nullable="false" primaryKey="true"/>
+            </column>
+            <column name="loan_product_id" type="BIGINT">
+                <constraints nullable="false" 
foreignKeyName="m_loan_product_payment_allocation_rule_fk" 
referencedTableName="m_product_loan" referencedColumnNames="id"/>
+            </column>
+            <column name="transaction_type" type="VARCHAR(255)">
+                <constraints nullable="false"/>
+            </column>
+            <column name="allocation_types" type="TEXT">
+                <constraints nullable="false"/>
+            </column>
+            <column name="future_installment_allocation_rule" 
type="VARCHAR(255)">
+                <constraints nullable="false"/>
+            </column>
+            <column name="created_by" type="BIGINT">
+                <constraints nullable="false"/>
+            </column>
+            <column name="last_modified_by" type="BIGINT">
+                <constraints nullable="false"/>
+            </column>
+        </createTable>
+        <createTable tableName="m_loan_payment_allocation_rule">
+            <column autoIncrement="true" name="id" type="BIGINT">
+                <constraints nullable="false" primaryKey="true"/>
+            </column>
+            <column name="loan_id" type="BIGINT">
+                <constraints nullable="false" 
foreignKeyName="m_loan_payment_allocation_rule_fk" referencedTableName="m_loan" 
referencedColumnNames="id"/>
+            </column>
+            <column name="transaction_type" type="VARCHAR(255)">
+                <constraints nullable="false"/>
+            </column>
+            <column name="allocation_types" type="TEXT">
+                <constraints nullable="false"/>
+            </column>
+            <column name="future_installment_allocation_rule" 
type="VARCHAR(255)">
+                <constraints nullable="false"/>
+            </column>
+            <column name="created_by" type="BIGINT">
+                <constraints nullable="false"/>
+            </column>
+            <column name="last_modified_by" type="BIGINT">
+                <constraints nullable="false"/>
+            </column>
+        </createTable>
+    </changeSet>
+    <changeSet author="fineract" id="1002-2" context="mysql">
+        <addColumn tableName="m_loan_product_payment_allocation_rule">
+            <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>
+        <addColumn tableName="m_loan_payment_allocation_rule">
+            <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 author="fineract" id="1002-2" context="postgresql">
+        <addColumn tableName="m_loan_product_payment_allocation_rule">
+            <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>
+        <addColumn tableName="m_loan_payment_allocation_rule">
+            <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 author="fineract" id="1002-3">
+        <addUniqueConstraint 
tableName="m_loan_product_payment_allocation_rule" 
columnNames="loan_product_id,transaction_type" 
constraintName="uq_m_loan_product_payment_allocation_rule"/>
+        <addUniqueConstraint tableName="m_loan_payment_allocation_rule" 
columnNames="loan_id,transaction_type" 
constraintName="uq_m_loan_payment_allocation_rule"/>
+    </changeSet>
+    <changeSet author="fineract" id="1002-4">
+        <addForeignKeyConstraint baseColumnNames="created_by" 
baseTableName="m_loan_product_payment_allocation_rule"
+                                 
constraintName="FK_loan_product_payment_allocation_rule_created_by" 
deferrable="false" initiallyDeferred="false"
+                                 onDelete="RESTRICT" onUpdate="RESTRICT" 
referencedColumnNames="id"
+                                 referencedTableName="m_appuser" 
validate="true"/>
+        <addForeignKeyConstraint baseColumnNames="last_modified_by" 
baseTableName="m_loan_product_payment_allocation_rule"
+                                 
constraintName="FK_loan_product_payment_allocation_rule_last_modified_by" 
deferrable="false"
+                                 initiallyDeferred="false"
+                                 onDelete="RESTRICT" onUpdate="RESTRICT" 
referencedColumnNames="id"
+                                 referencedTableName="m_appuser" 
validate="true"/>
+        <addForeignKeyConstraint baseColumnNames="created_by" 
baseTableName="m_loan_payment_allocation_rule"
+                                 
constraintName="FK_loan_payment_allocation_rule_created_by" deferrable="false" 
initiallyDeferred="false"
+                                 onDelete="RESTRICT" onUpdate="RESTRICT" 
referencedColumnNames="id"
+                                 referencedTableName="m_appuser" 
validate="true"/>
+        <addForeignKeyConstraint baseColumnNames="last_modified_by" 
baseTableName="m_loan_payment_allocation_rule"
+                                 
constraintName="FK_loan_payment_allocation_rule_last_modified_by" 
deferrable="false"
+                                 initiallyDeferred="false"
+                                 onDelete="RESTRICT" onUpdate="RESTRICT" 
referencedColumnNames="id"
+                                 referencedTableName="m_appuser" 
validate="true"/>
+    </changeSet>
+    <changeSet id="fineract" author="1002-5">
+        <createIndex tableName="m_loan_product_payment_allocation_rule" 
indexName="IND_loan_product_payment_allocation_rule_loan_product_id">
+            <column name="loan_product_id"/>
+        </createIndex>
+        <createIndex tableName="m_loan_payment_allocation_rule" 
indexName="IND_loan_payment_allocation_rule_loan_id">
+            <column name="loan_id"/>
+        </createIndex>
+    </changeSet>
+</databaseChangeLog>
diff --git a/fineract-provider/src/main/resources/jpa/persistence.xml 
b/fineract-provider/src/main/resources/jpa/persistence.xml
index f901e617d..b1fba72c9 100644
--- a/fineract-provider/src/main/resources/jpa/persistence.xml
+++ b/fineract-provider/src/main/resources/jpa/persistence.xml
@@ -106,6 +106,14 @@
         
<class>org.apache.fineract.portfolio.loanproduct.domain.LoanProductInterestRecalculationDetails</class>
         
<class>org.apache.fineract.portfolio.loanproduct.domain.LoanProductVariableInstallmentConfig</class>
         
<class>org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecks</class>
+        
<class>org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType</class>
+        <class>org.apache.fineract.portfolio.loanproduct.domain.DueType</class>
+        
<class>org.apache.fineract.portfolio.loanproduct.domain.AllocationType</class>
+        
<class>org.apache.fineract.portfolio.loanproduct.domain.FutureInstallmentAllocationRule</class>
+        
<class>org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationTransactionType</class>
+        
<class>org.apache.fineract.portfolio.loanproduct.domain.AllocationTypeListConverter</class>
+        
<class>org.apache.fineract.portfolio.loanproduct.domain.LoanProductPaymentAllocationRule</class>
+        
<class>org.apache.fineract.portfolio.loanaccount.domain.LoanPaymentAllocationRule</class>
         <exclude-unlisted-classes>false</exclude-unlisted-classes>
         <properties>
             <property name="eclipselink.weaving" value="static" />

Reply via email to