public RoatpFinancialApplicationViewModel(RoatpApply application, FinancialReviewDetails financialReviewDetails, Section parentCompanySection, Section activelyTradingSection, Section organisationTypeSection, List <Section> financialSections)
        {
            ApplicationId = application.ApplicationId;
            OrgId         = application.OrganisationId;

            ApplicationStatus = application.ApplicationStatus;

            Sections = SetupSections(parentCompanySection, activelyTradingSection, organisationTypeSection, financialSections);
            SetupGradeAndFinancialDueDate(financialReviewDetails);

            if (application.ApplyData?.ApplyDetails != null)
            {
                ApplicationReference = application.ApplyData.ApplyDetails.ReferenceNumber;
                ApplicationRoute     = application.ApplyData.ApplyDetails.ProviderRouteName;
                Ukprn            = application.ApplyData.ApplyDetails.UKPRN;
                OrganisationName = application.ApplyData.ApplyDetails.OrganisationName;
                SubmittedDate    = application.ApplyData.ApplyDetails.ApplicationSubmittedOn;

                if (application.ApplicationStatus == AssessorService.ApplyTypes.Roatp.ApplicationStatus.Withdrawn)
                {
                    ApplicationClosedOn = application.ApplyData.ApplyDetails.ApplicationWithdrawnOn;
                    ApplicationClosedBy = application.ApplyData.ApplyDetails.ApplicationWithdrawnBy;
                }
                else if (application.ApplicationStatus == AssessorService.ApplyTypes.Roatp.ApplicationStatus.Removed)
                {
                    ApplicationClosedOn = application.ApplyData.ApplyDetails.ApplicationRemovedOn;
                    ApplicationClosedBy = application.ApplyData.ApplyDetails.ApplicationRemovedBy;
                }
            }

            ApplicationComments         = application.Comments;
            ApplicationExternalComments = application.ExternalComments;

            SetupDeclaredInApplication(application.ApplyData);
        }
Beispiel #2
0
        private FinancialReviewDetails RebuildFinancialReviewDetailsForSubmission(RoatpFinancialClarificationViewModel vm)
        {
            var comments         = vm.Comments;
            var externalComments = default(string);

            if (vm.FinancialReviewDetails.SelectedGrade == FinancialApplicationSelectedGrade.Inadequate)
            {
                comments         = vm.InadequateComments;
                externalComments = vm.InadequateExternalComments;
            }

            var financialReviewDetails = new FinancialReviewDetails
            {
                GradedBy                 = _contextAccessor.HttpContext.User.UserDisplayName(),
                GradedDateTime           = DateTime.UtcNow,
                SelectedGrade            = vm.FinancialReviewDetails.SelectedGrade,
                FinancialDueDate         = GetFinancialDueDate(vm),
                Comments                 = comments,
                ExternalComments         = externalComments,
                ClarificationResponse    = vm.ClarificationResponse,
                ClarificationRequestedOn = vm.FinancialReviewDetails.ClarificationRequestedOn,
                ClarificationFiles       = vm.FinancialReviewDetails.ClarificationFiles
            };

            return(financialReviewDetails);
        }
        public async Task <IActionResult> RecordGrade(Guid applicationId, [FromBody] FinancialReviewDetails financialReviewDetails)
        {
            if (financialReviewDetails != null)
            {
                // Note: This gets around the WAF block
                financialReviewDetails.FinancialEvidences = await GetFinancialEvidence(applicationId);
            }

            await _mediator.Send(new RecordGradeRequest(applicationId, financialReviewDetails));

            return(Ok());
        }
        private void SetupGradeAndFinancialDueDate(FinancialReviewDetails financialReviewDetails)
        {
            FinancialReviewDetails = financialReviewDetails ?? new FinancialReviewDetails();

            OutstandingFinancialDueDate  = new FinancialDueDate();
            GoodFinancialDueDate         = new FinancialDueDate();
            SatisfactoryFinancialDueDate = new FinancialDueDate();

            if (FinancialReviewDetails.FinancialDueDate.HasValue)
            {
                var day   = FinancialReviewDetails.FinancialDueDate.Value.Day.ToString();
                var month = FinancialReviewDetails.FinancialDueDate.Value.Month.ToString();
                var year  = FinancialReviewDetails.FinancialDueDate.Value.Year.ToString();

                switch (FinancialReviewDetails.SelectedGrade)
                {
                case FinancialApplicationSelectedGrade.Outstanding:
                    OutstandingFinancialDueDate = new FinancialDueDate {
                        Day = day, Month = month, Year = year
                    };
                    break;

                case FinancialApplicationSelectedGrade.Good:
                    GoodFinancialDueDate = new FinancialDueDate {
                        Day = day, Month = month, Year = year
                    };
                    break;

                case FinancialApplicationSelectedGrade.Satisfactory:
                    SatisfactoryFinancialDueDate = new FinancialDueDate {
                        Day = day, Month = month, Year = year
                    };
                    break;

                default:
                    break;
                }
            }

            if (FinancialReviewDetails.SelectedGrade == FinancialApplicationSelectedGrade.Inadequate)
            {
                InadequateComments         = FinancialReviewDetails.Comments;
                InadequateExternalComments = FinancialReviewDetails.ExternalComments;
            }
            else if (FinancialReviewDetails.SelectedGrade == FinancialApplicationSelectedGrade.Clarification)
            {
                ClarificationComments = FinancialReviewDetails.Comments;
            }
        }
