public bool IsValidReturn()
        {
            bool optOutOfReporting =
                ReportingYearsHelper.IsReportingYearWithFurloughScheme(AccountingDate) && OptedOutOfReportingPayQuarters;

            bool hasPayQuartersData = MaleLowerPayBand.HasValue &&
                                      FemaleLowerPayBand.HasValue &&
                                      MaleMiddlePayBand.HasValue &&
                                      FemaleMiddlePayBand.HasValue &&
                                      MaleUpperPayBand.HasValue &&
                                      FemaleUpperPayBand.HasValue &&
                                      MaleUpperQuartilePayBand.HasValue &&
                                      FemaleUpperQuartilePayBand.HasValue;
            bool hasEnterCalculationsData = DiffMeanHourlyPayPercent.HasValue &&
                                            DiffMedianHourlyPercent.HasValue &&
                                            MaleMedianBonusPayPercent.HasValue &&
                                            FemaleMedianBonusPayPercent.HasValue &&
                                            FemaleMoneyFromMeanHourlyRate >= 0 &&
                                            FemaleMoneyFromMedianHourlyRate >= 0;
            bool hasValidBonusFigures = MaleMedianBonusPayPercent == 0 || DiffMeanBonusPercent.HasValue && DiffMedianBonusPercent.HasValue;
            bool hasValidGpgFigures   = (optOutOfReporting || hasPayQuartersData) && hasEnterCalculationsData && hasValidBonusFigures;

            if (SectorType == SectorTypes.Public)
            {
                return(hasValidGpgFigures);
            }

            bool hasPersonResponsibleData = !string.IsNullOrWhiteSpace(JobTitle) &&
                                            !string.IsNullOrWhiteSpace(FirstName) &&
                                            !string.IsNullOrWhiteSpace(LastName);

            return(hasValidGpgFigures && hasPersonResponsibleData);
        }
        public void IsReportingYearWithFurloughScheme_Returns_False_Given_A_Year_Without_Furlough_Scheme(int year)
        {
            // Arrange
            var accountingDate = SectorTypes.Private.GetAccountingStartDate(year);

            // Act
            var actualResult = ReportingYearsHelper.IsReportingYearWithFurloughScheme(accountingDate);

            // Assert
            Assert.AreEqual(false, actualResult);
        }
Beispiel #3
0
        public bool DraftReturnExistsAndRequiredFieldsAreComplete(long organisationId, int reportingYear)
        {
            DraftReturn draftReturn = GetDraftReturn(organisationId, reportingYear);

            if (draftReturn == null)
            {
                return(false);
            }

            var organisation = dataRepository.Get <Organisation>(organisationId);

            bool employeesByPayQuartileSectionIsComplete =
                (ReportingYearsHelper.IsReportingYearWithFurloughScheme(reportingYear) && draftReturn.OptedOutOfReportingPayQuarters) ||
                EmployeesByPayQuartileSectionIsFilledIn(draftReturn);

            return(HourlyPaySectionIsComplete(draftReturn) &&
                   BonusPaySectionIsComplete(draftReturn) &&
                   employeesByPayQuartileSectionIsComplete &&
                   ResponsiblePersonSectionIsComplete(draftReturn, organisation) &&
                   WebsiteLinkSectionIsComplete(draftReturn));
        }
        public static void ValidateUserInput(ReportFiguresViewModel viewModel, HttpRequest request, int reportingYear)
        {
            ValidateBonusPayFigures(viewModel, request);
            ValidateHourlyPayFigures(viewModel, request);
            ValidatePayQuartileFigures(viewModel, request);

            if (viewModel.OptedOutOfReportingPayQuarters)
            {
                if (!ReportingYearsHelper.IsReportingYearWithFurloughScheme(reportingYear))
                {
                    const string errorMessage = "You cannot opt out of reporting your pay quarter figures for this reporting year";
                    viewModel.AddErrorFor(m => m.OptedOutOfReportingPayQuarters, errorMessage);
                }

                if (HasPayQuarterFigures(viewModel))
                {
                    const string errorMessage = "Do not enter the data for the percentage of men and women in each hourly pay quarter "
                                                + "if you have opted out of reporting your pay quarter figures";
                    viewModel.AddErrorFor(m => m.OptedOutOfReportingPayQuarters, errorMessage);
                }
            }
        }
        public bool AllRequiredFieldsAreFilled()
        {
            bool optOutOfReporting = ReportingYearsHelper.IsReportingYearWithFurloughScheme(SnapshotDate) && OptedOutOfReportingPayQuarters;

            bool hasPayQuartersData = MaleLowerPayBand.HasValue &&
                                      FemaleLowerPayBand.HasValue &&
                                      MaleLowerMiddlePayBand.HasValue &&
                                      FemaleLowerMiddlePayBand.HasValue &&
                                      MaleUpperPayBand.HasValue &&
                                      FemaleUpperPayBand.HasValue &&
                                      MaleUpperMiddlePayBand.HasValue &&
                                      FemaleUpperMiddlePayBand.HasValue;

            bool hasHourlyData = DiffMeanHourlyPayPercent.HasValue &&
                                 DiffMedianHourlyPercent.HasValue;

            bool hasBonusData = MaleBonusPayPercent.HasValue &&
                                FemaleBonusPayPercent.HasValue &&
                                DiffMeanBonusPercent.HasValue &&
                                DiffMedianBonusPercent.HasValue;


            bool hasEnterCalculationsData = hasHourlyData && hasBonusData;

            bool hasValidBonusFigures = MaleBonusPayPercent == 0 || DiffMeanBonusPercent.HasValue && DiffMedianBonusPercent.HasValue;

            bool hasValidGpgFigures = (optOutOfReporting || hasPayQuartersData) && hasEnterCalculationsData && hasValidBonusFigures;

            if (Organisation.SectorType == SectorTypes.Public)
            {
                return(hasValidGpgFigures);
            }

            bool hasPersonResponsibleData = !string.IsNullOrWhiteSpace(ResponsiblePersonJobTitle) &&
                                            !string.IsNullOrWhiteSpace(ResponsiblePersonFirstName) &&
                                            !string.IsNullOrWhiteSpace(ResponsiblePersonLastName);

            return(hasValidGpgFigures && hasPersonResponsibleData);
        }