Skip to content

Commit

Permalink
reload document verifications
Browse files Browse the repository at this point in the history
  • Loading branch information
banterCZ committed Nov 10, 2022
1 parent 1e2534b commit 96e4609
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,23 +352,25 @@ public void processDocumentVerificationResult(final OwnerId ownerId, final Ident
* Move identity verification to {@code DOCUMENT_VERIFICATION} phase and status based on the given document verifications.
*
* @param idVerification Identity verification entity.
* @param docVerifications Document verifications to determine identity verification status.
* @param docVerificationsToProcess Document verifications to determine identity verification status.
*/
private void moveToDocumentVerificationAndStatusByDocuments(
final IdentityVerificationEntity idVerification,
final List<DocumentVerificationEntity> docVerifications,
final List<DocumentVerificationEntity> docVerificationsToProcess,
final OwnerId ownerId) {

final String identityVerificationId = idVerification.getId();
// docVerificationsToProcess have been modified, so idVerification.getDocumentVerifications() must be reloaded to reflect these modifications
final List<DocumentVerificationEntity> allDocumentVerifications = documentVerificationRepository.findAllUsedForVerification(idVerification);

final boolean allRequiredDocumentsChecked = requiredDocumentTypesCheck.evaluate(idVerification.getDocumentVerifications(), identityVerificationId);
final boolean allRequiredDocumentsChecked = requiredDocumentTypesCheck.evaluate(allDocumentVerifications, identityVerificationId);
if (!allRequiredDocumentsChecked) {
logger.debug("Not all required document types are present yet for identity verification ID: {}", identityVerificationId);
} else {
logger.debug("All required document types are present for identity verification ID: {}", identityVerificationId);
}

if (docVerifications.stream()
if (docVerificationsToProcess.stream()
.map(DocumentVerificationEntity::getStatus)
.allMatch(it -> it == DocumentStatus.ACCEPTED)) {
// The timestampFinished parameter is not set yet, there may be other steps ahead
Expand All @@ -382,8 +384,8 @@ private void moveToDocumentVerificationAndStatusByDocuments(
} else {
// Identity verification status is changed to DOCUMENT_UPLOAD / IN_PROGRESS to allow re-submission of failed documents
moveToDocumentUpload(ownerId, idVerification, IN_PROGRESS);
handleDocumentStatus(docVerifications, idVerification, DocumentStatus.FAILED, ownerId);
handleDocumentStatus(docVerifications, idVerification, DocumentStatus.REJECTED, ownerId);
handleDocumentStatus(docVerificationsToProcess, idVerification, DocumentStatus.FAILED, ownerId);
handleDocumentStatus(docVerificationsToProcess, idVerification, DocumentStatus.REJECTED, ownerId);
}
}

Expand Down

0 comments on commit 96e4609

Please sign in to comment.