Beispiel #5
0
 public async Task <bool> UpdateFinancialReviewDetails(Guid applicationId, FinancialReviewDetails financialReviewDetails)
 {
     using (var connection = new SqlConnection(_config.SqlConnectionString))
     {
         await connection.ExecuteAsync(@"UPDATE Apply 
                                                  SET FinancialGrade = @financialReviewDetails
                                                  WHERE ApplicationId = @applicationId
                                                     AND apply.DeletedAt IS NULL",
                                       new
         {
             applicationId,
             financialReviewDetails
         });
     }
     return(true);
 }
        public void TestSetup()
        {
            _applicationId          = Guid.NewGuid();
            _financialReviewDetails = new FinancialReviewDetails {
                ApplicationId = _applicationId
            };
            _clarificationFile = new ClarificationFile {
                Filename = "file.pdf"
            };
            _clarificationFiles = new List <ClarificationFile> {
                _clarificationFile
            };
            _repository = new Mock <IApplyRepository>();
            _repository.Setup(x => x.GetFinancialReviewDetails(_applicationId)).ReturnsAsync(_financialReviewDetails);
            _repository.Setup(x => x.GetFinancialReviewClarificationFiles(_applicationId)).ReturnsAsync(_clarificationFiles);

            _handler = new GetFinancialReviewDetailsHandler(_repository.Object);
        }
Beispiel #7
0
        public async Task <bool> RecordFinancialGrade(Guid applicationId, FinancialReviewDetails financialReviewDetails, string financialReviewStatus)
        {
            using (var connection = new SqlConnection(_config.SqlConnectionString))
            {
                await connection.ExecuteAsync(@"UPDATE Apply 
                                                         SET FinancialGrade = @financialReviewDetails,
                                                         FinancialReviewStatus = @financialReviewStatus
                                                         WHERE ApplicationId = @applicationId",
                                              new
                {
                    applicationId,
                    financialReviewDetails,
                    financialReviewStatus
                });
            }

            return(true);
        }
