Skip to content

Commit

Permalink
Merge pull request #196 from fiterlatam/feature/FBR-312
Browse files Browse the repository at this point in the history
Request for updates on prequalification
  • Loading branch information
BrianMuhimbura authored Sep 25, 2023
2 parents a536b15 + a3740f0 commit 3edfab1
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3885,4 +3885,12 @@ public CommandWrapperBuilder bureauValidationProcessing(Long prequalificationId)
this.href = "/prequalification/checklist/" + prequalificationId;
return this;
}

public CommandWrapperBuilder requestUpdatePrequalification(Long prequalificationId) {
this.actionName = "REQUESTUPDATE";
this.entityName = "PREQUALIFICATIONS";
this.entityId = prequalificationId;
this.href = "/prequalification/checklist/" + prequalificationId;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ public String validateHardPolicyChecklist(@PathParam("prequalificationId") final
if (is(commandParam, "bureauValidation")) {
final CommandWrapper validateCommandRequest = builder.bureauValidationProcessing(prequalificationId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(validateCommandRequest);
}
if (is(commandParam, "requestUpdates")) {
final CommandWrapper validateCommandRequest = builder.requestUpdatePrequalification(prequalificationId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(validateCommandRequest);
} else {
final CommandWrapper commandRequest = builder.validatePrequalificationHardPolicies(prequalificationId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@

public class PrequalificationCollectionConstants extends PrequalificatoinApiConstants {

protected static final Set<String> NEW_GROUP_PREQUALIFICATION_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(groupIdParamName,
groupNameParamName, productIdParamName, portfolioIdParamName, centerIdParamName, membersParamName, dateFormatParamName,
localeParamName, agencyIdParamName, facilitatorParamName, "individual", prequalilficationTimespanParamName,previousPrequalificationParamName));
protected static final Set<String> NEW_GROUP_PREQUALIFICATION_REQUEST_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(groupIdParamName, groupNameParamName, productIdParamName, portfolioIdParamName, centerIdParamName,
membersParamName, dateFormatParamName, localeParamName, agencyIdParamName, facilitatorParamName, "individual",
prequalilficationTimespanParamName, previousPrequalificationParamName));

protected static final Set<String> EDIT_GROUP_PREQUALIFICATION_REQUEST_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(groupIdParamName, groupNameParamName, productIdParamName, portfolioIdParamName, centerIdParamName,
membersParamName, dateFormatParamName, localeParamName, agencyIdParamName, facilitatorParamName, "individual",
prequalificationNumberParamName, prequalilficationTimespanParamName,previousPrequalificationParamName));
prequalificationNumberParamName, prequalilficationTimespanParamName, previousPrequalificationParamName));

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public static EnumOptionData status(final PrequalificationStatus status) {
case AGENCY_LEAD_PENDING_APPROVAL -> new EnumOptionData(
PrequalificationStatus.AGENCY_LEAD_PENDING_APPROVAL.getValue().longValue(),
PrequalificationStatus.AGENCY_LEAD_PENDING_APPROVAL.getCode(), "AGENCY_LEAD_PENDING_APPROVAL");
case PREQUALIFICATION_UPDATE_REQUESTED -> new EnumOptionData(
PrequalificationStatus.PREQUALIFICATION_UPDATE_REQUESTED.getValue().longValue(),
PrequalificationStatus.PREQUALIFICATION_UPDATE_REQUESTED.getCode(), "PREQUALIFICATION_UPDATE_REQUESTED");
default -> new EnumOptionData(PrequalificationStatus.INVALID.getValue().longValue(), PrequalificationStatus.INVALID.getCode(),
"INVALID");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,24 @@ public class PrequalificationGroup extends AbstractPersistableCustom {
private List<PrequalificationGroupMember> members;

public static PrequalificationGroup fromJson(final AppUser appUser, final AppUser facilitator, final Agency agency, final Group group,
final LoanProduct loanProduct, PrequalificationGroup parentGroup, final JsonCommand command) {
final LoanProduct loanProduct, PrequalificationGroup parentGroup, final JsonCommand command) {
String groupName = command.stringValueOfParameterNamed("groupName");
Long prequalilficationTimespan = command.longValueOfParameterNamed(PrequalificatoinApiConstants.prequalilficationTimespanParamName);
Long center = command.longValueOfParameterNamed(PrequalificatoinApiConstants.centerIdParamName);
if (group != null) {
groupName = group.getName();
}
return new PrequalificationGroup(appUser, facilitator, agency, group, groupName, center, loanProduct, prequalilficationTimespan, parentGroup);
return new PrequalificationGroup(appUser, facilitator, agency, group, groupName, center, loanProduct, prequalilficationTimespan,
parentGroup);
}

protected PrequalificationGroup() {
//
}

private PrequalificationGroup(final AppUser appUser, final AppUser facilitator, final Agency agency, final Group group,
final String groupName, Long center, final LoanProduct loanProduct, Long prequalilficationTimespan, PrequalificationGroup parentGroup) {
final String groupName, Long center, final LoanProduct loanProduct, Long prequalilficationTimespan,
PrequalificationGroup parentGroup) {
this.addedBy = appUser;
this.facilitator = facilitator;
this.status = PrequalificationStatus.BLACKLIST_CHECKED.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public enum PrequalificationStatus {
"prequalification.status.buro.checked"), HARD_POLICY_CHECKED(700, "prequalification.status.hard.policy.checked"), TIME_EXPIRED(
800, "prequalification.status.expired"), COMPLETED(900, "prequalification.status.completed"), CONSENT_ADDED(901,
"prequalification.status.concent.added"), AGENCY_LEAD_PENDING_APPROVAL(902,
"prequalification.status.pending.approval"), INVALID(0, "prequalification.status.invalid");
"prequalification.status.pending.approval"), PREQUALIFICATION_UPDATE_REQUESTED(903,
"prequalification.status.update.requested"), INVALID(0, "prequalification.status.invalid");

private final Integer value;
private final String code;
Expand Down Expand Up @@ -75,6 +76,9 @@ public static PrequalificationStatus fromInt(final Integer statusValue) {
case 902:
enumeration = PrequalificationStatus.AGENCY_LEAD_PENDING_APPROVAL;
break;
case 903:
enumeration = PrequalificationStatus.PREQUALIFICATION_UPDATE_REQUESTED;
break;
}
return enumeration;
}
Expand Down Expand Up @@ -114,6 +118,8 @@ public static PrequalificationStatus fromString(String status) {
clientStatus = PrequalificationStatus.CONSENT_ADDED;
} else if (status.equalsIgnoreCase(PrequalificationStatus.AGENCY_LEAD_PENDING_APPROVAL.toString())) {
clientStatus = PrequalificationStatus.AGENCY_LEAD_PENDING_APPROVAL;
} else if (status.equalsIgnoreCase(PrequalificationStatus.PREQUALIFICATION_UPDATE_REQUESTED.toString())) {
clientStatus = PrequalificationStatus.PREQUALIFICATION_UPDATE_REQUESTED;
}

return clientStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = "REQUESTUPDATE")
public class RequestPreQualificationUpdateCommandHandler implements NewCommandSourceHandler {

private final PrequalificationWritePlatformService prequalificationWritePlatformService;

@Autowired
public RequestPreQualificationUpdateCommandHandler(final PrequalificationWritePlatformService prequalificationWritePlatformService) {
this.prequalificationWritePlatformService = prequalificationWritePlatformService;
}

@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {

return this.prequalificationWritePlatformService.requestUpdates(command.entityId(), command);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ public interface PrequalificationWritePlatformService {
CommandProcessingResult updatePrequalificationGroupMember(Long memberId, JsonCommand command);

void disableExpiredPrequalifications() throws JobExecutionException;

CommandProcessingResult requestUpdates(Long entityId, JsonCommand command);
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.apache.fineract.organisation.prequalification.domain.PrequalificationGroupRepositoryWrapper;
import org.apache.fineract.organisation.prequalification.domain.PrequalificationMemberIndication;
import org.apache.fineract.organisation.prequalification.domain.PrequalificationStatus;
import org.apache.fineract.organisation.prequalification.exception.GroupPreQualificationNotFound;
import org.apache.fineract.organisation.prequalification.serialization.PrequalificationMemberCommandFromApiJsonDeserializer;
import org.apache.fineract.portfolio.blacklist.domain.BlacklistStatus;
import org.apache.fineract.portfolio.client.service.ClientChargeWritePlatformServiceJpaRepositoryImpl;
Expand Down Expand Up @@ -124,7 +125,8 @@ public CommandProcessingResult processPrequalification(JsonCommand command) {
final Long productId = command.longValueOfParameterNamed(PrequalificatoinApiConstants.productIdParamName);
final Long centerGroupId = command.longValueOfParameterNamed(PrequalificatoinApiConstants.groupIdParamName);
final Long agencyId = command.longValueOfParameterNamed(PrequalificatoinApiConstants.agencyIdParamName);
final Long previousPrequalificationId = command.longValueOfParameterNamed(PrequalificatoinApiConstants.previousPrequalificationParamName);
final Long previousPrequalificationId = command
.longValueOfParameterNamed(PrequalificatoinApiConstants.previousPrequalificationParamName);

PrequalificationGroup parentGroup = null;
if (previousPrequalificationId != null) {
Expand All @@ -149,8 +151,8 @@ public CommandProcessingResult processPrequalification(JsonCommand command) {
if (facilitatorId != null) {
facilitator = this.appUserRepository.findById(facilitatorId).orElseThrow(() -> new UserNotFoundException(facilitatorId));
}
PrequalificationGroup prequalificationGroup = PrequalificationGroup.fromJson(addedBy, facilitator, agency, group, loanProduct, parentGroup,
command);
PrequalificationGroup prequalificationGroup = PrequalificationGroup.fromJson(addedBy, facilitator, agency, group, loanProduct,
parentGroup, command);

this.prequalificationGroupRepositoryWrapper.saveAndFlush(prequalificationGroup);
StringBuilder prequalSB = new StringBuilder();
Expand Down Expand Up @@ -565,4 +567,19 @@ public void disableExpiredPrequalifications() throws JobExecutionException {
}

}

@Override
public CommandProcessingResult requestUpdates(Long entityId, JsonCommand command) {
this.context.authenticatedUser();
final PrequalificationGroup prequalificationGroup = this.prequalificationGroupRepositoryWrapper
.findOneWithNotFoundDetection(entityId);
if (prequalificationGroup == null) {
throw new GroupPreQualificationNotFound(entityId);
}
prequalificationGroup.updateStatus(PrequalificationStatus.PREQUALIFICATION_UPDATE_REQUESTED);
prequalificationGroup.updateComments(command.stringValueOfParameterNamed("comments"));
this.prequalificationGroupRepositoryWrapper.save(prequalificationGroup);

return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(prequalificationGroup.getId()).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,17 @@ public static GroupGeneralData instance(final Long id, final String accountNo, f
}

private GroupGeneralData(final Long id, final String accountNo, final String name, final String externalId, final EnumOptionData status,
final LocalDate activationDate, final Long officeId, final String officeName, final Long centerId, final String centerName,
final Long staffId, final String staffName, final String hierarchy, final String groupLevel,
final Collection<ClientData> clientMembers, final Collection<ClientData> activeClientMembers,
final Collection<CenterData> centerOptions, final Collection<OfficeData> officeOptions,
final Collection<StaffData> staffOptions, final Collection<ClientData> clientOptions,
final Collection<GroupRoleData> groupRoles, final Collection<CodeValueData> availableRoles, final GroupRoleData role,
final Collection<CalendarData> calendarsData, final CalendarData collectionMeetingCalendar,
final Collection<CodeValueData> closureReasons, final GroupTimelineData timeline,
final Collection<OfficeData> parentOfficesOptions, final Collection<AppUserData> responsibleUserOptions,
final Collection<PortfolioCenterData> portfolioCenterOptions, Collection<EnumOptionData> centerGroupLocations,
String prequalificationNumber, Long prequalificationId) {
final LocalDate activationDate, final Long officeId, final String officeName, final Long centerId, final String centerName,
final Long staffId, final String staffName, final String hierarchy, final String groupLevel,
final Collection<ClientData> clientMembers, final Collection<ClientData> activeClientMembers,
final Collection<CenterData> centerOptions, final Collection<OfficeData> officeOptions,
final Collection<StaffData> staffOptions, final Collection<ClientData> clientOptions,
final Collection<GroupRoleData> groupRoles, final Collection<CodeValueData> availableRoles, final GroupRoleData role,
final Collection<CalendarData> calendarsData, final CalendarData collectionMeetingCalendar,
final Collection<CodeValueData> closureReasons, final GroupTimelineData timeline,
final Collection<OfficeData> parentOfficesOptions, final Collection<AppUserData> responsibleUserOptions,
final Collection<PortfolioCenterData> portfolioCenterOptions, Collection<EnumOptionData> centerGroupLocations,
String prequalificationNumber, Long prequalificationId) {
this.id = id;
this.accountNo = accountNo;
this.name = name;
Expand Down Expand Up @@ -632,6 +632,7 @@ public void setGroupLocation(EnumOptionData groupLocation) {
public void setPrequalificationNumber(String prequalificationNumber) {
this.prequalificationNumber = prequalificationNumber;
}

public void setPrequalificationId(Long prequalificationId) {
this.prequalificationId = prequalificationId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,21 @@
<column name="can_maker_checker" valueBoolean="false" />
</insert>
<insert tableName="m_permission">
<column name="grouping" value="portfolio" />
<column name="grouping" value="portfolio" />
<column name="code" value="UPDATE_PREQUALIFICATIONS" />
<column name="entity_name" value="PREQUALIFICATIONS" />
<column name="action_name" value="UPDATE" />
<column name="can_maker_checker" valueBoolean="false" />
</insert>
</changeSet>
<changeSet author="fineract" id="2">
<insert tableName="m_permission">
<column name="grouping" value="portfolio" />
<column name="code" value="REQUESTUPDATE_PREQUALIFICATIONS" />
<column name="entity_name" value="PREQUALIFICATIONS" />
<column name="action_name" value="REQUESTUPDATE" />
<column name="can_maker_checker" valueBoolean="false" />
</insert>
</changeSet>

</databaseChangeLog>

0 comments on commit 3edfab1

Please sign in to comment.