diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/domain/PrequalificationGroup.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/domain/PrequalificationGroup.java index fbb7d009359..78363cb9b5d 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/domain/PrequalificationGroup.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/domain/PrequalificationGroup.java @@ -86,6 +86,9 @@ public class PrequalificationGroup extends AbstractPersistableCustom { @Column(name = "created_at") private LocalDateTime createdAt; + @Column(name = "prequalification_type_enum") + private Integer prequalificationType; + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "previous_prequalification") private PrequalificationGroup parent; @@ -212,4 +215,12 @@ public Map update(final JsonCommand command) { public void updateComments(String comment) { this.comments = comment; } + + public Integer getPrequalificationType() { + return prequalificationType; + } + + public void setPrequalificationType(Integer prequalificationType) { + this.prequalificationType = prequalificationType; + } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/domain/ValidationChecklistResult.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/domain/ValidationChecklistResult.java index 9780a2b4f60..8d4837b0950 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/domain/ValidationChecklistResult.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/domain/ValidationChecklistResult.java @@ -44,6 +44,7 @@ public class ValidationChecklistResult extends AbstractAuditableCustom { @Column(name = "client_id") private Integer clientId; + @Column(name = "prequalification_type") private Integer prequalificationType; diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationWritePlatformServiceImpl.java index 5c2e6e5e010..f69f786155d 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationWritePlatformServiceImpl.java @@ -65,6 +65,7 @@ import org.apache.fineract.organisation.prequalification.domain.PrequalificationMemberIndication; import org.apache.fineract.organisation.prequalification.domain.PrequalificationStatus; import org.apache.fineract.organisation.prequalification.domain.PrequalificationStatusLog; +import org.apache.fineract.organisation.prequalification.domain.PrequalificationType; import org.apache.fineract.organisation.prequalification.exception.PrequalificationStatusNotChangedException; import org.apache.fineract.organisation.prequalification.serialization.PrequalificationMemberCommandFromApiJsonDeserializer; import org.apache.fineract.portfolio.blacklist.domain.BlacklistStatus; @@ -73,6 +74,7 @@ import org.apache.fineract.portfolio.group.domain.Group; import org.apache.fineract.portfolio.group.domain.GroupRepositoryWrapper; import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct; +import org.apache.fineract.portfolio.loanproduct.domain.LoanProductOwnerType; import org.apache.fineract.portfolio.loanproduct.domain.LoanProductRepository; import org.apache.fineract.portfolio.loanproduct.exception.LoanProductNotFoundException; import org.apache.fineract.useradministration.domain.AppUser; @@ -183,6 +185,9 @@ public CommandProcessingResult processPrequalification(JsonCommand command) { PrequalificationGroup prequalificationGroup = PrequalificationGroup.fromJson(addedBy, facilitator, agency, group, loanProduct, parentGroup, command); + PrequalificationType prequalificationType = resolvePrequalificationType(loanProduct); + prequalificationGroup.setPrequalificationType(prequalificationType.getValue()); + this.prequalificationGroupRepositoryWrapper.saveAndFlush(prequalificationGroup); StringBuilder prequalSB = new StringBuilder(); prequalSB.append("PRECAL-"); @@ -378,6 +383,9 @@ public CommandProcessingResult processUpdatePrequalification(Long groupId, JsonC newLoanProduct = productOption.get(); } prequalificationGroup.updateProduct(newLoanProduct); + + PrequalificationType prequalificationType = resolvePrequalificationType(newLoanProduct); + prequalificationGroup.setPrequalificationType(prequalificationType.getValue()); } if (changes.containsKey(PrequalificatoinApiConstants.facilitatorParamName)) { @@ -756,4 +764,18 @@ private PrequalificationStatus resolveStatus(String action) { } return status; } + + private PrequalificationType resolvePrequalificationType(LoanProduct loanProduct) { + if (loanProduct.getOwnerType() != null) { + LoanProductOwnerType ownerType = LoanProductOwnerType.fromInt(loanProduct.getOwnerType()); + if (ownerType.equals(LoanProductOwnerType.INDIVIDUAL)) { + return PrequalificationType.INDIVIDUAL; + } + if (ownerType.equals(LoanProductOwnerType.GROUP)) { + return PrequalificationType.GROUP; + } + } + return PrequalificationType.INVALID; + } + } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProduct.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProduct.java index 94b384387d7..1ddf5619f42 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProduct.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProduct.java @@ -1651,4 +1651,7 @@ public void setLoanProducTrancheDetails(LoanProductTrancheDetails loanProducTran this.loanProducTrancheDetails = loanProducTrancheDetails; } + public Integer getOwnerType() { + return ownerType; + } } diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml index 16a15b7f0c1..59843fd7e0a 100644 --- a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml +++ b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml @@ -111,4 +111,5 @@ + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0095_Add_fields_to_prequalification_group.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0095_Add_fields_to_prequalification_group.xml new file mode 100644 index 00000000000..464cf266583 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0095_Add_fields_to_prequalification_group.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + UPDATE m_prequalification_group SET prequalification_type_enum = 1 WHERE product_id IN + (SELECT id FROM m_product_loan WHERE owner_type_enum = 1 AND id = product_id) + + + UPDATE m_prequalification_group SET prequalification_type_enum = 2 WHERE product_id IN + (SELECT id FROM m_product_loan WHERE owner_type_enum = 2 AND id = product_id) + + +