public ManageOrganisationDetailsForYearViewModel(Database.Organisation organisation, int reportingYear, DraftReturn draftReturnForYear)
 {
     this.organisation       = organisation;
     ReportingYear           = reportingYear;
     this.draftReturnForYear = draftReturnForYear;
     hasDraftReturnForYear   = draftReturnForYear != null;
 }
示例#2
0
 private void SetFiguresFromDraftReturn(ReportBonusPayViewModel viewModel, DraftReturn draftReturn)
 {
     viewModel.FemaleBonusPayPercent  = draftReturn.FemaleMedianBonusPayPercent;
     viewModel.MaleBonusPayPercent    = draftReturn.MaleMedianBonusPayPercent;
     viewModel.DiffMeanBonusPercent   = draftReturn.DiffMeanBonusPercent;
     viewModel.DiffMedianBonusPercent = draftReturn.DiffMedianBonusPercent;
 }
        public IActionResult LateSubmissionGet(string encryptedOrganisationId, int reportingYear)
        {
            ControllerHelper.Throw404IfFeatureDisabled(FeatureFlag.NewReportingJourney);

            long organisationId = ControllerHelper.DecryptOrganisationIdOrThrow404(encryptedOrganisationId);

            ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository);
            ControllerHelper.ThrowIfUserDoesNotHavePermissionsForGivenOrganisation(User, dataRepository, organisationId);
            ControllerHelper.ThrowIfReportingYearIsOutsideOfRange(reportingYear);

            if (!draftReturnService.DraftReturnExistsAndIsComplete(organisationId, reportingYear))
            {
                return(RedirectToReportOverviewPageWithNotReadyStatusMessage(encryptedOrganisationId, reportingYear));
            }

            DraftReturn draftReturn = draftReturnService.GetDraftReturn(organisationId, reportingYear);

            if (!draftReturnService.DraftReturnWouldBeNewlyLateIfSubmittedNow(draftReturn))
            {
                // If (somehow) this is not a late submission, send the user back to the Review page
                return(RedirectToAction("ReportReview", "ReportReviewAndSubmit",
                                        new { encryptedOrganisationId = encryptedOrganisationId, reportingYear = reportingYear }));
            }

            var viewModel = new ReportLateSubmissionViewModel();

            PopulateLateSubmissionViewModel(viewModel, organisationId, reportingYear);

            return(View("LateSubmission", viewModel));
        }
        public IActionResult ReportSubmitPost(string encryptedOrganisationId, int reportingYear)
        {
            ControllerHelper.Throw404IfFeatureDisabled(FeatureFlag.NewReportingJourney);

            long organisationId = ControllerHelper.DecryptOrganisationIdOrThrow404(encryptedOrganisationId);

            ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository);
            ControllerHelper.ThrowIfUserDoesNotHavePermissionsForGivenOrganisation(User, dataRepository, organisationId);
            ControllerHelper.ThrowIfReportingYearIsOutsideOfRange(reportingYear);

            if (!draftReturnService.DraftReturnExistsAndIsComplete(organisationId, reportingYear))
            {
                return(RedirectToReportOverviewPageWithNotReadyStatusMessage(encryptedOrganisationId, reportingYear));
            }

            DraftReturn draftReturn = draftReturnService.GetDraftReturn(organisationId, reportingYear);

            if (draftReturnService.DraftReturnWouldBeNewlyLateIfSubmittedNow(draftReturn))
            {
                return(RedirectToAction("LateSubmissionGet", "ReportReviewAndSubmit",
                                        new { encryptedOrganisationId = encryptedOrganisationId, reportingYear = reportingYear }));
            }

            User   user      = ControllerHelper.GetGpgUserFromAspNetUser(User, dataRepository);
            Return newReturn = returnService.CreateAndSaveReturnFromDraftReturn(draftReturn, user, Url);

            return(RedirectToAction("ReportConfirmation", "ReportConfirmation",
                                    new
            {
                encryptedOrganisationId = encryptedOrganisationId,
                reportingYear = reportingYear,
                confirmationId = Encryption.EncryptQuerystring(newReturn.ReturnId.ToString())
            }));
        }
        private ReturnViewModel LoadDraftReturnAsReturnViewModel(Draft resultingDraft)
        {
            DraftReturn     draftReturnFromDatabase = GetDraftReturnFromDatabase(resultingDraft.OrganisationId, resultingDraft.SnapshotYear);
            ReturnViewModel returnViewModel         = CastDatabaseDraftReturnToReturnViewModel(draftReturnFromDatabase);

            return(returnViewModel);
        }