Beispiel #8
0
        public async Task <IActionResult> GradeApplication(Guid applicationId, [FromForm] RoatpFinancialApplicationViewModel vm)
        {
            var application = await _applyApiClient.GetApplication(vm.ApplicationId);

            if (application is null)
            {
                return(RedirectToAction(nameof(OpenApplications)));
            }

            if (ModelState.IsValid)
            {
                var financialReviewDetails = new FinancialReviewDetails
                {
                    GradedBy         = _contextAccessor.HttpContext.User.UserDisplayName(),
                    GradedDateTime   = DateTime.UtcNow,
                    SelectedGrade    = vm.FinancialReviewDetails.SelectedGrade,
                    FinancialDueDate = GetFinancialDueDate(vm),
                    Comments         = GetFinancialReviewComments(vm),
                    ExternalComments = GetFinancialReviewExternalComments(vm)
                };

                await _applyApiClient.ReturnFinancialReview(vm.ApplicationId, financialReviewDetails);

                return(RedirectToAction(nameof(Graded), new { vm.ApplicationId }));
            }
            else
            {
                var newvm = await CreateRoatpFinancialApplicationViewModel(application);

                newvm.ApplicantEmailAddress      = vm.ApplicantEmailAddress;
                newvm.InadequateComments         = vm.InadequateComments;
                newvm.InadequateExternalComments = vm.InadequateExternalComments;
                newvm.ClarificationComments      = vm.ClarificationComments;

                // For now, only replace selected grade with whatever was selected
                if (vm.FinancialReviewDetails != null)
                {
                    newvm.FinancialReviewDetails.SelectedGrade = vm.FinancialReviewDetails.SelectedGrade;
                }

                return(View("~/Views/Roatp/Apply/Financial/Application.cshtml", newvm));
            }
        }
        public void Before_each_test()
        {
            _roatpOrganisationApiClient = new Mock <IRoatpOrganisationApiClient>();
            _applicationApplyApiClient  = new Mock <IRoatpApplicationApiClient>();
            _clarificationValidator     = new Mock <IRoatpFinancialClarificationViewModelValidator>();
            _qnaApiClient     = new Mock <IQnaApiClient>();
            _csvExportService = new Mock <ICsvExportService>();


            _financialReviewDetails = new FinancialReviewDetails();
            MockHttpContextAccessor = SetupMockedHttpContextAccessor();

            _controller = new RoatpFinancialController(_roatpOrganisationApiClient.Object,
                                                       _applicationApplyApiClient.Object,
                                                       _qnaApiClient.Object,
                                                       MockHttpContextAccessor.Object, _clarificationValidator.Object, _csvExportService.Object)
            {
                ControllerContext = MockedControllerContext.Setup()
            };
        }
        public async Task moderator_pass_with_failed_moderator_questions_returns_model_with_no_sequences_and_external_comments()
        {
            var submittedApp = new Apply
            {
                ApplicationStatus   = ApplicationStatus.Unsuccessful,
                ApplicationId       = _applicationId,
                GatewayReviewStatus = GatewayReviewStatus.Pass,
                ModerationStatus    = ModerationStatus.Pass,
                ApplyData           = new ApplyData
                {
                    ApplyDetails = new ApplyDetails
                    {
                        UKPRN = "11112222"
                    }
                }
            };

            _applicationApiClient.Setup(x => x.GetApplication(_applicationId)).ReturnsAsync(submittedApp);

            var financialReviewDetails = new FinancialReviewDetails
            {
                SelectedGrade    = FinancialApplicationSelectedGrade.Outstanding,
                ExternalComments = "financial external comments",
                Status           = FinancialReviewStatus.Pass
            };

            _applicationApiClient.Setup(x => x.GetFinancialReviewDetails(_applicationId)).ReturnsAsync(financialReviewDetails);

            var oversightExternalComments = "oversight external comments";

            _outcomeApiClient.Setup(x => x.GetOversightReview(_applicationId)).ReturnsAsync(new GetOversightReviewResponse {
                ModerationApproved = false, ExternalComments = oversightExternalComments
            });

            var result = await _service.BuildApplicationSummaryViewModelWithGatewayAndModerationDetails(_applicationId, _emailAddress);

            result.ModerationPassOverturnedToFail.Should().Be(true);
            result.OversightExternalComments.Should().Be(oversightExternalComments);
            result.Sequences.Should().BeNullOrEmpty();
        }
        public async Task <bool> RecordFinancialGrade(Guid applicationId, FinancialReviewDetails financialReviewDetails, string financialReviewStatus)
        {
            using (var connection = _dbConnectionHelper.GetDatabaseConnection())
            {
                await connection.ExecuteAsync(@"UPDATE FinancialReview 
                                                         SET FinancialDueDate = @financialDueDate,
                                                         SelectedGrade = @selectedGrade,
                                                         GradedBy = @GradedBy,
                                                         GradedOn = @GradedOn,
                                                         ClarificationRequestedOn = @clarificationRequestedOn,
                                                         ClarificationRequestedBy = @clarificationRequestedBy,
                                                         FinancialEvidences= @financialEvidences,
                                                         Comments = @Comments,
                                                         ExternalComments = @ExternalComments,
                                                         Status = @financialReviewStatus,
                                                         ClarificationResponse=@ClarificationResponse
                                                         WHERE ApplicationId = @applicationId",
                                              new
                {
                    applicationId,
                    financialReviewDetails.SelectedGrade,
                    financialReviewDetails.FinancialDueDate,
                    financialReviewDetails.GradedBy,
                    gradedOn = financialReviewDetails.GradedOn,
                    clarificationRequestedBy = financialReviewDetails.ClarificationRequestedBy,
                    clarificationRequestedOn = financialReviewDetails.ClarificationRequestedOn,
                    financialEvidences       = financialReviewDetails.FinancialEvidences,
                    financialReviewDetails.Comments,
                    financialReviewDetails.ExternalComments,
                    financialReviewStatus,
                    financialReviewDetails.ClarificationResponse
                });
            }

            return(true);
        }
        public async Task application_unsuccessful_moderation_settings_work_as_expected(string moderationStatus, bool moderationApproved, bool moderationPassOverturnedToFail, bool moderationPassApproved, bool moderationFailAndOverturned, bool moderationFailApproved, bool sequencesInjected)
        {
            var gatewayReviewStatus = GatewayAnswerStatus.Pass;

            var submittedApp = new Apply
            {
                ApplicationStatus   = ApplicationStatus.Unsuccessful,
                ApplicationId       = _applicationId,
                GatewayReviewStatus = gatewayReviewStatus,
                ModerationStatus    = moderationStatus,
                ApplyData           = new ApplyData
                {
                    ApplyDetails = new ApplyDetails
                    {
                        UKPRN = "11112222"
                    }
                }
            };

            _applicationApiClient.Setup(x => x.GetApplication(_applicationId)).ReturnsAsync(submittedApp);

            var financialReviewDetails = new FinancialReviewDetails
            {
                SelectedGrade    = FinancialApplicationSelectedGrade.Outstanding,
                ExternalComments = "financial external comments",
                Status           = FinancialReviewStatus.Pass
            };

            _applicationApiClient.Setup(x => x.GetFinancialReviewDetails(_applicationId)).ReturnsAsync(financialReviewDetails);

            const string oversightExternalComments = "oversight external comments";

            _outcomeApiClient.Setup(x => x.GetOversightReview(_applicationId)).ReturnsAsync(new GetOversightReviewResponse {
                GatewayApproved = true, ModerationApproved = moderationApproved, ExternalComments = oversightExternalComments
            });

            var sequences = SetUpAsessorSequences();

            _outcomeApiClient.Setup(x => x.GetClarificationSequences(_applicationId)).ReturnsAsync(sequences);

            var clarificationPages = SetUpClarificationOutcomes();

            _outcomeApiClient.Setup(x => x.GetAllClarificationPageReviewOutcomes(It.IsAny <Guid>(), It.IsAny <string>()))
            .ReturnsAsync(clarificationPages);
            var sections = SetUpApplicationSections(true, false, "answer", null);

            _qnaApiClient.Setup(x => x.GetSections(_applicationId)).ReturnsAsync(sections);

            var result = await _service.BuildApplicationSummaryViewModelWithGatewayAndModerationDetails(_applicationId, _emailAddress);

            result.ModerationStatus.Should().Be(moderationStatus);
            result.ModerationPassApproved.Should().Be(moderationPassApproved);
            result.ModerationFailApproved.Should().Be(moderationFailApproved);
            result.ModerationFailOverturnedToPass.Should().Be(moderationFailAndOverturned);
            result.ModerationPassOverturnedToFail.Should().Be(moderationPassOverturnedToFail);
            result.OversightExternalComments.Should().Be(oversightExternalComments);
            if (sequencesInjected)
            {
                result.Sequences.Any().Should().Be(true);
            }
            else
            {
                result.Sequences.Should().BeNullOrEmpty();
            }
        }
 public RecordGradeRequest(Guid applicationId, FinancialReviewDetails financialReviewDetails)
 {
     ApplicationId          = applicationId;
     FinancialReviewDetails = financialReviewDetails;
 }
