public IEnumerable <Return> GetOrganisationRecentReports(Organisation organisation, int recentCount)
        {
            foreach (var year in GetOrganisationRecentReportingYears(organisation, recentCount))
            {
                var defaultReturn = new Return
                {
                    Organisation   = organisation,
                    AccountingDate = _sharedBusinessLogic.GetAccountingStartDate(organisation.SectorType, year),
                    Modified       = VirtualDateTime.Now
                };
                defaultReturn.IsLateSubmission = defaultReturn.CalculateIsLateSubmission();

                yield return(organisation.GetReturn(year) ?? defaultReturn);
            }
        }
예제 #2
0
        public Return CreateDraftSubmissionFromViewModel(ReturnViewModel stashedReturnViewModel)
        {
            var orgSizeRange = stashedReturnViewModel.OrganisationSize.GetAttribute <RangeAttribute>();

            var result = new Return();

            result.AccountingDate = stashedReturnViewModel.AccountingDate;
            result.Status         = ReturnStatuses.Draft;
            result.OrganisationId = stashedReturnViewModel.OrganisationId;
            result.Organisation   = DataRepository.Get <Organisation>(result.OrganisationId);

            if (stashedReturnViewModel.DiffMeanBonusPercent != null)
            {
                result.DiffMeanBonusPercent = stashedReturnViewModel.DiffMeanBonusPercent.Value;
            }

            if (stashedReturnViewModel.DiffMeanHourlyPayPercent != null)
            {
                result.DiffMeanHourlyPayPercent = stashedReturnViewModel.DiffMeanHourlyPayPercent.Value;
            }

            if (stashedReturnViewModel.DiffMedianBonusPercent != null)
            {
                result.DiffMedianBonusPercent = stashedReturnViewModel.DiffMedianBonusPercent.Value;
            }

            //CompanyLinkToGPGInfo = model.CompanyLinkToGPGInfo,
            if (stashedReturnViewModel.CompanyLinkToGPGInfo != null)
            {
                result.CompanyLinkToGPGInfo = stashedReturnViewModel.CompanyLinkToGPGInfo;
            }

            if (stashedReturnViewModel.DiffMedianHourlyPercent != null)
            {
                result.DiffMedianHourlyPercent = stashedReturnViewModel.DiffMedianHourlyPercent.Value;
            }


            if (stashedReturnViewModel.FemaleLowerPayBand != null)
            {
                result.FemaleLowerPayBand = stashedReturnViewModel.FemaleLowerPayBand.Value;
            }

            if (stashedReturnViewModel.FemaleMedianBonusPayPercent != null)
            {
                result.FemaleMedianBonusPayPercent = stashedReturnViewModel.FemaleMedianBonusPayPercent.Value;
            }

            if (stashedReturnViewModel.FemaleMiddlePayBand != null)
            {
                result.FemaleMiddlePayBand = stashedReturnViewModel.FemaleMiddlePayBand.Value;
            }

            if (stashedReturnViewModel.FemaleUpperPayBand != null)
            {
                result.FemaleUpperPayBand = stashedReturnViewModel.FemaleUpperPayBand.Value;
            }

            if (stashedReturnViewModel.FemaleUpperQuartilePayBand != null)
            {
                result.FemaleUpperQuartilePayBand = stashedReturnViewModel.FemaleUpperQuartilePayBand.Value;
            }

            result.FirstName = stashedReturnViewModel.FirstName;
            result.LastName  = stashedReturnViewModel.LastName;
            result.JobTitle  = stashedReturnViewModel.JobTitle;

            if (stashedReturnViewModel.MaleLowerPayBand != null)
            {
                result.MaleLowerPayBand = stashedReturnViewModel.MaleLowerPayBand.Value;
            }

            if (stashedReturnViewModel.MaleMedianBonusPayPercent != null)
            {
                result.MaleMedianBonusPayPercent = stashedReturnViewModel.MaleMedianBonusPayPercent.Value;
            }

            if (stashedReturnViewModel.MaleUpperQuartilePayBand != null)
            {
                result.MaleUpperQuartilePayBand = stashedReturnViewModel.MaleUpperQuartilePayBand.Value;
            }

            if (stashedReturnViewModel.MaleMiddlePayBand != null)
            {
                result.MaleMiddlePayBand = stashedReturnViewModel.MaleMiddlePayBand.Value;
            }

            if (stashedReturnViewModel.MaleUpperPayBand != null)
            {
                result.MaleUpperPayBand = stashedReturnViewModel.MaleUpperPayBand.Value;
            }

            result.Status           = ReturnStatuses.Draft;
            result.MinEmployees     = (int)orgSizeRange.Minimum;
            result.MaxEmployees     = (int)orgSizeRange.Maximum;
            result.LateReason       = stashedReturnViewModel.LateReason;
            result.EHRCResponse     = stashedReturnViewModel.EHRCResponse.ToBoolean();
            result.IsLateSubmission = result.CalculateIsLateSubmission();
            result.OptedOutOfReportingPayQuarters = stashedReturnViewModel.OptedOutOfReportingPayQuarters;

            return(result);
        }