示例#6
0
        private bool IsDraftReturnAMaterialChange(DraftReturn draftReturn, Organisation organisation)
        {
            Return submittedReturn = organisation.GetReturn(draftReturn.SnapshotYear);

            if (submittedReturn == null)
            {
                // If this is the first Return of the year, then it must include a material change (figures)
                return(true);
            }

            bool isMaterialChange =
                draftReturn.DiffMeanHourlyPayPercent != submittedReturn.DiffMeanHourlyPayPercent ||
                draftReturn.DiffMedianHourlyPercent != submittedReturn.DiffMedianHourlyPercent

                || draftReturn.DiffMeanBonusPercent != submittedReturn.DiffMeanBonusPercent ||
                draftReturn.DiffMedianBonusPercent != submittedReturn.DiffMedianBonusPercent ||
                draftReturn.MaleMedianBonusPayPercent != submittedReturn.MaleMedianBonusPayPercent ||
                draftReturn.FemaleMedianBonusPayPercent != submittedReturn.FemaleMedianBonusPayPercent

                || draftReturn.MaleLowerPayBand != submittedReturn.MaleLowerPayBand ||
                draftReturn.FemaleLowerPayBand != submittedReturn.FemaleLowerPayBand ||
                draftReturn.MaleMiddlePayBand != submittedReturn.MaleMiddlePayBand ||
                draftReturn.FemaleMiddlePayBand != submittedReturn.FemaleMiddlePayBand ||
                draftReturn.MaleUpperPayBand != submittedReturn.MaleUpperPayBand ||
                draftReturn.FemaleUpperPayBand != submittedReturn.FemaleUpperPayBand ||
                draftReturn.MaleUpperQuartilePayBand != submittedReturn.MaleUpperQuartilePayBand ||
                draftReturn.FemaleUpperQuartilePayBand != submittedReturn.FemaleUpperQuartilePayBand;

            return(isMaterialChange);
        }
示例#7
0
 private bool ResponsiblePersonSectionIsComplete(DraftReturn draftReturn, Organisation organisation)
 {
     return(organisation.SectorType == SectorTypes.Public || // Public sector organisations don't have to provide a responsible person
            (!string.IsNullOrWhiteSpace(draftReturn.FirstName) &&
             !string.IsNullOrWhiteSpace(draftReturn.LastName) &&
             !string.IsNullOrWhiteSpace(draftReturn.JobTitle)));
 }
示例#8
0
        public IActionResult ReportOverview(string encryptedOrganisationId, int reportingYear, bool canTriggerLateSubmissionWarning = false)
        {
            long organisationId = ControllerHelper.DecryptOrganisationIdOrThrow404(encryptedOrganisationId);

            ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository);
            ControllerHelper.ThrowIfUserDoesNotHavePermissionsForGivenOrganisation(User, dataRepository, organisationId);
            ControllerHelper.ThrowIfReportingYearIsOutsideOfRange(reportingYear);

            if (draftReturnService.ShouldShowLateWarning(organisationId, reportingYear) && canTriggerLateSubmissionWarning)
            {
                return(RedirectToAction("LateSubmissionWarningGet", "LateSubmission", new { encryptedOrganisationId, reportingYear }));
            }

            Organisation organisation    = dataRepository.Get <Organisation>(organisationId);
            DraftReturn  draftReturn     = draftReturnService.GetDraftReturn(organisationId, reportingYear);
            Return       submittedReturn = organisation.GetReturn(reportingYear);

            if (draftReturn == null && submittedReturn == null)
            {
                return(RedirectToAction("ReportFiguresGet", "ReportFigures", new { encryptedOrganisationId, reportingYear }));
            }


            var viewModel = new ReportOverviewViewModel();

            PopulateViewModel(viewModel, organisation, draftReturn, submittedReturn, reportingYear);

            return(View("ReportOverview", viewModel));
        }
        private Return CreateAndSaveReturnFromDraftReturn(
            DraftReturn draftReturn,
            User user,
            IUrlHelper urlHelper,
            bool isLateSubmission,
            string lateReason,
            bool receivedLetterFromEhrc)
        {
            // Don't save if no changes (to do later - when we get to editing returns)
            // Construct "Modifications" field (to do later - when we get to editing returns)

            // Create the Return
            Return newReturn = CreateReturnFromDraftReturn(draftReturn, isLateSubmission, lateReason, receivedLetterFromEhrc);

            dataRepository.Insert(newReturn);
            dataRepository.SaveChanges();

            // Set the Return Status using SetStatus (creates a ReturnStatus object) (might need to do this after initial save?)
            newReturn.SetStatus(ReturnStatuses.Submitted, user.UserId);

            // Retire the old Returns
            RetireOldReturnsForSameYear(newReturn, user);
            // Discard draft return
            dataRepository.Delete(draftReturn);
            dataRepository.SaveChanges();

            // Send emails
            SendGeoFirstTimeSubmissionEmail(newReturn, urlHelper);
            SendSuccessfulSubmissionEmailToRegisteredUsers(newReturn, urlHelper);

            return(newReturn);
        }
