Skip to content

Commit

Permalink
feat(registration): added a flag to make submit document type validat…
Browse files Browse the repository at this point in the history
…ion optional
  • Loading branch information
dhiren-singh-007 committed Jul 19, 2024
1 parent 1816125 commit bc393d5
Show file tree
Hide file tree
Showing 4 changed files with 325 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,17 @@ public async Task<bool> SubmitRegistrationAsync(Guid applicationId)

if (GetAndValidateUpdateApplicationStatus(applicationUserData.CompanyApplicationStatusId, UpdateApplicationSteps.SubmitRegistration) != CompanyApplicationStatusId.SUBMITTED)
{
throw new UnexpectedConditionException("updateStatus should allways be SUBMITTED here");
throw new UnexpectedConditionException("updateStatus should always be SUBMITTED here");
}

portalRepositories.GetInstance<IDocumentRepository>().AttachAndModifyDocuments(
applicationUserData.DocumentDatas.Select(x => new ValueTuple<Guid, Action<Document>?, Action<Document>>(
x.DocumentId,
doc => doc.DocumentStatusId = x.StatusId,
doc => doc.DocumentStatusId = DocumentStatusId.LOCKED)));
if (applicationUserData.DocumentDatas != null && applicationUserData.DocumentDatas.Any())
{
portalRepositories.GetInstance<IDocumentRepository>().AttachAndModifyDocuments(
applicationUserData.DocumentDatas.Select(x => new ValueTuple<Guid, Action<Document>?, Action<Document>>(
x.DocumentId,
doc => doc.DocumentStatusId = x.StatusId,
doc => doc.DocumentStatusId = DocumentStatusId.LOCKED)));
}

var entries = await checklistService.CreateInitialChecklistAsync(applicationId);

Expand Down Expand Up @@ -637,7 +640,7 @@ private async ValueTask<CompanyApplicationUserEmailData> GetAndValidateCompanyDa
{
throw new ConflictException($"Agreement and Consent must not be empty");
}
if (!applicationUserData.DocumentDatas.Any())
if (!_settings.IsSubmitDocumentValidationOptional && !applicationUserData.DocumentDatas.Any())
{
throw new ConflictException($"At least one Document type Id must be [{string.Join(", ", docTypeIds)}]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ public class RegistrationSettings
[DistinctValues]
public IEnumerable<DocumentTypeId> SubmitDocumentTypeIds { get; set; } = null!;

/// <summary>
/// Is Submit DocumentType Validation Optional
/// </summary>
/// <value></value>
[Required]
[DistinctValues]
public bool IsSubmitDocumentValidationOptional { get; set; } = false;

/// <summary>
/// Url to the password resend of the portal
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion src/registration/Registration.Service/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"ApplicationDeclineStatusIds": [],
"DocumentTypeIds": [],
"RegistrationDocumentTypeIds": [],
"SubmitDocumentTypeIds": []
"SubmitDocumentTypeIds": [],
"IsSubmitDocumentValidationOptional": false
},
"BPN_Address": "",
"Keycloak": {
Expand Down
Loading

0 comments on commit bc393d5

Please sign in to comment.