Skip to content

Commit

Permalink
FBR-485 - Wrong status for Individual prequalification (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardohildt authored Dec 14, 2023
1 parent 7f7c97c commit 6e63d19
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ public static EnumOptionData status(final PrequalificationStatus status) {
PrequalificationStatus.ANALYSIS_UNIT_PENDING_APPROVAL_WITH_EXCEPTIONS.getValue().longValue(),
PrequalificationStatus.ANALYSIS_UNIT_PENDING_APPROVAL_WITH_EXCEPTIONS.getCode(),
"ANALYSIS_UNIT_PENDING_APPROVAL_WITH_EXCEPTIONS");
case PRE_COMMITTEE_D_PENDING_APPROVAL -> new EnumOptionData(
PrequalificationStatus.PRE_COMMITTEE_D_PENDING_APPROVAL.getValue().longValue(),
PrequalificationStatus.PRE_COMMITTEE_D_PENDING_APPROVAL.getCode(), "PRE_COMMITTEE_D_PENDING_APPROVAL");
case PRE_COMMITTEE_A_PENDING_APPROVAL -> new EnumOptionData(
PrequalificationStatus.PRE_COMMITTEE_A_PENDING_APPROVAL.getValue().longValue(),
PrequalificationStatus.PRE_COMMITTEE_A_PENDING_APPROVAL.getCode(), "PRE_COMMITTEE_A_PENDING_APPROVAL");
case PRE_COMMITTEE_B_PENDING_APPROVAL -> new EnumOptionData(
PrequalificationStatus.PRE_COMMITTEE_B_PENDING_APPROVAL.getValue().longValue(),
PrequalificationStatus.PRE_COMMITTEE_B_PENDING_APPROVAL.getCode(), "PRE_COMMITTEE_B_PENDING_APPROVAL");
case PRE_COMMITTEE_C_PENDING_APPROVAL -> new EnumOptionData(
PrequalificationStatus.PRE_COMMITTEE_C_PENDING_APPROVAL.getValue().longValue(),
PrequalificationStatus.PRE_COMMITTEE_C_PENDING_APPROVAL.getCode(), "PRE_COMMITTEE_C_PENDING_APPROVAL");
case PRE_COMMITTEE_A_PENDING_APPROVAL -> new EnumOptionData(
PrequalificationStatus.PRE_COMMITTEE_A_PENDING_APPROVAL.getValue().longValue(),
PrequalificationStatus.PRE_COMMITTEE_A_PENDING_APPROVAL.getCode(), "PRE_COMMITTEE_A_PENDING_APPROVAL");
case PRE_COMMITTEE_D_PENDING_APPROVAL -> new EnumOptionData(
PrequalificationStatus.PRE_COMMITTEE_D_PENDING_APPROVAL.getValue().longValue(),
PrequalificationStatus.PRE_COMMITTEE_D_PENDING_APPROVAL.getCode(), "PRE_COMMITTEE_D_PENDING_APPROVAL");
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 @@ -63,7 +63,6 @@
import org.apache.fineract.organisation.prequalification.command.PrequalificationDataValidator;
import org.apache.fineract.organisation.prequalification.command.PrequalificatoinApiConstants;
import org.apache.fineract.organisation.prequalification.data.GenericValidationResultSet;
import org.apache.fineract.organisation.prequalification.data.GroupPrequalificationData;
import org.apache.fineract.organisation.prequalification.data.LoanData;
import org.apache.fineract.organisation.prequalification.data.MemberPrequalificationData;
import org.apache.fineract.organisation.prequalification.data.PrequalificationChecklistData;
Expand Down Expand Up @@ -1105,27 +1104,38 @@ private PrequalificationStatusRange resolveIndividualStatusRange(Prequalificatio
PrequalificationStatusRange finalRange = null;

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

GroupPrequalificationData prequalificationData = prequalificationReadPlatformService.retrieveOne(prequalificationGroup.getId());
int numberOfErrors = prequalificationData.getRedValidationCount() > 0
? Math.toIntExact(prequalificationData.getRedValidationCount())
: 0;

BigDecimal amount = prequalificationGroup.getTotalRequestedAmount();
PrequalificationChecklistData prequalificationChecklistData = this.prequalificationChecklistReadPlatformService
.retrieveHardPolicyValidationResults(prequalificationGroup.getId());
List<List<String>> rows = prequalificationChecklistData.getMembers().getRows();
AtomicReference<Integer> redCountRef = new AtomicReference<>(0);
for (List<String> innerList : rows) {
innerList.forEach(item -> {
if ("RED".equalsIgnoreCase(item)) {
redCountRef.getAndSet(redCountRef.get() + 1);
}
});
}
Integer redCounts = redCountRef.get();

List<PrequalificationStatusRange> statusRangeList = this.prequalificationStatusRangeRepository
.findByPrequalificationTypeAndNumberOfErrors(prequalificationGroup.getPrequalificationType(), numberOfErrors);

for (PrequalificationStatusRange statusRange : statusRangeList) {
if (amount.compareTo(statusRange.getMinAmount()) >= 0
&& (statusRange.getMaxAmount() != null && amount.compareTo(statusRange.getMaxAmount()) <= 0)) {
finalRange = statusRange;
break;
} else if (amount.compareTo(statusRange.getMinAmount()) >= 0 && statusRange.getMaxAmount() == null) {
finalRange = statusRange;
break;
.findByPrequalificationTypeAndNumberOfErrors(prequalificationGroup.getPrequalificationType(), redCounts);

if (statusRangeList.size() == 1) {
finalRange = statusRangeList.get(0);
} else {
for (PrequalificationStatusRange statusRange : statusRangeList) {
if (amount.compareTo(statusRange.getMinAmount()) >= 0
&& (statusRange.getMaxAmount() != null && amount.compareTo(statusRange.getMaxAmount()) <= 0)) {
finalRange = statusRange;
break;
} else if (amount.compareTo(statusRange.getMinAmount()) >= 0 && statusRange.getMaxAmount() == null) {
finalRange = statusRange;
break;
}
}
}

}

return finalRange;
Expand Down

0 comments on commit 6e63d19

Please sign in to comment.