示例#10
0
        public IActionResult SubmitReturnPost(string encryptedOrganisationId, int reportingYear)
        {
            long organisationId = ControllerHelper.DecryptOrganisationIdOrThrow404(encryptedOrganisationId);

            ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository);
            ControllerHelper.ThrowIfUserDoesNotHavePermissionsForGivenOrganisation(User, dataRepository, organisationId);
            ControllerHelper.ThrowIfReportingYearIsOutsideOfRange(reportingYear);

            DraftReturn draftReturn = draftReturnService.GetDraftReturn(organisationId, reportingYear);

            if (!draftReturnService.DraftReturnExistsAndRequiredFieldsAreComplete(organisationId, reportingYear))
            {
                return(RedirectToReportOverviewPage(encryptedOrganisationId, reportingYear, "This report is not ready to submit. Complete the remaining sections"));
            }

            if (draftReturnService.DraftReturnWouldBeNewlyLateIfSubmittedNow(draftReturn))
            {
                // Late submission Reason
                return(RedirectToAction("LateSubmissionReasonGet", "LateSubmission", new { encryptedOrganisationId, reportingYear }));
            }

            User   user      = ControllerHelper.GetGpgUserFromAspNetUser(User, dataRepository);
            Return newReturn = returnService.CreateAndSaveReturnFromDraftReturn(draftReturn, user, Url);

            // Confirmation
            return(RedirectToAction("ReportConfirmation", "ReportConfirmation",
                                    new
            {
                encryptedOrganisationId,
                reportingYear,
                confirmationId = Encryption.EncryptQuerystring(newReturn.ReturnId.ToString())
            }));
        }
示例#11
0
        public IActionResult ReportDiscardDraftGet(string encryptedOrganisationId, int reportingYear)
        {
            ControllerHelper.Throw404IfFeatureDisabled(FeatureFlag.NewReportingJourney);

            long organisationId = ControllerHelper.DecryptOrganisationIdOrThrow404(encryptedOrganisationId);

            ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository);
            ControllerHelper.ThrowIfUserDoesNotHavePermissionsForGivenOrganisation(User, dataRepository, organisationId);
            ControllerHelper.ThrowIfReportingYearIsOutsideOfRange(reportingYear);

            DraftReturn draftReturn       = draftReturnService.GetDraftReturn(organisationId, reportingYear);
            bool        draftReturnExists = draftReturn != null;

            if (!draftReturnExists)
            {
                string nextPageUrl = Url.Action("ReportOverview", "ReportOverview", new { encryptedOrganisationId = encryptedOrganisationId, reportingYear = reportingYear });
                StatusMessageHelper.SetStatusMessage(Response, "No draft to discard", nextPageUrl);
                return(LocalRedirect(nextPageUrl));
            }

            var viewModel = new ReportDiscardDraftViewModel();

            PopulateViewModel(viewModel, organisationId, reportingYear);

            return(View("ReportDiscardDraft", viewModel));
        }