Beispiel #14
0
        private async Task <RoatpFinancialApplicationViewModel> RebuildApplicationViewModel(RoatpFinancialClarificationViewModel vm,
                                                                                            RoatpApply application, FinancialReviewDetails financialReviewDetails)
        {
            var clarificationVm = await CreateRoatpFinancialApplicationViewModel(application);

            clarificationVm.ApplicantEmailAddress        = vm.ApplicantEmailAddress;
            clarificationVm.ClarificationComments        = vm.ClarificationComments;
            clarificationVm.FinancialReviewDetails       = financialReviewDetails;
            clarificationVm.OutstandingFinancialDueDate  = vm.OutstandingFinancialDueDate;
            clarificationVm.GoodFinancialDueDate         = vm.GoodFinancialDueDate;
            clarificationVm.SatisfactoryFinancialDueDate = vm.SatisfactoryFinancialDueDate;
            clarificationVm.InadequateComments           = vm.InadequateComments;
            clarificationVm.InadequateExternalComments   = vm.InadequateExternalComments;
            return(clarificationVm);
        }
        public void SubmitClarification_valid_submission(string grade)
        {
            _clarificationValidator.Setup(x =>
                                          x.Validate(It.IsAny <RoatpFinancialClarificationViewModel>(), It.IsAny <bool>(), It.IsAny <bool>()))
            .Returns(new ValidationResponse {
            });

            _applicationApplyApiClient.Setup(x => x.GetApplication(It.IsAny <Guid>())).ReturnsAsync(
                new RoatpApply
            {
                ApplicationId = _applicationId,
                ApplyData     = new RoatpApplyData
                {
                    ApplyDetails = new RoatpApplyDetails
                    {
                        OrganisationName       = "org name",
                        UKPRN                  = "12344321",
                        ReferenceNumber        = "3443",
                        ProviderRouteName      = "main",
                        ApplicationSubmittedOn = DateTime.Today
                    },
                    Sequences = new List <RoatpApplySequence>
                    {
                        new RoatpApplySequence
                        {
                            SequenceNo  = 5,
                            NotRequired = true
                        }
                    }
                }
            });
            _financialReviewDetails = new FinancialReviewDetails
            {
                GradedBy                 = MockHttpContextAccessor.Name,
                GradedOn                 = DateTime.UtcNow,
                SelectedGrade            = grade,
                FinancialDueDate         = DateTime.Today.AddDays(5),
                Comments                 = "comments",
                ExternalComments         = grade == FinancialApplicationSelectedGrade.Inadequate ? "external comments" : null,
                ClarificationResponse    = "clarification response",
                ClarificationRequestedOn = DateTime.UtcNow
            };

            _applicationApplyApiClient.Setup(x => x.GetFinancialReviewDetails(_applicationId)).ReturnsAsync(_financialReviewDetails);

            var vm = new RoatpFinancialClarificationViewModel
            {
                ApplicationId               = _applicationId,
                FinancialReviewDetails      = _financialReviewDetails,
                OutstandingFinancialDueDate = new FinancialDueDate
                {
                    Day   = "1",
                    Month = "1",
                    Year  = (DateTime.Now.Year + 1).ToString()
                },
                ClarificationResponse = "clarification response",
                ClarificationComments = "clarification comments",
                FilesToUpload         = null
            };
            var result = _controller.SubmitClarification(_applicationId, vm).Result as RedirectToActionResult;

            _applicationApplyApiClient.Verify(x => x.ReturnFinancialReview(_applicationId, It.IsAny <FinancialReviewDetails>()), Times.Once);
            Assert.AreEqual("Graded", result.ActionName);
        }
        public void when_validation_errors_occur_page_refreshes_with_validation_messages()
        {
            var buttonPressed = "submitClarificationFiles";

            _applicationApplyApiClient.Setup(x => x.GetRoatpSequences()).ReturnsAsync(new List <RoatpSequence>());
            _qnaApiClient.Setup(x => x.GetSectionBySectionNo(_applicationId,
                                                             RoatpQnaConstants.RoatpSequences.YourOrganisation,
                                                             RoatpQnaConstants.RoatpSections.YourOrganisation.OrganisationDetails))
            .ReturnsAsync(new Section {
                ApplicationId = _applicationId, QnAData = new QnAData()
            });
            _qnaApiClient.Setup(x => x.GetSectionBySectionNo(_applicationId,
                                                             RoatpQnaConstants.RoatpSequences.YourOrganisation,
                                                             RoatpQnaConstants.RoatpSections.YourOrganisation.DescribeYourOrganisation))
            .ReturnsAsync(new Section {
                ApplicationId = _applicationId, QnAData = new QnAData()
            });
            _controller = new RoatpFinancialController(_roatpOrganisationApiClient.Object,
                                                       _applicationApplyApiClient.Object,
                                                       _qnaApiClient.Object,
                                                       _searchTermValidator.Object, _clarificationValidator.Object, Mock.Of <ICsvExportService>())
            {
                ControllerContext = MockedControllerContext.Setup(buttonPressed)
            };

            _clarificationValidator.Setup(x =>
                                          x.Validate(It.IsAny <RoatpFinancialClarificationViewModel>(), It.IsAny <bool>(), It.IsAny <bool>()))
            .Returns(new ValidationResponse {
                Errors = new List <ValidationErrorDetail> {
                    new ValidationErrorDetail {
                        ErrorMessage = "error message", Field = "errorField"
                    }
                }
            });

            _applicationApplyApiClient.Setup(x => x.GetApplication(It.IsAny <Guid>())).ReturnsAsync(
                new RoatpApply
            {
                ApplicationId = _applicationId,
                ApplyData     = new RoatpApplyData
                {
                    ApplyDetails = new RoatpApplyDetails
                    {
                        OrganisationName       = "org name",
                        UKPRN                  = "12344321",
                        ReferenceNumber        = "3443",
                        ProviderRouteName      = "main",
                        ApplicationSubmittedOn = DateTime.Today
                    },
                    Sequences = new List <RoatpApplySequence>
                    {
                        new RoatpApplySequence
                        {
                            SequenceNo  = 5,
                            NotRequired = true
                        }
                    }
                }
            });

            _applicationApplyApiClient.Setup(x =>
                                             x.UploadClarificationFile(_applicationId, It.IsAny <string>(), It.IsAny <IFormFileCollection>()))
            .ReturnsAsync(true);


            _financialReviewDetails = new FinancialReviewDetails
            {
                GradedBy                 = MockHttpContextAccessor.Name,
                GradedOn                 = DateTime.UtcNow,
                SelectedGrade            = FinancialApplicationSelectedGrade.Good,
                FinancialDueDate         = DateTime.Today.AddDays(5),
                Comments                 = "comments",
                ClarificationResponse    = "clarification response",
                ClarificationRequestedOn = DateTime.UtcNow
            };

            _applicationApplyApiClient.Setup(x => x.GetFinancialReviewDetails(_applicationId)).ReturnsAsync(_financialReviewDetails);

            var vm = new RoatpFinancialClarificationViewModel
            {
                ApplicationId               = _applicationId,
                FinancialReviewDetails      = _financialReviewDetails,
                OutstandingFinancialDueDate = new FinancialDueDate
                {
                    Day   = "1",
                    Month = "1",
                    Year  = (DateTime.Now.Year + 1).ToString()
                },
                ClarificationResponse = "clarification response",
                ClarificationComments = "clarification comments",
                FilesToUpload         = null
            };
            var result = _controller.SubmitClarification(_applicationId, vm).Result as ViewResult;

            Assert.IsTrue(result.ViewName.Contains("Application_Clarification.cshtml"));
            var resultModel = result.Model as RoatpFinancialClarificationViewModel;

            Assert.AreEqual(1, resultModel.ErrorMessages.Count);
        }
        public async Task BuildApplicationSummaryViewModel_builds_expected_viewModel(string appealStatus, bool appealSubmitted)
        {
            var emailAddress         = "*****@*****.**";
            var ukprn                = "12345678";
            var organisationName     = "org name 1";
            var tradingName          = "trading name";
            var applicationRouteId   = 1;
            var applicationReference = "ABC";
            var submittedDate        = DateTime.Today.AddDays(-32);
            var externalComments     = "external comments";
            var gatewayReviewStatus  = GatewayReviewStatus.Pass;
            var moderationStatus     = Domain.Apply.ModerationStatus.Fail;

            if (string.IsNullOrEmpty(appealStatus))
            {
                _appealsApiClient.Setup(x => x.GetAppeal(_applicationId))
                .ReturnsAsync((GetAppealResponse)null);
            }
            else
            {
                _appealsApiClient.Setup(x => x.GetAppeal(_applicationId))
                .ReturnsAsync(new GetAppealResponse {
                    Status = appealStatus, AppealSubmittedDate = DateTime.Today
                });
            }

            var application = new Apply
            {
                ApplicationId       = _applicationId,
                ExternalComments    = externalComments,
                GatewayReviewStatus = gatewayReviewStatus,
                ModerationStatus    = moderationStatus,
                ApplyData           = new ApplyData
                {
                    ApplyDetails = new ApplyDetails
                    {
                        UKPRN                  = ukprn,
                        OrganisationName       = organisationName,
                        TradingName            = tradingName,
                        ProviderRoute          = applicationRouteId,
                        ReferenceNumber        = applicationReference,
                        ApplicationSubmittedOn = submittedDate
                    }
                }
            };

            _applicationApiClient.Setup(x => x.GetApplication(_applicationId)).ReturnsAsync(application);

            var financialReviewDetails = new FinancialReviewDetails
            {
                SelectedGrade    = FinancialApplicationSelectedGrade.Outstanding,
                ExternalComments = "financial external comments",
                Status           = FinancialReviewStatus.Pass
            };

            _applicationApiClient.Setup(x => x.GetFinancialReviewDetails(_applicationId)).ReturnsAsync(financialReviewDetails);

            var expectedModel = new ApplicationSummaryViewModel
            {
                ApplicationId             = _applicationId,
                UKPRN                     = ukprn,
                OrganisationName          = organisationName,
                EmailAddress              = emailAddress,
                TradingName               = tradingName,
                ApplicationRouteId        = applicationRouteId.ToString(),
                ApplicationReference      = applicationReference,
                SubmittedDate             = submittedDate,
                GatewayExternalComments   = externalComments,
                GatewayReviewStatus       = gatewayReviewStatus,
                ModerationStatus          = moderationStatus,
                FinancialGrade            = financialReviewDetails.SelectedGrade,
                FinancialReviewStatus     = financialReviewDetails.Status,
                FinancialExternalComments = financialReviewDetails.ExternalComments,
                IsAppealSubmitted         = appealSubmitted,
                AppealStatus              = appealStatus
            };

            var returnedModel = await _service.BuildApplicationSummaryViewModel(_applicationId, emailAddress);

            expectedModel.Should().BeEquivalentTo(returnedModel);
        }
