From e9eb04b7ae00f901b32deb7d762e9fc540cb774a Mon Sep 17 00:00:00 2001 From: Muhimbura Brian Mart Date: Wed, 4 Oct 2023 19:59:24 +0300 Subject: [PATCH 1/5] analysis details and edit requested amount --- .../service/CommandWrapperBuilder.java | 8 ++++ .../api/GroupPrequalificationApiResource.java | 20 ++++++++ .../PrequalificationCollectionConstants.java | 4 ++ .../PrequalificationDataValidator.java | 23 +++++++++ .../command/PrequalificatoinApiConstants.java | 2 + .../data/GroupPrequalificationData.java | 21 ++++++--- .../data/MemberPrequalificationData.java | 22 +++++---- .../domain/PrequalificationGroupMember.java | 11 +++++ ...tMemberPreQualificationCommandHandler.java | 47 +++++++++++++++++++ ...equalificationReadPlatformServiceImpl.java | 10 +++- ...qualificationWritePlatformServiceImpl.java | 21 +++++++-- .../db/changelog/tenant/changelog-tenant.xml | 1 + ...d_Amount_prequalification_group_member.xml | 45 ++++++++++++++++++ 13 files changed, 212 insertions(+), 23 deletions(-) create mode 100644 fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/handler/EditMemberPreQualificationCommandHandler.java create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0092_Add_Approved_Amount_prequalification_group_member.xml diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java b/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java index 82401937857..9eaa54c7b2a 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java @@ -3918,4 +3918,12 @@ public CommandWrapperBuilder sendGroupForAnalysis(Long prequalificationId) { this.href = "/prequalification/checklist/" + prequalificationId; return this; } + + public CommandWrapperBuilder updatePrequalificationMemberDetails(Long memberId) { + this.actionName = "UPDATE"; + this.entityName = "PREQUALIFICATIONMEMBER"; + this.entityId = memberId; + this.href = "/prequalification/" + memberId; + return this; + } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/GroupPrequalificationApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/GroupPrequalificationApiResource.java index 998257dd74f..3197b0e2697 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/GroupPrequalificationApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/GroupPrequalificationApiResource.java @@ -282,6 +282,26 @@ public String updatePrequalification(@Parameter(hidden = true) final String apiR } } + @PUT + @Path("/{groupId}/{memberId}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String updatePrequalificationMember(@Parameter(hidden = true) final String apiRequestBodyAsJson, + @PathParam("groupId") @Parameter(description = "groupId") final Long groupId, @PathParam("memberId") @Parameter(description = "memberId") final Long memberId) { + + try { + final CommandWrapper commandRequest = new CommandWrapperBuilder().updatePrequalificationMemberDetails(memberId).withJson(apiRequestBodyAsJson) + .build(); + + final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + + return this.toApiJsonSerializer.serialize(result); + } catch (final Exception e) { + e.printStackTrace(); + throw e; + } + } + @POST @Path("/{groupId}/comment") @Consumes({ MediaType.MULTIPART_FORM_DATA }) diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationCollectionConstants.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationCollectionConstants.java index 3d24c404618..4338a6b0f60 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationCollectionConstants.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationCollectionConstants.java @@ -34,4 +34,8 @@ public class PrequalificationCollectionConstants extends PrequalificatoinApiCons membersParamName, dateFormatParamName, localeParamName, agencyIdParamName, facilitatorParamName, "individual", prequalificationNumberParamName, prequalilficationTimespanParamName, previousPrequalificationParamName)); + protected static final Set EDIT_MEMBER_PREQUALIFICATION_REQUEST_DATA_PARAMETERS = new HashSet<>( + Arrays.asList(memberIdParamName,memberNameParamName, memberDpiParamName, memberDobParamName, memberRequestedAmountParamName, memberWorkWithPuenteParamName, + memberStatusParamName, approvedAmountParamName,localeParamName,dateFormatParamName)); + } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationDataValidator.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationDataValidator.java index 6be53e03d56..d70dea3c585 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationDataValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationDataValidator.java @@ -22,6 +22,7 @@ import com.google.gson.JsonElement; import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -122,4 +123,26 @@ private void throwExceptionIfValidationWarningsExist(final List dataValidationErrors = new ArrayList<>(); + + final Type typeOfMap = new TypeToken>() {}.getType(); + this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, + PrequalificationCollectionConstants.EDIT_MEMBER_PREQUALIFICATION_REQUEST_DATA_PARAMETERS); + + final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) + .resource(PrequalificatoinApiConstants.PREQUALIFICATION_RESOURCE_NAME); + + final JsonElement element = this.fromApiJsonHelper.parse(json); + + if (this.fromApiJsonHelper.parameterExists(PrequalificatoinApiConstants.approvedAmountParamName, element)) { + final BigDecimal approvedAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(PrequalificatoinApiConstants.approvedAmountParamName, element); + baseDataValidator.reset().parameter(PrequalificatoinApiConstants.approvedAmountParamName).value(approvedAmount).notNull() + .longGreaterThanZero(); + } + throwExceptionIfValidationWarningsExist(dataValidationErrors); + } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificatoinApiConstants.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificatoinApiConstants.java index f4fa5847eb8..2204c4c9fb0 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificatoinApiConstants.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificatoinApiConstants.java @@ -42,6 +42,7 @@ public class PrequalificatoinApiConstants { public static final String previousPrequalificationParamName = "previousPrequalification"; // Members + public static final String memberIdParamName = "id"; public static final String memberNameParamName = "name"; public static final String memberDpiParamName = "dpi"; public static final String memberDobParamName = "dob"; @@ -49,4 +50,5 @@ public class PrequalificatoinApiConstants { public static final String memberWorkWithPuenteParamName = "workWithPuente"; public static final String memberStatusParamName = "status"; public static final String memberClientIdParamName = "clientId"; + public static String approvedAmountParamName = "approvedAmount"; } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/GroupPrequalificationData.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/GroupPrequalificationData.java index ecdd6b5fd23..845135bf742 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/GroupPrequalificationData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/GroupPrequalificationData.java @@ -18,6 +18,7 @@ */ package org.apache.fineract.organisation.prequalification.data; +import java.math.BigDecimal; import java.time.LocalDate; import java.util.Collection; import java.util.List; @@ -72,6 +73,8 @@ public class GroupPrequalificationData { private Long prequalilficationTimespan; private Collection groupMembers; private Collection groupStatusOptions; + private BigDecimal totalRequestedAmount; + private BigDecimal totalApprovedAmount; public GroupPrequalificationData(final Long id, final String productName, final String prequalificationNumber, final String agencyName, final String portforlioName, final String centerName, final String groupName, final String addedBy, final LocalDate createdAt, @@ -107,6 +110,8 @@ public GroupPrequalificationData(final Long id, final String productName, final this.statusChangedOn = null; this.processType = null; this.processQuality = null; + this.totalRequestedAmount = null; + this.totalApprovedAmount = null; } public GroupPrequalificationData(final Long id, final String productName, final String prequalificationNumber, final String agencyName, @@ -116,7 +121,7 @@ public GroupPrequalificationData(final Long id, final String productName, final Collection appUsers, final Long agencyId, final Long centerId, final Long productId, final Long facilitatorId, final String facilitatorName, Long greenValidationCount, Long yellowValidationCount, Long orangeValidationCount, Long redValidationCount, Long prequalilficationTimespan, EnumOptionData lastPrequalificationStatus, String statusChangedBy, - LocalDate statusChangedOn, String processType, String processQuality) { + LocalDate statusChangedOn, String processType, String processQuality, BigDecimal totalRequestedAmount, BigDecimal totalApprovedAmount) { this.id = id; this.productName = productName; this.prequalificationNumber = prequalificationNumber; @@ -149,6 +154,8 @@ public GroupPrequalificationData(final Long id, final String productName, final this.statusChangedOn = statusChangedOn; this.processType = processType; this.processQuality = processQuality; + this.totalRequestedAmount = totalRequestedAmount; + this.totalApprovedAmount = totalApprovedAmount; } public static GroupPrequalificationData template(final Collection agencies, Collection centerData, @@ -169,15 +176,15 @@ public static GroupPrequalificationData instance(Long id, String prequalificatio } public static GroupPrequalificationData instance(Long id, String prequalificationNumber, EnumOptionData status, String agencyName, - String portfolioName, String centerName, String groupName, String productName, String addedBy, LocalDate createdAt, - String comments, Long groupId, final Long agencyId, final Long centerId, final Long productId, final Long facilitatorId, - final String facilitatorName, Long greenValidationCount, Long yellowValidationCount, Long orangeValidationCount, - Long redValidationCount, Long prequalilficationTimespan, EnumOptionData lastPrequalificationStatus, String statusChangedBy, - LocalDate statusChangedOn, String processType, String processQuality) { + String portfolioName, String centerName, String groupName, String productName, String addedBy, LocalDate createdAt, + String comments, Long groupId, final Long agencyId, final Long centerId, final Long productId, final Long facilitatorId, + final String facilitatorName, Long greenValidationCount, Long yellowValidationCount, Long orangeValidationCount, + Long redValidationCount, Long prequalilficationTimespan, EnumOptionData lastPrequalificationStatus, String statusChangedBy, + LocalDate statusChangedOn, String processType, String processQuality, BigDecimal totalRequestedAmount, BigDecimal totalApprovedAmount) { return new GroupPrequalificationData(id, productName, prequalificationNumber, agencyName, portfolioName, centerName, groupName, addedBy, createdAt, status, comments, groupId, null, null, null, null, null, agencyId, centerId, productId, facilitatorId, facilitatorName, greenValidationCount, yellowValidationCount, orangeValidationCount, redValidationCount, - prequalilficationTimespan, lastPrequalificationStatus, statusChangedBy, statusChangedOn, processType, processQuality); + prequalilficationTimespan, lastPrequalificationStatus, statusChangedBy, statusChangedOn, processType, processQuality,totalRequestedAmount,totalApprovedAmount); } public void updateMembers(Collection groupMembers) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/MemberPrequalificationData.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/MemberPrequalificationData.java index bb95e1b0838..26abfcf3295 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/MemberPrequalificationData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/MemberPrequalificationData.java @@ -35,6 +35,7 @@ public class MemberPrequalificationData { private final LocalDate dob; private final String workWithPuente; private final BigDecimal requestedAmount; + private final BigDecimal approvedAmount; private EnumOptionData status; private final Long blacklistCount; private final Long activeBlacklistCount; @@ -52,10 +53,10 @@ public class MemberPrequalificationData { private final EnumOptionData bureauCheckStatus; public MemberPrequalificationData(final Long id, final String name, final String dpi, final LocalDate dob, final String workWithPuente, - final BigDecimal requestedAmount, final EnumOptionData status, Long blacklistCount, BigDecimal totalLoanAmount, - BigDecimal totalLoanBalance, BigDecimal totalGuaranteedLoanBalance, Long noOfCycles, Long additionalCreditsCount, - BigDecimal additionalCreditsSum, final Long activeBlacklistCount, final Long inActiveBlacklistCount, Long greenValidationCount, - Long yellowValidationCount, Long orangeValidationCount, Long redValidationCount, EnumOptionData bureauCheckStatus) { + final BigDecimal requestedAmount, final EnumOptionData status, Long blacklistCount, BigDecimal totalLoanAmount, + BigDecimal totalLoanBalance, BigDecimal totalGuaranteedLoanBalance, Long noOfCycles, Long additionalCreditsCount, + BigDecimal additionalCreditsSum, final Long activeBlacklistCount, final Long inActiveBlacklistCount, Long greenValidationCount, + Long yellowValidationCount, Long orangeValidationCount, Long redValidationCount, EnumOptionData bureauCheckStatus, BigDecimal approvedAmount) { this.id = id; this.name = name; this.dpi = dpi; @@ -77,17 +78,18 @@ public MemberPrequalificationData(final Long id, final String name, final String this.orangeValidationCount = orangeValidationCount; this.redValidationCount = redValidationCount; this.bureauCheckStatus = bureauCheckStatus; + this.approvedAmount = approvedAmount; } public static MemberPrequalificationData instance(final Long id, final String name, final String dpi, final LocalDate dob, - final String workWithPuente, final BigDecimal requestedAmount, final EnumOptionData status, Long blacklistCount, - BigDecimal totalLoanAmount, BigDecimal totalLoanBalance, BigDecimal totalGuaranteedLoanBalance, Long noOfCycles, - Long additionalCreditsCount, BigDecimal additionalCreditsSum, final Long activeBlacklistCount, - final Long inActiveBlacklistCount, final Long greenValidationCount, final Long yellowValidationCount, - final Long orangeValidationCount, final Long redValidationCount, EnumOptionData bureauCheckStatus) { + final String workWithPuente, final BigDecimal requestedAmount, final EnumOptionData status, Long blacklistCount, + BigDecimal totalLoanAmount, BigDecimal totalLoanBalance, BigDecimal totalGuaranteedLoanBalance, Long noOfCycles, + Long additionalCreditsCount, BigDecimal additionalCreditsSum, final Long activeBlacklistCount, + final Long inActiveBlacklistCount, final Long greenValidationCount, final Long yellowValidationCount, + final Long orangeValidationCount, final Long redValidationCount, EnumOptionData bureauCheckStatus, BigDecimal approvedAmount) { return new MemberPrequalificationData(id, name, dpi, dob, workWithPuente, requestedAmount, status, blacklistCount, totalLoanAmount, totalLoanBalance, totalGuaranteedLoanBalance, noOfCycles, additionalCreditsCount, additionalCreditsSum, activeBlacklistCount, inActiveBlacklistCount, greenValidationCount, yellowValidationCount, orangeValidationCount, - redValidationCount, bureauCheckStatus); + redValidationCount, bureauCheckStatus,approvedAmount); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/domain/PrequalificationGroupMember.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/domain/PrequalificationGroupMember.java index 9874cec47f8..712609a1ae1 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/domain/PrequalificationGroupMember.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/domain/PrequalificationGroupMember.java @@ -58,6 +58,9 @@ public class PrequalificationGroupMember extends AbstractPersistableCustom { @Column(name = "requested_amount", nullable = false) private BigDecimal requestedAmount; + @Column(name = "approved_amount", nullable = false) + private BigDecimal approvedAmount; + @Column(name = "created_at") private LocalDateTime createdAt; @@ -159,7 +162,15 @@ public Map update(JsonCommand command) { final String newValue = command.stringValueOfParameterNamed(PrequalificatoinApiConstants.memberWorkWithPuenteParamName); actualChanges.put(PrequalificatoinApiConstants.memberWorkWithPuenteParamName, newValue); } + if (command.isChangeInBigDecimalParameterNamed(PrequalificatoinApiConstants.approvedAmountParamName, this.approvedAmount)) { + final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(PrequalificatoinApiConstants.approvedAmountParamName); + actualChanges.put(PrequalificatoinApiConstants.approvedAmountParamName, newValue); + } return actualChanges; } + + public void updateApprovedAmount(BigDecimal newValue) { + this.approvedAmount = newValue; + } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/handler/EditMemberPreQualificationCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/handler/EditMemberPreQualificationCommandHandler.java new file mode 100644 index 00000000000..0c2f5f70c66 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/handler/EditMemberPreQualificationCommandHandler.java @@ -0,0 +1,47 @@ +/** + * 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.organisation.prequalification.handler; + +import org.apache.fineract.commands.annotation.CommandType; +import org.apache.fineract.commands.handler.NewCommandSourceHandler; +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.organisation.prequalification.service.PrequalificationWritePlatformService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@CommandType(entity = "PREQUALIFICATIONMEMBER", action = "UPDATE") +public class EditMemberPreQualificationCommandHandler implements NewCommandSourceHandler { + + private final PrequalificationWritePlatformService prequalificationWritePlatformService; + + @Autowired + public EditMemberPreQualificationCommandHandler(final PrequalificationWritePlatformService prequalificationWritePlatformService) { + this.prequalificationWritePlatformService = prequalificationWritePlatformService; + } + + @Transactional + @Override + public CommandProcessingResult processCommand(final JsonCommand command) { + + return this.prequalificationWritePlatformService.updatePrequalificationGroupMember(command.entityId(), command); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java index d350304221e..72818b05ddc 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java @@ -321,6 +321,8 @@ private static final class PrequalificationsGroupMapper implements RowMapper0 THEN 'Reproceso' ELSE 'Nuevo' END) as processQuality, concat(mu.firstname, ' ', mu.lastname) as statusChangedBy, @@ -432,6 +434,8 @@ public GroupPrequalificationData mapRow(final ResultSet rs, final int rowNum) th final LocalDate statusChangedOn = JdbcSupport.getLocalDate(rs, "statusChangedOn"); final String processType = rs.getString("processType"); final String processQuality = rs.getString("processQuality"); + final BigDecimal totalRequestedAmount = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "totalRequestedAmount"); + final BigDecimal totalApprovedAmount = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "totalApprovedAmount"); if (StringUtils.isBlank(groupName)) { groupName = newGroupName; @@ -443,7 +447,7 @@ public GroupPrequalificationData mapRow(final ResultSet rs, final int rowNum) th return GroupPrequalificationData.instance(id, prequalificationNumber, status, agencyName, null, centerName, groupName, productName, addedBy, createdAt, comments, groupId, agencyId, centerId, productId, facilitatorId, facilitatorName, greenValidationCount, yellowValidationCount, orangeValidationCount, redValidationCount, prequalilficationTimespan, - lastPrequalificationStatus, statusChangedBy, statusChangedOn, processType, processQuality); + lastPrequalificationStatus, statusChangedBy, statusChangedOn, processType, processQuality, totalRequestedAmount, totalApprovedAmount); } } @@ -461,6 +465,7 @@ private static final class PrequalificationsMemberMapper implements RowMapper changes = member.update(command); + if (changes.containsKey(PrequalificatoinApiConstants.approvedAmountParamName)) { + final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(PrequalificatoinApiConstants.approvedAmountParamName); + member.updateApprovedAmount(newValue); + } + + this.preQualificationMemberRepository.saveAndFlush(member); + return new CommandProcessingResultBuilder() // + .withCommandId(command.commandId()) // + .withResourceIdAsString(memberId.toString()) // + .build(); } private List assembleMembersForUpdate(JsonCommand command, PrequalificationGroup prequalificationGroup, 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 d9208400546..f91851599d4 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 @@ -108,4 +108,5 @@ + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0092_Add_Approved_Amount_prequalification_group_member.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0092_Add_Approved_Amount_prequalification_group_member.xml new file mode 100644 index 00000000000..34bb3962ac3 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0092_Add_Approved_Amount_prequalification_group_member.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + From 9262b2dc34043061a9e304e6637173f96949483f Mon Sep 17 00:00:00 2001 From: Muhimbura Brian Mart Date: Wed, 4 Oct 2023 22:45:32 +0300 Subject: [PATCH 2/5] analysis details and edit requested amount --- .../service/CommandWrapperBuilder.java | 8 ++++ .../PrequalificationChecklistApiResource.java | 15 +++++- .../ProcessAnalysisRequestCommandHandler.java | 47 +++++++++++++++++++ .../PrequalificationWritePlatformService.java | 2 + ...qualificationWritePlatformServiceImpl.java | 34 ++++++++++++++ ...d_Amount_prequalification_group_member.xml | 9 ++++ 6 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/handler/ProcessAnalysisRequestCommandHandler.java diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java b/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java index 90a11a501a0..35416766c32 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java @@ -3934,4 +3934,12 @@ public CommandWrapperBuilder updatePrequalificationMemberDetails(Long memberId) this.href = "/prequalification/" + memberId; return this; } + + public CommandWrapperBuilder processAnalysisRequest(Long prequalificationId) { + this.actionName = "PROCESSANALYSIS"; + this.entityName = "PREQUALIFICATIONS"; + this.entityId = prequalificationId; + this.href = "/prequalification/checklist/" + prequalificationId; + return this; + } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/PrequalificationChecklistApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/PrequalificationChecklistApiResource.java index d1e7df750bc..b81b834f982 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/PrequalificationChecklistApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/PrequalificationChecklistApiResource.java @@ -120,10 +120,23 @@ public String validateHardPolicyChecklist(@PathParam("prequalificationId") final } else if (is(commandParam, "sendToAnalysis")) { final CommandWrapper validateCommandRequest = builder.sendGroupForAnalysis(prequalificationId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(validateCommandRequest); + }else if (is(commandParam, "sendtoexception")) { + final CommandWrapper validateCommandRequest = builder.processAnalysisRequest(prequalificationId).build(); + result = this.commandsSourceWritePlatformService.logCommandSource(validateCommandRequest); + }else if (is(commandParam, "sendtoagency")) { + final CommandWrapper validateCommandRequest = builder.processAnalysisRequest(prequalificationId).build(); + result = this.commandsSourceWritePlatformService.logCommandSource(validateCommandRequest); + }else if (is(commandParam, "rejectanalysis")) { + final CommandWrapper validateCommandRequest = builder.processAnalysisRequest(prequalificationId).build(); + result = this.commandsSourceWritePlatformService.logCommandSource(validateCommandRequest); + }else if (is(commandParam, "approveanalysis")) { + final CommandWrapper validateCommandRequest = builder.processAnalysisRequest(prequalificationId).build(); + result = this.commandsSourceWritePlatformService.logCommandSource(validateCommandRequest); } else { - final CommandWrapper commandRequest = builder.validatePrequalificationHardPolicies(prequalificationId).build(); + final CommandWrapper commandRequest = builder.processAnalysisRequest(prequalificationId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); } + return this.toApiJsonSerializer.serialize(result); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/handler/ProcessAnalysisRequestCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/handler/ProcessAnalysisRequestCommandHandler.java new file mode 100644 index 00000000000..ad89a38c36e --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/handler/ProcessAnalysisRequestCommandHandler.java @@ -0,0 +1,47 @@ +/** + * 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.organisation.prequalification.handler; + +import org.apache.fineract.commands.annotation.CommandType; +import org.apache.fineract.commands.handler.NewCommandSourceHandler; +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.organisation.prequalification.service.PrequalificationWritePlatformService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@CommandType(entity = "PREQUALIFICATIONS", action = "PROCESSANALYSIS") +public class ProcessAnalysisRequestCommandHandler implements NewCommandSourceHandler { + + private final PrequalificationWritePlatformService prequalificationWritePlatformService; + + @Autowired + public ProcessAnalysisRequestCommandHandler(final PrequalificationWritePlatformService prequalificationWritePlatformService) { + this.prequalificationWritePlatformService = prequalificationWritePlatformService; + } + + @Transactional + @Override + public CommandProcessingResult processCommand(final JsonCommand command) { + + return this.prequalificationWritePlatformService.processAnalysisRequest(command.entityId(), command); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationWritePlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationWritePlatformService.java index 95a7c641c73..f04e607fe71 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationWritePlatformService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationWritePlatformService.java @@ -37,4 +37,6 @@ public interface PrequalificationWritePlatformService { CommandProcessingResult requestUpdates(Long entityId, JsonCommand command); CommandProcessingResult sendForAnalysis(Long entityId, JsonCommand command); + + CommandProcessingResult processAnalysisRequest(Long entityId, JsonCommand command); } 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 e02ebc2dd0a..b943afd1706 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 @@ -654,4 +654,38 @@ public CommandProcessingResult sendForAnalysis(Long entityId, JsonCommand comman return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(prequalificationGroup.getId()).build(); } + + @Override + public CommandProcessingResult processAnalysisRequest(Long entityId, JsonCommand command) { + String comments = command.stringValueOfParameterNamed("comments"); + String action = command.stringValueOfParameterNamed("action"); + AppUser addedBy = this.context.authenticatedUser(); + final PrequalificationGroup prequalificationGroup = this.prequalificationGroupRepositoryWrapper + .findOneWithNotFoundDetection(entityId); + Integer fromStatus = prequalificationGroup.getStatus(); + prequalificationGroup.updateStatus(resolveStatus(action)); +// this.prequalificationGroupRepositoryWrapper.save(prequalificationGroup); + + PrequalificationStatusLog statusLog = PrequalificationStatusLog.fromJson(addedBy, fromStatus, prequalificationGroup.getStatus(), + comments, prequalificationGroup); + + this.preQualificationLogRepository.saveAndFlush(statusLog); + return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(prequalificationGroup.getId()).build(); + } + + private PrequalificationStatus resolveStatus(String action) { + PrequalificationStatus status = null; + if (action.equalsIgnoreCase("sendtoagency")) { + status = PrequalificationStatus.AGENCY_LEAD_PENDING_APPROVAL; + } else if (action.equalsIgnoreCase("sendtoexception")) { + status = PrequalificationStatus.AGENCY_LEAD_PENDING_APPROVAL_WITH_EXCEPTIONS; + }else if (action.equalsIgnoreCase("requestupdates")) { + status = PrequalificationStatus.PREQUALIFICATION_UPDATE_REQUESTED; + }else if (action.equalsIgnoreCase("rejectanalysis")) { + status = PrequalificationStatus.REJECTED; + }else if (action.equalsIgnoreCase("approveanalysis")) { + status = PrequalificationStatus.APPROVED; + } + return status; + } } diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0092_Add_Approved_Amount_prequalification_group_member.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0092_Add_Approved_Amount_prequalification_group_member.xml index 34bb3962ac3..1cdec1bffb5 100644 --- a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0092_Add_Approved_Amount_prequalification_group_member.xml +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0092_Add_Approved_Amount_prequalification_group_member.xml @@ -42,4 +42,13 @@ + + + + + + + + + From 4a33bcd6f1e7df4142f1b011d94669b65d561f78 Mon Sep 17 00:00:00 2001 From: Muhimbura Brian Mart Date: Wed, 4 Oct 2023 22:50:38 +0300 Subject: [PATCH 3/5] analysis details and edit requested amount --- .../api/GroupPrequalificationApiResource.java | 7 ++++--- .../PrequalificationChecklistApiResource.java | 8 +++---- .../PrequalificationCollectionConstants.java | 4 ++-- .../PrequalificationDataValidator.java | 3 ++- .../data/GroupPrequalificationData.java | 17 ++++++++------- .../data/MemberPrequalificationData.java | 21 ++++++++++--------- ...equalificationReadPlatformServiceImpl.java | 5 +++-- ...qualificationWritePlatformServiceImpl.java | 8 +++---- 8 files changed, 40 insertions(+), 33 deletions(-) diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/GroupPrequalificationApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/GroupPrequalificationApiResource.java index 3197b0e2697..f7edac6c345 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/GroupPrequalificationApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/GroupPrequalificationApiResource.java @@ -287,11 +287,12 @@ public String updatePrequalification(@Parameter(hidden = true) final String apiR @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) public String updatePrequalificationMember(@Parameter(hidden = true) final String apiRequestBodyAsJson, - @PathParam("groupId") @Parameter(description = "groupId") final Long groupId, @PathParam("memberId") @Parameter(description = "memberId") final Long memberId) { + @PathParam("groupId") @Parameter(description = "groupId") final Long groupId, + @PathParam("memberId") @Parameter(description = "memberId") final Long memberId) { try { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updatePrequalificationMemberDetails(memberId).withJson(apiRequestBodyAsJson) - .build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().updatePrequalificationMemberDetails(memberId) + .withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/PrequalificationChecklistApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/PrequalificationChecklistApiResource.java index b81b834f982..223b497dfc5 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/PrequalificationChecklistApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/api/PrequalificationChecklistApiResource.java @@ -120,16 +120,16 @@ public String validateHardPolicyChecklist(@PathParam("prequalificationId") final } else if (is(commandParam, "sendToAnalysis")) { final CommandWrapper validateCommandRequest = builder.sendGroupForAnalysis(prequalificationId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(validateCommandRequest); - }else if (is(commandParam, "sendtoexception")) { + } else if (is(commandParam, "sendtoexception")) { final CommandWrapper validateCommandRequest = builder.processAnalysisRequest(prequalificationId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(validateCommandRequest); - }else if (is(commandParam, "sendtoagency")) { + } else if (is(commandParam, "sendtoagency")) { final CommandWrapper validateCommandRequest = builder.processAnalysisRequest(prequalificationId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(validateCommandRequest); - }else if (is(commandParam, "rejectanalysis")) { + } else if (is(commandParam, "rejectanalysis")) { final CommandWrapper validateCommandRequest = builder.processAnalysisRequest(prequalificationId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(validateCommandRequest); - }else if (is(commandParam, "approveanalysis")) { + } else if (is(commandParam, "approveanalysis")) { final CommandWrapper validateCommandRequest = builder.processAnalysisRequest(prequalificationId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(validateCommandRequest); } else { diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationCollectionConstants.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationCollectionConstants.java index 4338a6b0f60..bf7ce96b230 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationCollectionConstants.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationCollectionConstants.java @@ -35,7 +35,7 @@ public class PrequalificationCollectionConstants extends PrequalificatoinApiCons prequalificationNumberParamName, prequalilficationTimespanParamName, previousPrequalificationParamName)); protected static final Set EDIT_MEMBER_PREQUALIFICATION_REQUEST_DATA_PARAMETERS = new HashSet<>( - Arrays.asList(memberIdParamName,memberNameParamName, memberDpiParamName, memberDobParamName, memberRequestedAmountParamName, memberWorkWithPuenteParamName, - memberStatusParamName, approvedAmountParamName,localeParamName,dateFormatParamName)); + Arrays.asList(memberIdParamName, memberNameParamName, memberDpiParamName, memberDobParamName, memberRequestedAmountParamName, + memberWorkWithPuenteParamName, memberStatusParamName, approvedAmountParamName, localeParamName, dateFormatParamName)); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationDataValidator.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationDataValidator.java index d70dea3c585..94dc507f73c 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationDataValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/command/PrequalificationDataValidator.java @@ -139,7 +139,8 @@ public void validateUpdateMember(String json) { final JsonElement element = this.fromApiJsonHelper.parse(json); if (this.fromApiJsonHelper.parameterExists(PrequalificatoinApiConstants.approvedAmountParamName, element)) { - final BigDecimal approvedAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(PrequalificatoinApiConstants.approvedAmountParamName, element); + final BigDecimal approvedAmount = this.fromApiJsonHelper + .extractBigDecimalWithLocaleNamed(PrequalificatoinApiConstants.approvedAmountParamName, element); baseDataValidator.reset().parameter(PrequalificatoinApiConstants.approvedAmountParamName).value(approvedAmount).notNull() .longGreaterThanZero(); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/GroupPrequalificationData.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/GroupPrequalificationData.java index 845135bf742..82de85b79ea 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/GroupPrequalificationData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/GroupPrequalificationData.java @@ -121,7 +121,8 @@ public GroupPrequalificationData(final Long id, final String productName, final Collection appUsers, final Long agencyId, final Long centerId, final Long productId, final Long facilitatorId, final String facilitatorName, Long greenValidationCount, Long yellowValidationCount, Long orangeValidationCount, Long redValidationCount, Long prequalilficationTimespan, EnumOptionData lastPrequalificationStatus, String statusChangedBy, - LocalDate statusChangedOn, String processType, String processQuality, BigDecimal totalRequestedAmount, BigDecimal totalApprovedAmount) { + LocalDate statusChangedOn, String processType, String processQuality, BigDecimal totalRequestedAmount, + BigDecimal totalApprovedAmount) { this.id = id; this.productName = productName; this.prequalificationNumber = prequalificationNumber; @@ -176,15 +177,17 @@ public static GroupPrequalificationData instance(Long id, String prequalificatio } public static GroupPrequalificationData instance(Long id, String prequalificationNumber, EnumOptionData status, String agencyName, - String portfolioName, String centerName, String groupName, String productName, String addedBy, LocalDate createdAt, - String comments, Long groupId, final Long agencyId, final Long centerId, final Long productId, final Long facilitatorId, - final String facilitatorName, Long greenValidationCount, Long yellowValidationCount, Long orangeValidationCount, - Long redValidationCount, Long prequalilficationTimespan, EnumOptionData lastPrequalificationStatus, String statusChangedBy, - LocalDate statusChangedOn, String processType, String processQuality, BigDecimal totalRequestedAmount, BigDecimal totalApprovedAmount) { + String portfolioName, String centerName, String groupName, String productName, String addedBy, LocalDate createdAt, + String comments, Long groupId, final Long agencyId, final Long centerId, final Long productId, final Long facilitatorId, + final String facilitatorName, Long greenValidationCount, Long yellowValidationCount, Long orangeValidationCount, + Long redValidationCount, Long prequalilficationTimespan, EnumOptionData lastPrequalificationStatus, String statusChangedBy, + LocalDate statusChangedOn, String processType, String processQuality, BigDecimal totalRequestedAmount, + BigDecimal totalApprovedAmount) { return new GroupPrequalificationData(id, productName, prequalificationNumber, agencyName, portfolioName, centerName, groupName, addedBy, createdAt, status, comments, groupId, null, null, null, null, null, agencyId, centerId, productId, facilitatorId, facilitatorName, greenValidationCount, yellowValidationCount, orangeValidationCount, redValidationCount, - prequalilficationTimespan, lastPrequalificationStatus, statusChangedBy, statusChangedOn, processType, processQuality,totalRequestedAmount,totalApprovedAmount); + prequalilficationTimespan, lastPrequalificationStatus, statusChangedBy, statusChangedOn, processType, processQuality, + totalRequestedAmount, totalApprovedAmount); } public void updateMembers(Collection groupMembers) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/MemberPrequalificationData.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/MemberPrequalificationData.java index 26abfcf3295..ce91e3d537d 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/MemberPrequalificationData.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/data/MemberPrequalificationData.java @@ -53,10 +53,11 @@ public class MemberPrequalificationData { private final EnumOptionData bureauCheckStatus; public MemberPrequalificationData(final Long id, final String name, final String dpi, final LocalDate dob, final String workWithPuente, - final BigDecimal requestedAmount, final EnumOptionData status, Long blacklistCount, BigDecimal totalLoanAmount, - BigDecimal totalLoanBalance, BigDecimal totalGuaranteedLoanBalance, Long noOfCycles, Long additionalCreditsCount, - BigDecimal additionalCreditsSum, final Long activeBlacklistCount, final Long inActiveBlacklistCount, Long greenValidationCount, - Long yellowValidationCount, Long orangeValidationCount, Long redValidationCount, EnumOptionData bureauCheckStatus, BigDecimal approvedAmount) { + final BigDecimal requestedAmount, final EnumOptionData status, Long blacklistCount, BigDecimal totalLoanAmount, + BigDecimal totalLoanBalance, BigDecimal totalGuaranteedLoanBalance, Long noOfCycles, Long additionalCreditsCount, + BigDecimal additionalCreditsSum, final Long activeBlacklistCount, final Long inActiveBlacklistCount, Long greenValidationCount, + Long yellowValidationCount, Long orangeValidationCount, Long redValidationCount, EnumOptionData bureauCheckStatus, + BigDecimal approvedAmount) { this.id = id; this.name = name; this.dpi = dpi; @@ -82,14 +83,14 @@ public MemberPrequalificationData(final Long id, final String name, final String } public static MemberPrequalificationData instance(final Long id, final String name, final String dpi, final LocalDate dob, - final String workWithPuente, final BigDecimal requestedAmount, final EnumOptionData status, Long blacklistCount, - BigDecimal totalLoanAmount, BigDecimal totalLoanBalance, BigDecimal totalGuaranteedLoanBalance, Long noOfCycles, - Long additionalCreditsCount, BigDecimal additionalCreditsSum, final Long activeBlacklistCount, - final Long inActiveBlacklistCount, final Long greenValidationCount, final Long yellowValidationCount, - final Long orangeValidationCount, final Long redValidationCount, EnumOptionData bureauCheckStatus, BigDecimal approvedAmount) { + final String workWithPuente, final BigDecimal requestedAmount, final EnumOptionData status, Long blacklistCount, + BigDecimal totalLoanAmount, BigDecimal totalLoanBalance, BigDecimal totalGuaranteedLoanBalance, Long noOfCycles, + Long additionalCreditsCount, BigDecimal additionalCreditsSum, final Long activeBlacklistCount, + final Long inActiveBlacklistCount, final Long greenValidationCount, final Long yellowValidationCount, + final Long orangeValidationCount, final Long redValidationCount, EnumOptionData bureauCheckStatus, BigDecimal approvedAmount) { return new MemberPrequalificationData(id, name, dpi, dob, workWithPuente, requestedAmount, status, blacklistCount, totalLoanAmount, totalLoanBalance, totalGuaranteedLoanBalance, noOfCycles, additionalCreditsCount, additionalCreditsSum, activeBlacklistCount, inActiveBlacklistCount, greenValidationCount, yellowValidationCount, orangeValidationCount, - redValidationCount, bureauCheckStatus,approvedAmount); + redValidationCount, bureauCheckStatus, approvedAmount); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java index 72818b05ddc..e3d5d981051 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java @@ -447,7 +447,8 @@ public GroupPrequalificationData mapRow(final ResultSet rs, final int rowNum) th return GroupPrequalificationData.instance(id, prequalificationNumber, status, agencyName, null, centerName, groupName, productName, addedBy, createdAt, comments, groupId, agencyId, centerId, productId, facilitatorId, facilitatorName, greenValidationCount, yellowValidationCount, orangeValidationCount, redValidationCount, prequalilficationTimespan, - lastPrequalificationStatus, statusChangedBy, statusChangedOn, processType, processQuality, totalRequestedAmount, totalApprovedAmount); + lastPrequalificationStatus, statusChangedBy, statusChangedOn, processType, processQuality, totalRequestedAmount, + totalApprovedAmount); } } @@ -579,7 +580,7 @@ public MemberPrequalificationData mapRow(final ResultSet rs, final int rowNum) t return MemberPrequalificationData.instance(id, name, dpi, dob, puente, requestedAmount, status, blacklistCount, totalLoanAmount, totalLoanBalance, totalGuaranteedLoanBalance, noOfCycles, additionalCreditsCount, additionalCreditsSum, activeBlacklistCount, inActiveBlacklistCount, greenValidationCount, yellowValidationCount, orangeValidationCount, - redValidationCount, bureauCheckStatus,approvedAmount); + redValidationCount, bureauCheckStatus, approvedAmount); } } 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 b943afd1706..1e2f5452637 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 @@ -664,7 +664,7 @@ public CommandProcessingResult processAnalysisRequest(Long entityId, JsonCommand .findOneWithNotFoundDetection(entityId); Integer fromStatus = prequalificationGroup.getStatus(); prequalificationGroup.updateStatus(resolveStatus(action)); -// this.prequalificationGroupRepositoryWrapper.save(prequalificationGroup); + // this.prequalificationGroupRepositoryWrapper.save(prequalificationGroup); PrequalificationStatusLog statusLog = PrequalificationStatusLog.fromJson(addedBy, fromStatus, prequalificationGroup.getStatus(), comments, prequalificationGroup); @@ -679,11 +679,11 @@ private PrequalificationStatus resolveStatus(String action) { status = PrequalificationStatus.AGENCY_LEAD_PENDING_APPROVAL; } else if (action.equalsIgnoreCase("sendtoexception")) { status = PrequalificationStatus.AGENCY_LEAD_PENDING_APPROVAL_WITH_EXCEPTIONS; - }else if (action.equalsIgnoreCase("requestupdates")) { + } else if (action.equalsIgnoreCase("requestupdates")) { status = PrequalificationStatus.PREQUALIFICATION_UPDATE_REQUESTED; - }else if (action.equalsIgnoreCase("rejectanalysis")) { + } else if (action.equalsIgnoreCase("rejectanalysis")) { status = PrequalificationStatus.REJECTED; - }else if (action.equalsIgnoreCase("approveanalysis")) { + } else if (action.equalsIgnoreCase("approveanalysis")) { status = PrequalificationStatus.APPROVED; } return status; From 6dd6372a147938da59bfa5ca7225d71b8b6a48d0 Mon Sep 17 00:00:00 2001 From: Muhimbura Brian Mart Date: Wed, 4 Oct 2023 23:11:41 +0300 Subject: [PATCH 4/5] analysis details and edit requested amount --- ...ualificationStatusNotChangedException.java | 31 +++++++++++++++++++ ...qualificationWritePlatformServiceImpl.java | 7 ++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/exception/PrequalificationStatusNotChangedException.java diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/exception/PrequalificationStatusNotChangedException.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/exception/PrequalificationStatusNotChangedException.java new file mode 100644 index 00000000000..1d0e69f05af --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/exception/PrequalificationStatusNotChangedException.java @@ -0,0 +1,31 @@ +/** + * 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.organisation.prequalification.exception; + +import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + +/** + * A {@link RuntimeException} thrown when client is already blacklisted. + */ +public class PrequalificationStatusNotChangedException extends AbstractPlatformResourceNotFoundException { + + public PrequalificationStatusNotChangedException(String status) { + super("error.msg.group.prequalification.status.not.changed", "Group Prequalificaiton status " + status + " was not changed.", status); + } +} 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 1e2f5452637..575b86ff7da 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 @@ -57,6 +57,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.exception.PrequalificationStatusNotChangedException; import org.apache.fineract.organisation.prequalification.serialization.PrequalificationMemberCommandFromApiJsonDeserializer; import org.apache.fineract.portfolio.blacklist.domain.BlacklistStatus; import org.apache.fineract.portfolio.client.service.ClientChargeWritePlatformServiceJpaRepositoryImpl; @@ -663,7 +664,11 @@ public CommandProcessingResult processAnalysisRequest(Long entityId, JsonCommand final PrequalificationGroup prequalificationGroup = this.prequalificationGroupRepositoryWrapper .findOneWithNotFoundDetection(entityId); Integer fromStatus = prequalificationGroup.getStatus(); - prequalificationGroup.updateStatus(resolveStatus(action)); + PrequalificationStatus prequalificationStatus = resolveStatus(action); + if (fromStatus == prequalificationStatus.getValue()) { + throw new PrequalificationStatusNotChangedException(prequalificationStatus.toString()); + } + prequalificationGroup.updateStatus(prequalificationStatus); // this.prequalificationGroupRepositoryWrapper.save(prequalificationGroup); PrequalificationStatusLog statusLog = PrequalificationStatusLog.fromJson(addedBy, fromStatus, prequalificationGroup.getStatus(), From f10a24abfa0976b4cc59ce8597a923ab0c2b82ed Mon Sep 17 00:00:00 2001 From: Muhimbura Brian Mart Date: Thu, 5 Oct 2023 11:16:19 +0300 Subject: [PATCH 5/5] analysis details and edit requested amount --- .../service/PrequalificationReadPlatformServiceImpl.java | 5 ++++- .../service/PrequalificationWritePlatformServiceImpl.java | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java index e3d5d981051..f7fadef8ab4 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/prequalification/service/PrequalificationReadPlatformServiceImpl.java @@ -388,7 +388,10 @@ private static final class PrequalificationsGroupMapper implements RowMapper