示例#12
0
        public IActionResult ReportDiscardDraftPost(string encryptedOrganisationId, int reportingYear)
        {
            ControllerHelper.Throw404IfFeatureDisabled(FeatureFlag.NewReportingJourney);

            long organisationId = ControllerHelper.DecryptOrganisationIdOrThrow404(encryptedOrganisationId);

            ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository);
            ControllerHelper.ThrowIfUserDoesNotHavePermissionsForGivenOrganisation(User, dataRepository, organisationId);
            ControllerHelper.ThrowIfReportingYearIsOutsideOfRange(reportingYear);

            DraftReturn draftReturn       = draftReturnService.GetDraftReturn(organisationId, reportingYear);
            bool        draftReturnExists = draftReturn != null;

            if (!draftReturnExists)
            {
                string nextPageNoDraftUrl = Url.Action("ReportOverview", "ReportOverview", new { encryptedOrganisationId = encryptedOrganisationId, reportingYear = reportingYear });
                StatusMessageHelper.SetStatusMessage(Response, "No draft to discard", nextPageNoDraftUrl);
                return(LocalRedirect(nextPageNoDraftUrl));
            }

            dataRepository.Delete(draftReturn);
            dataRepository.SaveChanges();

            Organisation organisation             = dataRepository.Get <Organisation>(organisationId);
            Return       submittedReturn          = organisation.GetReturn(reportingYear);
            bool         isEditingSubmittedReturn = submittedReturn != null;

            string yourChangesOrYourDraftReport = isEditingSubmittedReturn ? "your changes" : "your draft report";

            string nextPageUrl = Url.Action("ReportOverview", "ReportOverview", new { encryptedOrganisationId = encryptedOrganisationId, reportingYear = reportingYear });

            StatusMessageHelper.SetStatusMessage(Response, $"Discarded {yourChangesOrYourDraftReport}", nextPageUrl);
            return(LocalRedirect(nextPageUrl));
        }
        public IActionResult LateSubmissionReasonGet(string encryptedOrganisationId, int reportingYear)
        {
            long organisationId = ControllerHelper.DecryptOrganisationIdOrThrow404(encryptedOrganisationId);

            ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository);
            ControllerHelper.ThrowIfUserDoesNotHavePermissionsForGivenOrganisation(User, dataRepository, organisationId);
            ControllerHelper.ThrowIfReportingYearIsOutsideOfRange(reportingYear);

            if (!draftReturnService.DraftReturnExistsAndRequiredFieldsAreComplete(organisationId, reportingYear))
            {
                return(RedirectToReportOverviewPage(encryptedOrganisationId, reportingYear, "This report is not ready to submit. Complete the remaining sections"));
            }

            DraftReturn draftReturn = draftReturnService.GetDraftReturn(organisationId, reportingYear);

            if (!draftReturnService.DraftReturnWouldBeNewlyLateIfSubmittedNow(draftReturn))
            {
                // If this is not a late submission, send the user back to the Overview page
                return(RedirectToAction("ReportOverview", "ReportOverview",
                                        new { encryptedOrganisationId, reportingYear }));
            }

            var viewModel = new LateSubmissionReasonViewModel();

            PopulateLateSubmissionViewModel(viewModel, organisationId, reportingYear);

            return(View("LateSubmissionReason", viewModel));
        }
示例#14
0
        private bool WebsiteLinkSectionIsComplete(DraftReturn draftReturn)
        {
            // The website link is optional, so we should allow it to be missing
            bool linkIsMissing = string.IsNullOrEmpty(draftReturn.CompanyLinkToGPGInfo);
            bool linkIsValid   = UriSanitiser.IsValidHttpOrHttpsLink(draftReturn.CompanyLinkToGPGInfo);

            return(linkIsMissing || linkIsValid);
        }
        private void SaveChangesToDraftReturn(ReportLinkToWebsiteViewModel viewModel, long organisationId, int reportingYear)
        {
            DraftReturn draftReturn = draftReturnService.GetOrCreateDraftReturn(organisationId, reportingYear);

            draftReturn.CompanyLinkToGPGInfo = viewModel.LinkToOrganisationWebsite;

            draftReturnService.SaveDraftReturnOrDeleteIfNotRelevant(draftReturn);
        }
示例#16
0
        private void SaveChangesToDraftReturn(ReportFiguresViewModel viewModel, long organisationId, int reportingYear)
        {
            DraftReturn draftReturn = draftReturnService.GetOrCreateDraftReturn(organisationId, reportingYear);

            ReportFiguresHelper.SaveFiguresToDraftReturn(viewModel, draftReturn);

            draftReturnService.SaveDraftReturnOrDeleteIfNotRelevant(draftReturn);
        }
