public async Task <OrganisationVerificationStatus> GetOrganisationVerificationStatus(Guid applicationId) { var verifiedCompaniesHouse = await _qnaApiClient.GetAnswer(applicationId, RoatpWorkflowSequenceIds.Preamble, RoatpWorkflowSectionIds.Preamble, RoatpWorkflowPageIds.Preamble, RoatpPreambleQuestionIdConstants.UkrlpVerificationCompany); var companiesHouseManualEntry = await _qnaApiClient.GetAnswer(applicationId, RoatpWorkflowSequenceIds.Preamble, RoatpWorkflowSectionIds.Preamble, RoatpWorkflowPageIds.Preamble, RoatpPreambleQuestionIdConstants.CompaniesHouseManualEntryRequired); var verifiedCharityCommission = await _qnaApiClient.GetAnswer(applicationId, RoatpWorkflowSequenceIds.Preamble, RoatpWorkflowSectionIds.Preamble, RoatpWorkflowPageIds.Preamble, RoatpPreambleQuestionIdConstants.UkrlpVerificationCharity); var charityCommissionManualEntry = await _qnaApiClient.GetAnswer(applicationId, RoatpWorkflowSequenceIds.Preamble, RoatpWorkflowSectionIds.Preamble, RoatpWorkflowPageIds.Preamble, RoatpPreambleQuestionIdConstants.CharityCommissionTrusteeManualEntry); var companiesHouseDataConfirmed = await _qnaApiClient.GetAnswer(applicationId, RoatpWorkflowSequenceIds.YourOrganisation, RoatpWorkflowSectionIds.YourOrganisation.WhosInControl, RoatpWorkflowPageIds.WhosInControl.CompaniesHouseStartPage, RoatpYourOrganisationQuestionIdConstants.CompaniesHouseDetailsConfirmed); var charityCommissionDataConfirmed = await _qnaApiClient.GetAnswer(applicationId, RoatpWorkflowSequenceIds.YourOrganisation, RoatpWorkflowSectionIds.YourOrganisation.WhosInControl, RoatpWorkflowPageIds.WhosInControl.CharityCommissionStartPage, RoatpYourOrganisationQuestionIdConstants.CharityCommissionDetailsConfirmed); var organisationType = await _qnaApiClient.GetAnswer(applicationId, RoatpWorkflowSequenceIds.YourOrganisation, RoatpWorkflowSectionIds.YourOrganisation.WhosInControl, RoatpWorkflowPageIds.WhosInControl.SoleTraderPartnership, RoatpYourOrganisationQuestionIdConstants.SoleTradeOrPartnership); var whosInControlStarted = organisationType != null && (organisationType.Value == RoatpOrganisationTypes.SoleTrader || organisationType.Value == RoatpOrganisationTypes.Partnership); var whosInControlConfirmed = false; if (organisationType != null && organisationType.Value == RoatpOrganisationTypes.SoleTrader) { var soleTraderDateOfBirthAnswer = await _qnaApiClient.GetAnswer(applicationId, RoatpWorkflowSequenceIds.YourOrganisation, RoatpWorkflowSectionIds.YourOrganisation.WhosInControl, RoatpWorkflowPageIds.WhosInControl.AddSoleTraderDob, RoatpYourOrganisationQuestionIdConstants.AddSoleTradeDob); if (soleTraderDateOfBirthAnswer != null && !String.IsNullOrEmpty(soleTraderDateOfBirthAnswer.Value)) { whosInControlConfirmed = true; } } else if (organisationType != null && organisationType.Value == RoatpOrganisationTypes.Partnership) { var partnersDetailsAnswer = await _qnaApiClient.GetAnswer(applicationId, RoatpWorkflowSequenceIds.YourOrganisation, RoatpWorkflowSectionIds.YourOrganisation.WhosInControl, RoatpWorkflowPageIds.WhosInControl.AddPartners, RoatpYourOrganisationQuestionIdConstants.AddPartners); if (partnersDetailsAnswer != null && !String.IsNullOrEmpty(partnersDetailsAnswer.Value)) { whosInControlConfirmed = true; } } var pscsDetailsAnswer = await _qnaApiClient.GetAnswer(applicationId, RoatpWorkflowSequenceIds.YourOrganisation, RoatpWorkflowSectionIds.YourOrganisation.WhosInControl, RoatpWorkflowPageIds.WhosInControl.AddPeopleInControl, RoatpYourOrganisationQuestionIdConstants.AddPeopleInControl); if (pscsDetailsAnswer != null && !String.IsNullOrEmpty(pscsDetailsAnswer.Value)) { whosInControlConfirmed = true; } var status = new OrganisationVerificationStatus { VerifiedCompaniesHouse = (verifiedCompaniesHouse != null && verifiedCompaniesHouse.Value == "TRUE"), VerifiedCharityCommission = (verifiedCharityCommission != null && verifiedCharityCommission.Value == "TRUE"), CompaniesHouseManualEntry = (companiesHouseManualEntry != null && companiesHouseManualEntry.Value == "TRUE"), CharityCommissionManualEntry = (charityCommissionManualEntry != null && charityCommissionManualEntry.Value == "TRUE"), CompaniesHouseDataConfirmed = (companiesHouseDataConfirmed != null && companiesHouseDataConfirmed.Value == "Y"), CharityCommissionDataConfirmed = (charityCommissionDataConfirmed != null && charityCommissionDataConfirmed.Value == "Y"), WhosInControlConfirmed = whosInControlConfirmed, WhosInControlStarted = whosInControlStarted }; return(status); }
private async Task <bool> IsSectionLocked(Guid applicationId, int sequenceId, int sectionId, List <ApplicationSequence> sequences, OrganisationVerificationStatus organisationVerificationStatus, bool yourOrganisationSequenceCompleted, bool applicationSequencesCompleted) { // Disable the other sequences if YourOrganisation sequence isn't complete if (sequenceId != RoatpWorkflowSequenceIds.YourOrganisation && !yourOrganisationSequenceCompleted) { return(true); } //Within Your Organisation, sections are locked until the previous one is completed if (sequenceId == RoatpWorkflowSequenceIds.YourOrganisation && sectionId != 1) { return(!await _roatpTaskListWorkflowService.PreviousSectionCompleted(applicationId, sequenceId, sectionId, sequences, organisationVerificationStatus)); } //Entire Finish section is locked until all app sequences are completed, and sections are locked until previous one is completed if (sequenceId == RoatpWorkflowSequenceIds.Finish) { return(!applicationSequencesCompleted || !await _roatpTaskListWorkflowService.PreviousSectionCompleted(applicationId, sequenceId, sectionId, sequences, organisationVerificationStatus)); } // CriminalComplianceChecks has two intro pages... if (sequenceId == RoatpWorkflowSequenceIds.CriminalComplianceChecks) { var SecondCriminialIntroductionSectionId = 3; if (sectionId > SecondCriminialIntroductionSectionId) { var statusOfSecondIntroductionPage = _roatpTaskListWorkflowService.SectionQuestionsStatus(applicationId, RoatpWorkflowSequenceIds.CriminalComplianceChecks, SecondCriminialIntroductionSectionId, sequences); if (statusOfSecondIntroductionPage != TaskListSectionStatus.Completed) { return(true); } } } var statusOfIntroductionPage = _roatpTaskListWorkflowService.SectionQuestionsStatus(applicationId, sequenceId, 1, sequences); if (sequenceId > 1 && sectionId != 1 && statusOfIntroductionPage != TaskListSectionStatus.Completed) { return(true); } return(false); }
private async Task <bool> ApplicationSequencesCompleted(Guid applicationId, IEnumerable <ApplicationSequence> sequences, OrganisationVerificationStatus organisationVerificationStatus) { var nonFinishSequences = sequences.Where(seq => seq.SequenceId != RoatpWorkflowSequenceIds.Finish).ToList(); foreach (var sequence in nonFinishSequences) { foreach (var section in sequence.Sections) { var sectionStatus = await _roatpTaskListWorkflowService.SectionStatusAsync(applicationId, sequence.SequenceId, section.SectionId, sequences, organisationVerificationStatus); if (sectionStatus != TaskListSectionStatus.NotRequired && sectionStatus != TaskListSectionStatus.Completed) { return(false); } } } return(true); }
private async Task <bool> IsYourOrganisationSequenceCompleted(Guid applicationId, IEnumerable <ApplicationSequence> sequences, OrganisationVerificationStatus organisationVerificationStatus) { var yourOrganisationSequenceCompleted = true; var yourOrganisationSequence = sequences.First(x => x.SequenceId == RoatpWorkflowSequenceIds.YourOrganisation); foreach (var section in yourOrganisationSequence.Sections) { var sectionStatus = await _roatpTaskListWorkflowService.SectionStatusAsync(applicationId, RoatpWorkflowSequenceIds.YourOrganisation, section.SectionId, sequences, organisationVerificationStatus); if (sectionStatus != TaskListSectionStatus.NotRequired && sectionStatus != TaskListSectionStatus.Completed) { yourOrganisationSequenceCompleted = false; break; } } return(yourOrganisationSequenceCompleted); }
public async Task <bool> PreviousSectionCompleted(Guid applicationId, int sequenceId, int sectionId, IEnumerable <ApplicationSequence> applicationSequences, OrganisationVerificationStatus organisationVerificationStatus) { var sequence = applicationSequences.FirstOrDefault(x => x.SequenceId == sequenceId); if (sequence is null) { _logger.LogError($"PreviousSectionCompleted - Sequence '{sequenceId}' could not found in Application {applicationId}"); return(false); } else if (sequence.SequenceId == RoatpWorkflowSequenceIds.YourOrganisation) { var complete = true; for (var index = 1; index < sectionId; index++) { if (await SectionStatusAsync(applicationId, RoatpWorkflowSequenceIds.YourOrganisation, index, applicationSequences, organisationVerificationStatus) != TaskListSectionStatus.Completed) { complete = false; break; } } return(complete); } else if (sequence.SequenceId == RoatpWorkflowSequenceIds.Finish) { if (sectionId == 1) { return(true); } else { var previousSectionStatus = string.Empty; // This loop goes to the next previous section if it happens to be 'Not required' for (var previousSectionId = sectionId - 1; previousSectionId > 0; previousSectionId--) { previousSectionStatus = await SectionStatusAsync(applicationId, sequenceId, previousSectionId, applicationSequences, organisationVerificationStatus); if (previousSectionStatus != TaskListSectionStatus.NotRequired) { break; } } return(previousSectionStatus == TaskListSectionStatus.Completed); } } else if (sequence.Sequential && sectionId > 1) { var previousSection = sequence.Sections.FirstOrDefault(x => x.SectionId == (sectionId - 1)); if (previousSection == null) { return(false); } if (previousSection.PagesActive == previousSection.PagesComplete && previousSection.PagesComplete > 0) { return(true); } var previousSectionsCompletedCount = SectionCompletedQuestionsCount(previousSection); if (previousSectionsCompletedCount == 0) { return(false); } var previousSectionQuestionsCount = previousSection.QnAData.Pages.Where(p => !p.NotRequired).SelectMany(x => x.Questions) .DistinctBy(q => q.QuestionId).Count(); if (previousSectionsCompletedCount < previousSectionQuestionsCount) { return(false); } } return(true); }
public async Task <string> SectionStatusAsync(Guid applicationId, int sequenceId, int sectionId, IEnumerable <ApplicationSequence> applicationSequences, OrganisationVerificationStatus organisationVerificationStatus) { var sectionNotRequired = await SectionNotRequired(applicationId, sequenceId, sectionId); if (sectionNotRequired) { return(TaskListSectionStatus.NotRequired); } if (sequenceId == RoatpWorkflowSequenceIds.YourOrganisation && sectionId == RoatpWorkflowSectionIds.YourOrganisation.WhosInControl) { return(await WhosInControlSectionStatus(applicationId, applicationSequences, organisationVerificationStatus)); } var sequence = applicationSequences?.FirstOrDefault(x => x.SequenceId == sequenceId); var section = sequence?.Sections?.FirstOrDefault(x => x.SectionId == sectionId); if (section == null) { return(string.Empty); } if (!await PreviousSectionCompleted(applicationId, sequence.SequenceId, sectionId, applicationSequences, organisationVerificationStatus)) { return(string.Empty); } var questionsCompleted = SectionCompletedQuestionsCount(section); var sectionText = GetSectionText(questionsCompleted, section, sequence.Sequential); return(sectionText); }
public string SectionStatus(Guid applicationId, int sequenceId, int sectionId, IEnumerable <ApplicationSequence> applicationSequences, OrganisationVerificationStatus organisationVerificationStatus) { return(SectionStatusAsync(applicationId, sequenceId, sectionId, applicationSequences, organisationVerificationStatus) .GetAwaiter().GetResult()); }
private async Task <string> WhosInControlSectionStatus(Guid applicationId, IEnumerable <ApplicationSequence> applicationSequences, OrganisationVerificationStatus organisationVerificationStatus) { if (await SectionStatusAsync(applicationId, RoatpWorkflowSequenceIds.YourOrganisation, RoatpWorkflowSectionIds.YourOrganisation.OrganisationDetails, applicationSequences, organisationVerificationStatus) == TaskListSectionStatus.Blank) { return(TaskListSectionStatus.Blank); } if ((organisationVerificationStatus.CompaniesHouseManualEntry || organisationVerificationStatus.CharityCommissionManualEntry) && !organisationVerificationStatus.CharityCommissionDataConfirmed && !organisationVerificationStatus.CompaniesHouseDataConfirmed && !organisationVerificationStatus.WhosInControlConfirmed) { return(TaskListSectionStatus.Next); } var companiesHouseVerified = organisationVerificationStatus.CompaniesHouseDataConfirmed || organisationVerificationStatus.CompaniesHouseManualEntry; var charityCommissionVerified = organisationVerificationStatus.CharityCommissionDataConfirmed || organisationVerificationStatus.CharityCommissionManualEntry; if (organisationVerificationStatus.VerifiedCompaniesHouse && organisationVerificationStatus.VerifiedCharityCommission) { if ((companiesHouseVerified && !charityCommissionVerified) || (!companiesHouseVerified && charityCommissionVerified)) { return(TaskListSectionStatus.InProgress); } if (companiesHouseVerified && charityCommissionVerified) { return(TaskListSectionStatus.Completed); } } if (organisationVerificationStatus.VerifiedCompaniesHouse && !organisationVerificationStatus.VerifiedCharityCommission) { if (companiesHouseVerified) { return(TaskListSectionStatus.Completed); } } if (!organisationVerificationStatus.VerifiedCompaniesHouse && organisationVerificationStatus.VerifiedCharityCommission) { if (charityCommissionVerified) { return(TaskListSectionStatus.Completed); } } if (organisationVerificationStatus.WhosInControlConfirmed) { return(TaskListSectionStatus.Completed); } if (organisationVerificationStatus.WhosInControlStarted) { return(TaskListSectionStatus.InProgress); } return(TaskListSectionStatus.Next); }