Skip to content

Commit

Permalink
Merge pull request #251 from fiterlatam/fix/FBR-375
Browse files Browse the repository at this point in the history
Fix/fbr 375
  • Loading branch information
BrianMuhimbura authored Nov 2, 2023
2 parents 3e03cf2 + 6f5e4b1 commit 00dcf71
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public static PrequalificationStatus fromInt(final Integer statusValue) {
break;
case 1005:
enumeration = PrequalificationStatus.PRE_COMMITTEE_B_PENDING_APPROVAL;
break;
case 1006:
enumeration = PrequalificationStatus.PRE_COMMITTEE_A_PENDING_APPROVAL;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,9 @@ private String resolveCommitteeGroupStatus(CodeValueData committeeValueData) {

String statusValues = "";
switch (name) {
case "A" -> statusValues = PrequalificationStatus.PRE_COMMITTEE_B_PENDING_APPROVAL.getValue().toString();
case "B" -> statusValues = PrequalificationStatus.PRE_COMMITTEE_C_PENDING_APPROVAL.getValue().toString() + ", "
case "A" -> statusValues = PrequalificationStatus.PRE_COMMITTEE_A_PENDING_APPROVAL.getValue().toString() + ", "
+ PrequalificationStatus.PRE_COMMITTEE_B_PENDING_APPROVAL.getValue().toString();
case "B" -> statusValues = PrequalificationStatus.PRE_COMMITTEE_B_PENDING_APPROVAL.getValue().toString() + ", "
+ PrequalificationStatus.PRE_COMMITTEE_C_PENDING_APPROVAL.getValue().toString();
case "C" -> statusValues = PrequalificationStatus.PRE_COMMITTEE_C_PENDING_APPROVAL.getValue().toString() + ", "
+ PrequalificationStatus.PRE_COMMITTEE_D_PENDING_APPROVAL.getValue().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,28 +798,23 @@ public CommandProcessingResult processAnalysisRequest(Long entityId, JsonCommand
return sendToAgency(entityId, command);
}
PrequalificationStatus prequalificationStatus = resolveStatus(action);
if (fromStatus.equals(prequalificationStatus.getValue())) {
throw new PrequalificationStatusNotChangedException(prequalificationStatus.toString());
}

if (prequalificationGroup.isPrequalificationTypeIndividual() && action.equals("approveanalysis")) {
prequalificationStatus = resolveIndividualStatus(prequalificationGroup, action);
PrequalificationStatusRange statusRange = resolveIndividualStatusRange(prequalificationGroup, action);
prequalificationStatus = PrequalificationStatus.fromInt(statusRange.getStatus());

if (fromStatus.equals(prequalificationStatus.getValue())) {
throw new PrequalificationStatusNotChangedException(prequalificationStatus.toString());
}
}
if (prequalificationGroup.isPrequalificationTypeIndividual() && action.equals("approveCommittee")) {
prequalificationStatus = resolveCommitteeStatus(prequalificationGroup, action);
}

if (fromStatus.equals(prequalificationStatus.getValue())) {
throw new PrequalificationStatusNotChangedException(prequalificationStatus.toString());
}
// check if status has changed after resolving the new status
if (fromStatus.equals(prequalificationStatus.getValue())) {
throw new PrequalificationStatusNotChangedException(prequalificationStatus.toString());
}

prequalificationGroup.updateStatus(prequalificationStatus);
prequalificationGroup.updateComments(comments);
// this.prequalificationGroupRepositoryWrapper.save(prequalificationGroup);

PrequalificationStatusLog statusLog = PrequalificationStatusLog.fromJson(addedBy, fromStatus, prequalificationGroup.getStatus(),
comments, prequalificationGroup);
Expand All @@ -830,23 +825,27 @@ public CommandProcessingResult processAnalysisRequest(Long entityId, JsonCommand

private PrequalificationStatus resolveCommitteeStatus(PrequalificationGroup prequalificationGroup, String action) {
// TODO ---CHECK IF THE COMMITTEE IS THE LAST COMMITTEE
PrequalificationStatus status;
BigDecimal amount = prequalificationGroup.getTotalRequestedAmount();
if (amount.compareTo(BigDecimal.valueOf(20000)) <= 0) {
return prequalificationGroup.getStatus().equals(PrequalificationStatus.PRE_COMMITTEE_D_PENDING_APPROVAL.getValue())
? PrequalificationStatus.PRE_COMMITTEE_C_PENDING_APPROVAL
: PrequalificationStatus.COMPLETED;
} else if (amount.compareTo(BigDecimal.valueOf(20000)) > 0 && amount.compareTo(BigDecimal.valueOf(75000)) <= 0) {
return prequalificationGroup.getStatus().equals(PrequalificationStatus.PRE_COMMITTEE_C_PENDING_APPROVAL.getValue())
? PrequalificationStatus.PRE_COMMITTEE_B_PENDING_APPROVAL
: PrequalificationStatus.COMPLETED;
} else if (amount.compareTo(BigDecimal.valueOf(75000)) > 0) {
return prequalificationGroup.getStatus().equals(PrequalificationStatus.PRE_COMMITTEE_B_PENDING_APPROVAL.getValue())
? PrequalificationStatus.PRE_COMMITTEE_A_PENDING_APPROVAL
: PrequalificationStatus.COMPLETED;
}

return null;
PrequalificationStatusRange initialStatusRange = resolveIndividualStatusRange(prequalificationGroup, action);

PrequalificationStatus initialStatus = PrequalificationStatus.fromInt(initialStatusRange.getStatus());
PrequalificationStatus currentStatus = PrequalificationStatus.fromInt(prequalificationGroup.getStatus());

PrequalificationStatus finalStatus = currentStatus;
if (initialStatus.getValue().equals(currentStatus.getValue())) {
if (currentStatus.equals(PrequalificationStatus.PRE_COMMITTEE_D_PENDING_APPROVAL)) {
finalStatus = PrequalificationStatus.PRE_COMMITTEE_C_PENDING_APPROVAL;
} else if (currentStatus.equals(PrequalificationStatus.PRE_COMMITTEE_C_PENDING_APPROVAL)) {
finalStatus = PrequalificationStatus.PRE_COMMITTEE_B_PENDING_APPROVAL;
} else if (currentStatus.equals(PrequalificationStatus.PRE_COMMITTEE_B_PENDING_APPROVAL)) {
finalStatus = PrequalificationStatus.PRE_COMMITTEE_A_PENDING_APPROVAL;
} else if (currentStatus.equals(PrequalificationStatus.PRE_COMMITTEE_A_PENDING_APPROVAL)) {
finalStatus = PrequalificationStatus.COMPLETED;
}
} else {
finalStatus = PrequalificationStatus.COMPLETED;
}

return finalStatus;
}

private PrequalificationStatus resolveStatus(String action) {
Expand All @@ -865,10 +864,10 @@ private PrequalificationStatus resolveStatus(String action) {
return status;
}

private PrequalificationStatus resolveIndividualStatus(PrequalificationGroup prequalificationGroup, String action) {
PrequalificationStatus status = null;
private PrequalificationStatusRange resolveIndividualStatusRange(PrequalificationGroup prequalificationGroup, String action) {
PrequalificationStatusRange finalRange = null;

if (action.equalsIgnoreCase("approveanalysis")) {
if (action.equalsIgnoreCase("approveanalysis") || action.equalsIgnoreCase("approveCommittee")) {

GroupPrequalificationData prequalificationData = prequalificationReadPlatformService.retrieveOne(prequalificationGroup.getId());
int numberOfErrors = prequalificationData.getRedValidationCount() > 0
Expand All @@ -883,16 +882,16 @@ private PrequalificationStatus resolveIndividualStatus(PrequalificationGroup pre
for (PrequalificationStatusRange statusRange : statusRangeList) {
if (amount.compareTo(statusRange.getMinAmount()) >= 0
&& (statusRange.getMaxAmount() != null && amount.compareTo(statusRange.getMaxAmount()) <= 0)) {
status = PrequalificationStatus.fromInt(statusRange.getStatus());
finalRange = statusRange;
break;
} else if (amount.compareTo(statusRange.getMinAmount()) >= 0 && statusRange.getMaxAmount() == null) {
status = PrequalificationStatus.fromInt(statusRange.getStatus());
finalRange = statusRange;
break;
}
}
}

return status;
return finalRange;
}

private PrequalificationType resolvePrequalificationType(LoanProduct loanProduct) {
Expand Down

0 comments on commit 00dcf71

Please sign in to comment.