示例#17
0
        private void SaveChangesToDraftReturn(ReportSizeOfOrganisationViewModel viewModel, long organisationId, int reportingYear)
        {
            DraftReturn draftReturn = draftReturnService.GetOrCreateDraftReturn(organisationId, reportingYear);

            draftReturn.OrganisationSize = viewModel.GetSizeOfOrganisation();

            draftReturnService.SaveDraftReturnOrDeleteIfNotRelevent(draftReturn);
        }
        private Return CreateReturnFromDraftReturn(
            DraftReturn draftReturn,
            bool isLateSubmission,
            string lateReason,
            bool receivedLetterFromEhrc)
        {
            Organisation organisation          = dataRepository.Get <Organisation>(draftReturn.OrganisationId);
            Return       existingReturn        = organisation.GetReturn(draftReturn.SnapshotYear);
            var          organisationSizeRange = draftReturn.OrganisationSize?.GetAttribute <RangeAttribute>();

            var newReturn = new Return
            {
                OrganisationId = draftReturn.OrganisationId,
                Organisation   = organisation,

                AccountingDate = organisation.SectorType.GetAccountingStartDate(draftReturn.SnapshotYear),

                DiffMeanHourlyPayPercent = draftReturn.DiffMeanHourlyPayPercent.Value,
                DiffMedianHourlyPercent  = draftReturn.DiffMedianHourlyPercent.Value,

                MaleMedianBonusPayPercent   = draftReturn.MaleMedianBonusPayPercent.Value,
                FemaleMedianBonusPayPercent = draftReturn.FemaleMedianBonusPayPercent.Value,
                DiffMeanBonusPercent        = draftReturn.DiffMeanBonusPercent,
                DiffMedianBonusPercent      = draftReturn.DiffMedianBonusPercent,

                MaleUpperQuartilePayBand   = draftReturn.MaleUpperQuartilePayBand.Value,
                FemaleUpperQuartilePayBand = draftReturn.FemaleUpperQuartilePayBand.Value,
                MaleUpperPayBand           = draftReturn.MaleUpperPayBand.Value,
                FemaleUpperPayBand         = draftReturn.FemaleUpperPayBand.Value,
                MaleMiddlePayBand          = draftReturn.MaleMiddlePayBand.Value,
                FemaleMiddlePayBand        = draftReturn.FemaleMiddlePayBand.Value,
                MaleLowerPayBand           = draftReturn.MaleLowerPayBand.Value,
                FemaleLowerPayBand         = draftReturn.FemaleLowerPayBand.Value,

                FirstName = draftReturn.FirstName,
                LastName  = draftReturn.LastName,
                JobTitle  = draftReturn.JobTitle,

                MinEmployees = (int)organisationSizeRange.Minimum,
                MaxEmployees = (int)organisationSizeRange.Maximum,

                CompanyLinkToGPGInfo = draftReturn.CompanyLinkToGPGInfo,

                IsLateSubmission = isLateSubmission,
                LateReason       = lateReason,
                EHRCResponse     = receivedLetterFromEhrc,

                // We will set the status to Submitted soon
                // But, we want to use the Return.SetStatus method (which required the Return to already be saved
                // But, to save the Return, we need an initial status
                // Maybe we should see if we can reduce this complexity!
                Status = ReturnStatuses.Draft
            };

            newReturn.Modifications = CalculateModifications(newReturn, existingReturn);

            return(newReturn);
        }
        private void SaveChangesToDraftReturn(ReportHourlyPayViewModel viewModel, long organisationId, int reportingYear)
        {
            DraftReturn draftReturn = draftReturnService.GetOrCreateDraftReturn(organisationId, reportingYear);

            draftReturn.DiffMeanHourlyPayPercent = viewModel.DiffMeanHourlyPayPercent;
            draftReturn.DiffMedianHourlyPercent  = viewModel.DiffMedianHourlyPercent;

            draftReturnService.SaveDraftReturnOrDeleteIfNotRelevent(draftReturn);
        }
 public Return CreateAndSaveLateReturnFromDraftReturn(
     DraftReturn draftReturn,
     User user,
     IUrlHelper urlHelper,
     string lateReason,
     bool receivedLetterFromEhrc)
 {
     return(CreateAndSaveReturnFromDraftReturn(draftReturn, user, urlHelper, true, lateReason, receivedLetterFromEhrc));
 }
 private static ReturnViewModel CastDatabaseDraftReturnToReturnViewModel(DraftReturn draftReturn)
 {
     if (draftReturn == null)
     {
         return(null);
     }
     return(new ReturnViewModel
     {
         AccountingDate = draftReturn.AccountingDate ?? VirtualDateTime.Now,
         Address = draftReturn.Address,
         CompanyLinkToGPGInfo = draftReturn.CompanyLinkToGPGInfo,
         DiffMeanBonusPercent = NormaliseDecimal(draftReturn.DiffMeanBonusPercent),
         DiffMeanHourlyPayPercent = NormaliseDecimal(draftReturn.DiffMeanHourlyPayPercent),
         DiffMedianBonusPercent = NormaliseDecimal(draftReturn.DiffMedianBonusPercent),
         DiffMedianHourlyPercent = NormaliseDecimal(draftReturn.DiffMedianHourlyPercent),
         EHRCResponse = draftReturn.EHRCResponse,
         EncryptedOrganisationId = draftReturn.EncryptedOrganisationId,
         FemaleLowerPayBand = NormaliseDecimal(draftReturn.FemaleLowerPayBand),
         FemaleMedianBonusPayPercent = NormaliseDecimal(draftReturn.FemaleMedianBonusPayPercent),
         FemaleMiddlePayBand = NormaliseDecimal(draftReturn.FemaleMiddlePayBand),
         FemaleUpperPayBand = NormaliseDecimal(draftReturn.FemaleUpperPayBand),
         FemaleUpperQuartilePayBand = NormaliseDecimal(draftReturn.FemaleUpperQuartilePayBand),
         FirstName = draftReturn.FirstName,
         IsDifferentFromDatabase = draftReturn.IsDifferentFromDatabase ?? false,
         IsInScopeForThisReportYear = draftReturn.IsInScopeForThisReportYear ?? false,
         IsLateSubmission = draftReturn.IsLateSubmission ?? false,
         IsVoluntarySubmission = draftReturn.IsVoluntarySubmission ?? false,
         JobTitle = draftReturn.JobTitle,
         LastName = draftReturn.LastName,
         LateReason = draftReturn.LateReason,
         LatestAddress = draftReturn.LatestAddress,
         LatestOrganisationName = draftReturn.LatestOrganisationName,
         LatestSector = draftReturn.LatestSector,
         MaleMedianBonusPayPercent = NormaliseDecimal(draftReturn.MaleMedianBonusPayPercent),
         MaleMiddlePayBand = NormaliseDecimal(draftReturn.MaleMiddlePayBand),
         MaleUpperQuartilePayBand = NormaliseDecimal(draftReturn.MaleUpperQuartilePayBand),
         MaleUpperPayBand = NormaliseDecimal(draftReturn.MaleUpperPayBand),
         MaleLowerPayBand = NormaliseDecimal(draftReturn.MaleLowerPayBand),
         Modified = draftReturn.Modified,
         OptedOutOfReportingPayQuarters = draftReturn.OptedOutOfReportingPayQuarters,
         OrganisationId = draftReturn.OrganisationId,
         OrganisationName = draftReturn.OrganisationName,
         OrganisationSize = draftReturn.OrganisationSize ?? OrganisationSizes.NotProvided,
         OriginatingAction = draftReturn.OriginatingAction,
         ReportInfo = new ReportInfoModel
         {
             ReportingRequirement = draftReturn.ReportingRequirement ?? ScopeStatuses.Unknown,
             ReportingStartDate = draftReturn.ReportingStartDate ?? VirtualDateTime.Now,
             ReportModifiedDate = draftReturn.ReportModifiedDate ?? VirtualDateTime.Now,
         },
         ReturnId = draftReturn.ReturnId ?? 0,
         ReturnUrl = draftReturn.ReturnUrl,
         Sector = draftReturn.Sector,
         SectorType = draftReturn.SectorType ?? SectorTypes.Unknown,
         ShouldProvideLateReason = draftReturn.ShouldProvideLateReason ?? false
     });
 }
        private DraftReturn SerialiseDraftAsDraftReturn(Draft draft)
        {
            var draftReturn = new DraftReturn
            {
                OrganisationId = draft.OrganisationId,
                SnapshotYear   = draft.SnapshotYear,

                AccountingDate                        = draft.ReturnViewModelContent?.AccountingDate,
                Address                               = draft.ReturnViewModelContent?.Address,
                CompanyLinkToGPGInfo                  = draft.ReturnViewModelContent?.CompanyLinkToGPGInfo,
                DiffMeanBonusPercent                  = draft.ReturnViewModelContent?.DiffMeanBonusPercent,
                DiffMeanHourlyPayPercent              = draft.ReturnViewModelContent?.DiffMeanHourlyPayPercent,
                DiffMedianBonusPercent                = draft.ReturnViewModelContent?.DiffMedianBonusPercent,
                DiffMedianHourlyPercent               = draft.ReturnViewModelContent?.DiffMedianHourlyPercent,
                EHRCResponse                          = draft.ReturnViewModelContent?.EHRCResponse,
                EncryptedOrganisationId               = draft.ReturnViewModelContent?.EncryptedOrganisationId,
                FemaleLowerPayBand                    = draft.ReturnViewModelContent?.FemaleLowerPayBand,
                FemaleMedianBonusPayPercent           = draft.ReturnViewModelContent?.FemaleMedianBonusPayPercent,
                FemaleMiddlePayBand                   = draft.ReturnViewModelContent?.FemaleMiddlePayBand,
                FemaleUpperPayBand                    = draft.ReturnViewModelContent?.FemaleUpperPayBand,
                FemaleUpperQuartilePayBand            = draft.ReturnViewModelContent?.FemaleUpperQuartilePayBand,
                FirstName                             = draft.ReturnViewModelContent?.FirstName,
                HasDraftBeenModifiedDuringThisSession = draft.HasDraftBeenModifiedDuringThisSession,
                IsDifferentFromDatabase               = draft.ReturnViewModelContent?.IsDifferentFromDatabase,
                IsInScopeForThisReportYear            = draft.ReturnViewModelContent?.IsInScopeForThisReportYear,
                IsLateSubmission                      = draft.ReturnViewModelContent?.IsLateSubmission,
                IsVoluntarySubmission                 = draft.ReturnViewModelContent?.IsVoluntarySubmission,
                JobTitle                              = draft.ReturnViewModelContent?.JobTitle,
                LastName                              = draft.ReturnViewModelContent?.LastName,
                LastWrittenByUserId                   = draft.LastWrittenByUserId,
                LastWrittenDateTime                   = draft.LastWrittenDateTime,
                LateReason                            = draft.ReturnViewModelContent?.LateReason,
                LatestAddress                         = draft.ReturnViewModelContent?.LatestAddress,
                LatestOrganisationName                = draft.ReturnViewModelContent?.LatestOrganisationName,
                LatestSector                          = draft.ReturnViewModelContent?.LatestSector,
                MaleLowerPayBand                      = draft.ReturnViewModelContent?.MaleLowerPayBand,
                MaleMedianBonusPayPercent             = draft.ReturnViewModelContent?.MaleMedianBonusPayPercent,
                MaleMiddlePayBand                     = draft.ReturnViewModelContent?.MaleMiddlePayBand,
                MaleUpperPayBand                      = draft.ReturnViewModelContent?.MaleUpperPayBand,
                MaleUpperQuartilePayBand              = draft.ReturnViewModelContent?.MaleUpperQuartilePayBand,
                Modified                              = draft.ReturnViewModelContent?.Modified ?? VirtualDateTime.Now,
                OptedOutOfReportingPayQuarters        = draft.ReturnViewModelContent?.OptedOutOfReportingPayQuarters ?? false,
                OrganisationName                      = draft.ReturnViewModelContent?.OrganisationName,
                OrganisationSize                      = draft.ReturnViewModelContent?.OrganisationSize,
                OriginatingAction                     = draft.ReturnViewModelContent?.OriginatingAction,
                ReportingRequirement                  = draft.ReturnViewModelContent?.ReportInfo.ReportingRequirement,
                ReportingStartDate                    = draft.ReturnViewModelContent?.ReportInfo.ReportingStartDate,
                ReportModifiedDate                    = draft.ReturnViewModelContent?.ReportInfo.ReportModifiedDate,
                ReturnId                              = draft.ReturnViewModelContent?.ReturnId,
                ReturnUrl                             = draft.ReturnViewModelContent?.ReturnUrl,
                Sector     = draft.ReturnViewModelContent?.Sector,
                SectorType = draft.ReturnViewModelContent?.SectorType,
                ShouldProvideLateReason = draft.ReturnViewModelContent?.ShouldProvideLateReason
            };

            return(draftReturn);
        }
