Beispiel #1
0
        /// <summary>
        ///     Returns the latest organisation name before specified date/time
        /// </summary>
        /// <param name="maxDate">Ignore name changes after this date/time - if empty returns the latest name</param>
        /// <returns>The name of the organisation</returns>
        public OrganisationName GetName(DateTime?maxDate = null)
        {
            if (maxDate == null || maxDate.Value == DateTime.MinValue)
            {
                maxDate = SectorType.GetAccountingStartDate().AddYears(1);
            }

            return(OrganisationNames.Where(n => n.Created < maxDate.Value).OrderByDescending(n => n.Created).FirstOrDefault());
        }
Beispiel #2
0
        //Returns the latest return for the specified accounting year or the latest ever if no accounting year is
        public Return GetReturn(int year = 0)
        {
            DateTime accountingStartDate = SectorType.GetAccountingStartDate(year);

            return(Returns
                   .Where(r => r.Status == ReturnStatuses.Submitted && r.AccountingDate == accountingStartDate)
                   .OrderByDescending(r => r.StatusDate)
                   .FirstOrDefault());
        }
Beispiel #3
0
        /// <summary>
        ///     Returns the latest SIC Codes before specified date/time
        /// </summary>
        /// <param name="maxDate">Ignore SIC codes changes after this date/time - if empty returns the latest SIC codes</param>
        /// <returns>The employer SIC codes</returns>
        public IEnumerable <OrganisationSicCode> GetSicCodes(DateTime?maxDate = null)
        {
            if (maxDate == null || maxDate.Value == DateTime.MinValue)
            {
                maxDate = SectorType.GetAccountingStartDate().AddYears(1);
            }

            return(OrganisationSicCodes.Where(s => s.Created < maxDate.Value && (s.Retired == null || s.Retired.Value > maxDate.Value)));
        }
Beispiel #4
0
        public string GetSicSource(DateTime?maxDate = null)
        {
            if (maxDate == null || maxDate.Value == DateTime.MinValue)
            {
                maxDate = SectorType.GetAccountingStartDate().AddYears(1);
            }

            return(OrganisationSicCodes
                   .FirstOrDefault(s => s.Created < maxDate.Value && (s.Retired == null || s.Retired.Value > maxDate.Value))
                   ?.Source);
        }
Beispiel #5
0
        public IEnumerable <Return> GetRecentReports(int recentCount)
        {
            foreach (int year in GetRecentReportingYears(recentCount))
            {
                var defaultReturn = new Return {
                    Organisation   = this,
                    AccountingDate = SectorType.GetAccountingStartDate(year),
                    Modified       = VirtualDateTime.Now
                };
                defaultReturn.IsLateSubmission = defaultReturn.CalculateIsLateSubmission();

                yield return(GetReturn(year) ?? defaultReturn);
            }
        }
Beispiel #6
0
        public IEnumerable <int> GetRecentReportingYears(int recentCount)
        {
            int endYear   = SectorType.GetAccountingStartDate().Year;
            int startYear = endYear - (recentCount - 1);

            if (startYear < Global.FirstReportingYear)
            {
                startYear = Global.FirstReportingYear;
            }

            for (int year = endYear; year >= startYear; year--)
            {
                yield return(year);
            }
        }
Beispiel #7
0
        public ScopeStatuses GetScopeStatus(int year = 0)
        {
            DateTime accountingStartDate = SectorType.GetAccountingStartDate(year);

            return(GetScopeStatus(accountingStartDate));
        }
Beispiel #8
0
        //Returns the latest scope for the current accounting date
        public OrganisationScope GetCurrentScope()
        {
            var accountingStartDate = SectorType.GetAccountingStartDate();

            return(GetScopeForYear(accountingStartDate));
        }