Beispiel #18
0
 public async Task ReturnFinancialReview(Guid applicationId, FinancialReviewDetails financialReviewDetails)
 {
     await Post <FinancialReviewDetails>($"/Financial/{applicationId}/Grade", financialReviewDetails);
 }
        public void When_clarification_file_is_removed_and_page_is_refreshed_with_filename_removed_from_model()
        {
            var buttonPressed = "removeClarificationFile";

            _applicationApplyApiClient.Setup(x => x.GetRoatpSequences()).ReturnsAsync(new List <RoatpSequence>());
            _qnaApiClient.Setup(x => x.GetSectionBySectionNo(_applicationId,
                                                             RoatpQnaConstants.RoatpSequences.YourOrganisation,
                                                             RoatpQnaConstants.RoatpSections.YourOrganisation.OrganisationDetails))
            .ReturnsAsync(new Section {
                ApplicationId = _applicationId, QnAData = new QnAData()
            });
            _qnaApiClient.Setup(x => x.GetSectionBySectionNo(_applicationId,
                                                             RoatpQnaConstants.RoatpSequences.YourOrganisation,
                                                             RoatpQnaConstants.RoatpSections.YourOrganisation.DescribeYourOrganisation))
            .ReturnsAsync(new Section {
                ApplicationId = _applicationId, QnAData = new QnAData()
            });
            _controller = new RoatpFinancialController(_roatpOrganisationApiClient.Object,
                                                       _applicationApplyApiClient.Object,
                                                       _qnaApiClient.Object,
                                                       MockHttpContextAccessor.Object, _clarificationValidator.Object, Mock.Of <ICsvExportService>())
            {
                ControllerContext = MockedControllerContext.Setup(buttonPressed)
            };

            _clarificationValidator.Setup(x =>
                                          x.Validate(It.IsAny <RoatpFinancialClarificationViewModel>(), It.IsAny <bool>(), It.IsAny <bool>()))
            .Returns(new ValidationResponse {
            });
            var fileToBeRemoved = "file.pdf";

            _financialReviewDetails = new FinancialReviewDetails
            {
                GradedBy                 = MockHttpContextAccessor.Name,
                GradedDateTime           = DateTime.UtcNow,
                SelectedGrade            = FinancialApplicationSelectedGrade.Good,
                FinancialDueDate         = DateTime.Today.AddDays(5),
                Comments                 = "comments",
                ClarificationResponse    = "clarification response",
                ClarificationRequestedOn = DateTime.UtcNow,
                ClarificationFiles       = new List <ClarificationFile> {
                    new ClarificationFile {
                        Filename = fileToBeRemoved
                    }, new ClarificationFile {
                        Filename = "second.pdf"
                    }
                }
            };

            _applicationApplyApiClient.Setup(x => x.GetApplication(It.IsAny <Guid>())).ReturnsAsync(
                new RoatpApply
            {
                ApplicationId = _applicationId,
                ApplyData     = new RoatpApplyData
                {
                    ApplyDetails = new RoatpApplyDetails
                    {
                        OrganisationName       = "org name",
                        UKPRN                  = "12344321",
                        ReferenceNumber        = "3443",
                        ProviderRouteName      = "main",
                        ApplicationSubmittedOn = DateTime.Today
                    },
                    Sequences = new List <RoatpApplySequence>
                    {
                        new RoatpApplySequence
                        {
                            SequenceNo  = 5,
                            NotRequired = true
                        }
                    }
                },
                FinancialGrade = _financialReviewDetails
            });

            _applicationApplyApiClient.Setup(x =>
                                             x.RemoveClarificationFile(_applicationId, It.IsAny <string>(), fileToBeRemoved))
            .ReturnsAsync(true);

            var vm = new RoatpFinancialClarificationViewModel
            {
                ApplicationId               = _applicationId,
                FinancialReviewDetails      = _financialReviewDetails,
                OutstandingFinancialDueDate = new FinancialDueDate
                {
                    Day   = "1",
                    Month = "1",
                    Year  = (DateTime.Now.Year + 1).ToString()
                },
                ClarificationResponse = "clarification response",
                ClarificationComments = "clarification comments",
                FilesToUpload         = null
            };
            var result = _controller.SubmitClarification(_applicationId, vm).Result as ViewResult;

            Assert.IsTrue(result.ViewName.Contains("Application_Clarification.cshtml"));
            var resultModel = result.Model as RoatpFinancialClarificationViewModel;

            Assert.IsTrue(resultModel.FinancialReviewDetails.ClarificationFiles.Count == 1);
            Assert.IsTrue(resultModel.FinancialReviewDetails.ClarificationFiles[0].Filename == "second.pdf");
        }