示例#23
0
        private void SaveChangesToDraftReturn(ReportResponsiblePersonViewModel viewModel, long organisationId, int reportingYear)
        {
            DraftReturn draftReturn = draftReturnService.GetOrCreateDraftReturn(organisationId, reportingYear);

            draftReturn.FirstName = viewModel.ResponsiblePersonFirstName;
            draftReturn.LastName  = viewModel.ResponsiblePersonLastName;
            draftReturn.JobTitle  = viewModel.ResponsiblePersonJobTitle;

            draftReturnService.SaveDraftReturnOrDeleteIfNotRelevent(draftReturn);
        }
        private (bool IsAllowedAccess, long UserId) GetIsUserTheLastPersonThatWroteOnTheFile(long organisationId,
                                                                                             int snapshotYear,
                                                                                             long userId)
        {
            DraftReturn draftReturn = GetDraftReturnFromDatabase(organisationId, snapshotYear);

            long lastAccessedByUserId = draftReturn.LastWrittenByUserId ?? 0;

            return(lastAccessedByUserId == 0 || lastAccessedByUserId == userId, lastAccessedByUserId);
        }
        private DateTime?GetLastWriteTime(Draft draft)
        {
            if (DraftExists(draft))
            {
                DraftReturn originalDraftReturn = GetDraftReturnFromDatabase(draft.OrganisationId, draft.SnapshotYear);
                return(originalDraftReturn.LastWrittenDateTime);
            }

            return(null);
        }
示例#26
0
 private bool EmployeesByPayQuartileSectionIsFilledIn(DraftReturn draftReturn)
 {
     return(draftReturn.MaleLowerPayBand != null &&
            draftReturn.FemaleLowerPayBand != null &&
            draftReturn.MaleMiddlePayBand != null &&
            draftReturn.FemaleMiddlePayBand != null &&
            draftReturn.MaleUpperPayBand != null &&
            draftReturn.FemaleUpperPayBand != null &&
            draftReturn.MaleUpperQuartilePayBand != null &&
            draftReturn.FemaleUpperQuartilePayBand != null);
 }
示例#27
0
        public bool DraftReturnWouldBeNewlyLateIfSubmittedNow(DraftReturn draftReturn)
        {
            Organisation organisation  = dataRepository.Get <Organisation>(draftReturn.OrganisationId);
            int          reportingYear = draftReturn.SnapshotYear;

            return(ReportIsLate(organisation, reportingYear) &&
                   OrganisationSizeMakesReportMandatory(draftReturn) &&
                   OrganisationIsInScope(organisation, reportingYear) &&
                   ReportingYearIsNotExcludedFromLateEnforcement(reportingYear) &&
                   IsDraftReturnAMaterialChange(draftReturn, organisation));
        }
 public static void SetFigures(ReportFiguresViewModel viewModel, DraftReturn draftReturn, Return submittedReturn)
 {
     if (draftReturn != null)
     {
         SetFiguresFromDraftReturn(viewModel, draftReturn);
     }
     else if (submittedReturn != null)
     {
         SetFiguresFromSubmittedReturn(viewModel, submittedReturn);
     }
 }
示例#29
0
        private void SetValuesFromDraftReturn(ReportOverviewViewModel viewModel, DraftReturn draftReturn)
        {
            SetHourlyPayQuarterFiguresFromDraftReturn(viewModel, draftReturn);
            SetMeanAndMedianGenderPayGapUsingHourlyPayFiguresFromDraftReturn(viewModel, draftReturn);
            SetBonusPayFiguresFromDraftReturn(viewModel, draftReturn);
            SetPersonResponsibleFromDraftReturn(viewModel, draftReturn);

            SetOrganisationSizeFromDraftReturn(viewModel, draftReturn);
            SetLinkToGenderPayGapInformationFromDraftReturn(viewModel, draftReturn);

            SetOptedOutOfReportingPayQuarterFromDraftReturn(viewModel, draftReturn);
        }
        private void SaveNewEmptyDraftReturn(Draft resultingDraft, long userIdRequestingAccess)
        {
            var newEmptyDraftReturn = new DraftReturn
            {
                OrganisationId      = resultingDraft.OrganisationId,
                SnapshotYear        = resultingDraft.SnapshotYear,
                LastWrittenByUserId = userIdRequestingAccess
            };

            InsertOrUpdate(newEmptyDraftReturn);
            dataRepository.SaveChanges();
        }