public static OrganisationScope CreateScope(ScopeStatuses scopeStatus, DateTime snapshotDate) { return(new OrganisationScope { ScopeStatus = scopeStatus, Status = ScopeRowStatuses.Active, SnapshotDate = snapshotDate }); }
private Organisation CreateOrgWithDeclaredAndPresumedScopes( SectorTypes testSector, ScopeStatuses testDeclaredScopeStatus, DateTime testCreated, DateTime testSnapshotDate) { var testOrg = CreateOrgWithNoScopes(1, testSector, testCreated); testOrg.OrganisationScopes.Add( new OrganisationScope { OrganisationScopeId = 1, Status = ScopeRowStatuses.Active, SnapshotDate = testSnapshotDate, ScopeStatus = testDeclaredScopeStatus }); testOrg.OrganisationScopes.Add( new OrganisationScope { OrganisationScopeId = 2, Status = ScopeRowStatuses.Active, SnapshotDate = testSnapshotDate.AddYears(1), ScopeStatus = testDeclaredScopeStatus == ScopeStatuses.InScope ? ScopeStatuses.PresumedInScope : ScopeStatuses.PresumedOutOfScope }); return(testOrg); }
private Organisation CreateOrgWithScopeForAllYears(int testOrgId, SectorTypes testSector, ScopeStatuses testScopeStatus, DateTime snapshotDate) { var firstYear = SectorTypeHelper.SnapshotDateHelper.FirstReportingYear; var lastYear = SectorTypeHelper.SnapshotDateHelper.CurrentSnapshotYear; var testOrg = CreateOrgWithNoScopes(testOrgId, testSector, VirtualDateTime.Now); // for all snapshot years check if scope exists for (var year = firstYear; year < lastYear; year++) { testOrg.OrganisationScopes.Add( new OrganisationScope { OrganisationScopeId = 1, Status = ScopeRowStatuses.Active, SnapshotDate = new DateTime(year, snapshotDate.Month, snapshotDate.Day), ScopeStatus = testScopeStatus }); } return(testOrg); }
public static CustomError SameScopesCannotBeUpdated(ScopeStatuses newScopeStatus, ScopeStatuses oldScopeStatus, int snapshotYear) { return(new CustomError( 4006, $"Unable to update to {newScopeStatus} as the record for {snapshotYear} is already showing as {oldScopeStatus}")); }
public void PreservesDeclaredScopes(SectorTypes testSectorType, ScopeStatuses testDeclaredScopeStatus, ScopeStatuses expectedPresumedScopeStatus) { // setup var testCreatedDate = mockSharedBusinessLogic.GetAccountingStartDate(testSectorType, ConfigHelpers.SharedOptions.FirstReportingYear); var testOrg = CreateOrgWithDeclaredAndPresumedScopes( testSectorType, testDeclaredScopeStatus, testCreatedDate, testCreatedDate); // act var actualChanged = scopeBusinessLogic.FillMissingScopes(testOrg); // assert Assert.IsTrue(actualChanged, "Expected change to be true for missing scopes"); var actualScopesArray = testOrg.OrganisationScopes.ToArray(); Assert.AreEqual(testDeclaredScopeStatus, actualScopesArray[0].ScopeStatus, "Expected first year scope status to match"); // check that each year is presumed out of scope after first year for (var i = 1; i < actualScopesArray.Length; i++) { var scope = actualScopesArray[i]; Assert.AreEqual(expectedPresumedScopeStatus, scope.ScopeStatus, "Expected presumed scope statuses to match"); } }
public IActionResult ChangeScopePost(long id, int year, AdminChangeScopeViewModel viewModel) { var organisation = dataRepository.Get <Organisation>(id); var currentOrganisationScope = organisation.GetScopeForYear(year); if (currentOrganisationScope.ScopeStatus != ScopeStatuses.InScope && currentOrganisationScope.ScopeStatus != ScopeStatuses.OutOfScope) { viewModel.ParseAndValidateParameters(Request, m => m.NewScopeStatus); } viewModel.ParseAndValidateParameters(Request, m => m.Reason); if (viewModel.HasAnyErrors()) { // If there are any errors, return the user back to the same page to correct the mistakes var currentScopeStatus = organisation.GetScopeStatus(year); viewModel.OrganisationName = organisation.OrganisationName; viewModel.OrganisationId = organisation.OrganisationId; viewModel.ReportingYear = year; viewModel.CurrentScopeStatus = currentScopeStatus; return(View("ChangeScope", viewModel)); } RetireOldScopesForCurrentSnapshotDate(organisation, year); ScopeStatuses newScope = ConvertNewScopeStatusToScopeStatus(viewModel.NewScopeStatus); var newOrganisationScope = new OrganisationScope { Organisation = organisation, ScopeStatus = newScope, ScopeStatusDate = VirtualDateTime.Now, ContactFirstname = currentOrganisationScope.ContactFirstname, ContactLastname = currentOrganisationScope.ContactLastname, ContactEmailAddress = currentOrganisationScope.ContactEmailAddress, Reason = viewModel.Reason, SnapshotDate = currentOrganisationScope.SnapshotDate, StatusDetails = "Changed by Admin", Status = ScopeRowStatuses.Active }; dataRepository.Insert(newOrganisationScope); dataRepository.SaveChanges(); auditLogger.AuditChangeToOrganisation( AuditedAction.AdminChangeOrganisationScope, organisation, new { PreviousScope = currentOrganisationScope.ScopeStatus.ToString(), NewScope = newScope.ToString(), Reason = viewModel.Reason }, User); return(RedirectToAction("ViewScopeHistory", "AdminOrganisationScope", new { id = organisation.OrganisationId })); }
public static Organisation GetOrganisationInAGivenScope(ScopeStatuses scope, string employerRef = null, int snapshotYear = 0) { Organisation org = GetPrivateOrganisation(employerRef); OrganisationScope organisationScope = OrganisationScopeHelper.GetOrgScopeWithThisScope(snapshotYear, org.SectorType, scope); org.OrganisationScopes.Add(organisationScope); return(org); }
public IActionResult DeclareScope(string id) { //Ensure user has completed the registration process IActionResult checkResult = CheckUserRegisteredOk(out User currentUser); if (checkResult != null) { return(checkResult); } // Decrypt org id if (!id.DecryptToId(out long organisationId)) { return(new HttpBadRequestResult($"Cannot decrypt employer id {id}")); } // Check the user has permission for this organisation UserOrganisation userOrg = currentUser.UserOrganisations.FirstOrDefault(uo => uo.OrganisationId == organisationId); if (userOrg == null) { return(new HttpForbiddenResult($"User {currentUser?.EmailAddress} is not registered for employer id {organisationId}")); } // Ensure this user is registered fully for this organisation if (userOrg.PINConfirmedDate == null) { return(new HttpForbiddenResult( $"User {currentUser?.EmailAddress} has not completed registration for employer {userOrg.Organisation.EmployerReference}")); } //Get the current snapshot date DateTime snapshotDate = userOrg.Organisation.SectorType.GetAccountingStartDate().AddYears(-1); if (snapshotDate.Year < Global.FirstReportingYear) { return(new HttpBadRequestResult($"Snapshot year {snapshotDate.Year} is invalid")); } ScopeStatuses scopeStatus = ScopeBusinessLogic.GetLatestScopeStatusForSnapshotYear(organisationId, snapshotDate.Year); if (scopeStatus.IsAny(ScopeStatuses.InScope, ScopeStatuses.OutOfScope)) { return(new HttpBadRequestResult("Explicit scope is already set")); } // build the view model var model = new DeclareScopeModel { OrganisationId = userOrg.OrganisationId, OrganisationName = userOrg.Organisation.OrganisationName, SnapshotDate = snapshotDate }; return(View(model)); }
public static OrganisationScope GetOrgScopeWithThisScope(int snapshotYear, SectorTypes organisationSectorType, ScopeStatuses scope) { if (snapshotYear == 0) { snapshotYear = organisationSectorType.GetAccountingStartDate().Year; } var org = GetOrganisationScope(snapshotYear, organisationSectorType); org.ScopeStatus = scope; return(org); }
public void PreservesPresumedScopesFromPreviousYear(SectorTypes testSectorType, ScopeStatuses testDeclaredScopeStatus, ScopeStatuses expectedPresumedScopeStatus) { // setup DateTime testSnapshotDate = testSectorType.GetAccountingStartDate(Global.FirstReportingYear); Organisation testOrg = CreateOrgWithScopeForAllYears(1, testSectorType, testDeclaredScopeStatus, testSnapshotDate); // act bool actualChanged = scopeBusinessLogic.FillMissingScopes(testOrg); // assert Assert.IsTrue(actualChanged, "Expected change to be true for missing scopes"); }
private NewScopeStatus?GetNewScopeStatus(ScopeStatuses previousScopeStatus) { if (previousScopeStatus == ScopeStatuses.InScope) { return(NewScopeStatus.OutOfScope); } if (previousScopeStatus == ScopeStatuses.OutOfScope) { return(NewScopeStatus.InScope); } return(null); }
public static void AddScopeStatus(ScopeStatuses scopeStatus, int year = 0, params Organisation[] orgs) { foreach (var org in orgs) { org.OrganisationScopes.Add( new OrganisationScope { Organisation = org, ScopeStatus = scopeStatus, SnapshotDate = org.SectorType.GetAccountingStartDate(year), Status = ScopeRowStatuses.Active }); } }
/// <summary> /// Adds a new scope and updates the latest scope (if required) /// </summary> /// <param name="org"></param> /// <param name="scopeStatus"></param> /// <param name="snapshotDate"></param> /// <param name="currentUser"></param> public virtual OrganisationScope SetPresumedScope(Organisation org, ScopeStatuses scopeStatus, DateTime snapshotDate, User currentUser = null) { //Ensure scopestatus is presumed if (scopeStatus != ScopeStatuses.PresumedInScope && scopeStatus != ScopeStatuses.PresumedOutOfScope) { throw new ArgumentOutOfRangeException(nameof(scopeStatus)); } //Check no previous scopes if (org.OrganisationScopes.Any(os => os.SnapshotDate == snapshotDate)) { throw new ArgumentException( $"A scope already exists for snapshot year {snapshotDate.Year} for organisation employer reference '{org.EmployerReference}'", nameof(scopeStatus)); } //Check for conflict with previous years scope if (snapshotDate.Year > _sharedBusinessLogic.SharedOptions.FirstReportingYear) { var previousScope = GetLatestScopeStatusForSnapshotYear(org, snapshotDate.Year - 1); if (previousScope == ScopeStatuses.InScope && scopeStatus == ScopeStatuses.PresumedOutOfScope || previousScope == ScopeStatuses.OutOfScope && scopeStatus == ScopeStatuses.PresumedInScope) { throw new ArgumentException( $"Cannot set {scopeStatus} for snapshot year {snapshotDate.Year} when previos year was {previousScope} for organisation employer reference '{org.EmployerReference}'", nameof(scopeStatus)); } } var newScope = new OrganisationScope { OrganisationId = org.OrganisationId, ContactEmailAddress = currentUser?.EmailAddress, ContactFirstname = currentUser?.Firstname, ContactLastname = currentUser?.Lastname, ScopeStatus = scopeStatus, Status = ScopeRowStatuses.Active, StatusDetails = "Generated by the system", SnapshotDate = snapshotDate }; org.OrganisationScopes.Add(newScope); return(newScope); }
/// <summary> /// Creates a new scope record using an existing scope and applies a new status /// </summary> /// <param name="existingOrgScopeId"></param> /// <param name="newStatus"></param> public virtual async Task <OrganisationScope> UpdateScopeStatusAsync(long existingOrgScopeId, ScopeStatuses newStatus) { var oldOrgScope = await _sharedBusinessLogic.DataRepository.FirstOrDefaultAsync <OrganisationScope>(os => os.OrganisationScopeId == existingOrgScopeId); // when OrganisationScope isn't found then throw ArgumentOutOfRangeException if (oldOrgScope == null) { throw new ArgumentOutOfRangeException( nameof(existingOrgScopeId), $"Cannot find organisation with OrganisationScopeId: {existingOrgScopeId}"); } var org = await _sharedBusinessLogic.DataRepository.FirstOrDefaultAsync <Organisation>(o => o.OrganisationId == oldOrgScope.OrganisationId); // when Organisation isn't found then throw ArgumentOutOfRangeException if (org == null) { throw new ArgumentOutOfRangeException( nameof(oldOrgScope.OrganisationId), $"Cannot find organisation with OrganisationId: {oldOrgScope.OrganisationId}"); } // When Organisation is Found Then Save New Scope Record With New Status var newScope = new OrganisationScope { OrganisationId = oldOrgScope.OrganisationId, ContactEmailAddress = oldOrgScope.ContactEmailAddress, ContactFirstname = oldOrgScope.ContactFirstname, ContactLastname = oldOrgScope.ContactLastname, ReadGuidance = oldOrgScope.ReadGuidance, Reason = oldOrgScope.Reason, ScopeStatus = newStatus, ScopeStatusDate = VirtualDateTime.Now, RegisterStatus = oldOrgScope.RegisterStatus, RegisterStatusDate = oldOrgScope.RegisterStatusDate, // carry the snapshot date over SnapshotDate = oldOrgScope.SnapshotDate }; await SaveScopeAsync(org, true, newScope); return(newScope); }
public virtual async Task <CustomResult <OrganisationScope> > AddScopeAsync(Organisation organisation, ScopeStatuses newStatus, User currentUser, int snapshotYear, string comment, bool saveToDatabase) { snapshotYear = _sharedBusinessLogic.GetAccountingStartDate(organisation.SectorType, snapshotYear) .Year; var oldOrgScope = organisation.GetScopeOrThrow(snapshotYear); if (oldOrgScope.ScopeStatus == newStatus) { return(new CustomResult <OrganisationScope>( InternalMessages.SameScopesCannotBeUpdated(newStatus, oldOrgScope.ScopeStatus, snapshotYear))); } // When Organisation is Found Then Save New Scope Record With New Status var newScope = new OrganisationScope { OrganisationId = oldOrgScope.OrganisationId, Organisation = organisation, /* Updated by the current user */ ContactEmailAddress = currentUser.EmailAddress, ContactFirstname = currentUser.Firstname, ContactLastname = currentUser.Lastname, ReadGuidance = oldOrgScope.ReadGuidance, Reason = !string.IsNullOrEmpty(comment) ? comment : oldOrgScope.Reason, ScopeStatus = newStatus, ScopeStatusDate = VirtualDateTime.Now, StatusDetails = _sharedBusinessLogic.AuthorisationBusinessLogic.IsAdministrator(currentUser) ? "Changed by Admin" : null, RegisterStatus = oldOrgScope.RegisterStatus, RegisterStatusDate = oldOrgScope.RegisterStatusDate, // carry the snapshot date over SnapshotDate = oldOrgScope.SnapshotDate }; await SaveScopeAsync(organisation, saveToDatabase, newScope); return(new CustomResult <OrganisationScope>(newScope)); }
public void UpdateScopes(Organisation organisation, ScopeStatuses newStatus, int reportingYear, string reasonForChange, bool?haveReadGuidance) { User currentUser = ControllerHelper.GetGpgUserFromAspNetUser(User, dataRepository); organisation.OrganisationScopes.Add( new OrganisationScope { OrganisationId = organisation.OrganisationId, ScopeStatus = newStatus, StatusDetails = "Generated by the system", ContactFirstname = currentUser.Firstname, ContactLastname = currentUser.Lastname, ContactEmailAddress = currentUser.EmailAddress, Status = ScopeRowStatuses.Active, SnapshotDate = organisation.SectorType.GetAccountingStartDate(reportingYear), Reason = reasonForChange, ReadGuidance = haveReadGuidance }); }
public void PreservesPresumedScopesFromPreviousYear(SectorTypes testSectorType, ScopeStatuses testDeclaredScopeStatus, ScopeStatuses expectedPresumedScopeStatus) { // setup var testSnapshotDate = mockSharedBusinessLogic.GetAccountingStartDate(testSectorType, ConfigHelpers.SharedOptions.FirstReportingYear); var testOrg = CreateOrgWithScopeForAllYears(1, testSectorType, testDeclaredScopeStatus, testSnapshotDate); // act var actualChanged = scopeBusinessLogic.FillMissingScopes(testOrg); // assert Assert.IsTrue(actualChanged, "Expected change to be true for missing scopes"); Assert.NotNull(testOrg.LatestScope, "Expected latest scope to be set"); Assert.AreEqual(expectedPresumedScopeStatus, testOrg.LatestScope.ScopeStatus, "Expected latest scope to be PresumedOutOfScope"); }
private static string ScopeStatusToString(ScopeStatuses scope) { switch (scope) { case ScopeStatuses.InScope: return("In scope"); case ScopeStatuses.OutOfScope: return("Out of scope"); case ScopeStatuses.PresumedInScope: return("Presumed in scope"); case ScopeStatuses.PresumedOutOfScope: return("Presumed out of scope"); case ScopeStatuses.Unknown: default: return("Unknown"); } }
public void IsFalseWhenNotVoluntary(SectorTypes testSector, int testOrgSize, ScopeStatuses testScopeStatus) { // Arrange var testOrganisation = testSector == SectorTypes.Private ? OrganisationHelper.GetPrivateOrganisation() : OrganisationHelper.GetPublicOrganisation(); var snapshotDate = testSector.GetAccountingStartDate(VirtualDateTime.Now.Year); var testScope = ScopeHelper.CreateScope(testScopeStatus, snapshotDate); var testReturn = ReturnHelper.CreateTestReturn(testOrganisation, snapshotDate.Year); testReturn.MaxEmployees = testOrgSize; OrganisationHelper.LinkOrganisationAndReturn(testOrganisation, testReturn); OrganisationHelper.LinkOrganisationAndScope(testOrganisation, testScope, true); // Act var actual = testReturn.IsVoluntarySubmission(); // Assert Assert.IsFalse((bool)actual); }
private Organisation CreateOrgWithScopeForAllYears(int testOrgId, SectorTypes testSector, ScopeStatuses testScopeStatus, DateTime snapshotDate) { int firstYear = Global.FirstReportingYear; int lastYear = SectorTypes.Private.GetAccountingStartDate().Year; Organisation testOrg = CreateOrgWithNoScopes(testOrgId, testSector, VirtualDateTime.Now); // for all snapshot years check if scope exists for (int year = firstYear; year < lastYear; year++) { testOrg.OrganisationScopes.Add( new OrganisationScope { OrganisationScopeId = 1, Status = ScopeRowStatuses.Active, SnapshotDate = new DateTime(year, snapshotDate.Month, snapshotDate.Day), ScopeStatus = testScopeStatus }); } return(testOrg); }
public IActionResult DeclareScope(DeclareScopeModel model, string id) { // Ensure user has completed the registration process IActionResult checkResult = CheckUserRegisteredOk(out User currentUser); if (checkResult != null) { return(checkResult); } // Decrypt org id if (!id.DecryptToId(out long organisationId)) { return(new HttpBadRequestResult($"Cannot decrypt employer id {id}")); } // Check the user has permission for this organisation UserOrganisation userOrg = currentUser.UserOrganisations.FirstOrDefault(uo => uo.OrganisationId == organisationId); if (userOrg == null) { return(new HttpForbiddenResult($"User {currentUser?.EmailAddress} is not registered for employer id {organisationId}")); } // Ensure this user is registered fully for this organisation if (userOrg.PINConfirmedDate == null) { return(new HttpForbiddenResult( $"User {currentUser?.EmailAddress} has not completed registration for employer {userOrg.Organisation.EmployerReference}")); } //Check the year parameters if (model.SnapshotDate.Year < Global.FirstReportingYear || model.SnapshotDate.Year > VirtualDateTime.Now.Year) { return(new HttpBadRequestResult($"Snapshot year {model.SnapshotDate.Year} is invalid")); } //Check if we need the current years scope ScopeStatuses scopeStatus = ScopeBusinessLogic.GetLatestScopeStatusForSnapshotYear(organisationId, model.SnapshotDate.Year); if (scopeStatus.IsAny(ScopeStatuses.InScope, ScopeStatuses.OutOfScope)) { return(new HttpBadRequestResult("Explicit scope is already set")); } //Validate the submitted fields ModelState.Clear(); if (model.ScopeStatus == null || model.ScopeStatus == ScopeStatuses.Unknown) { AddModelError(3032, "ScopeStatus"); } if (!ModelState.IsValid) { this.CleanModelErrors <DeclareScopeModel>(); return(View("DeclareScope", model)); } //Create last years declared scope var newScope = new OrganisationScope { OrganisationId = userOrg.OrganisationId, Organisation = userOrg.Organisation, ContactEmailAddress = currentUser.EmailAddress, ContactFirstname = currentUser.Firstname, ContactLastname = currentUser.Lastname, ScopeStatus = model.ScopeStatus.Value, Status = ScopeRowStatuses.Active, ScopeStatusDate = VirtualDateTime.Now, SnapshotDate = model.SnapshotDate }; //Save the new declared scopes ScopeBusinessLogic.SaveScope(userOrg.Organisation, true, newScope); return(View("ScopeDeclared", model)); }
public virtual async Task <CustomResult <OrganisationScope> > SetAsScopeAsync(string employerRef, int changeScopeToSnapshotYear, string changeScopeToComment, User currentUser, ScopeStatuses scopeStatus, bool saveToDatabase) { var org = await GetOrganisationByEmployerReferenceOrThrowAsync(employerRef); return(await _scopeLogic.AddScopeAsync( org, scopeStatus, currentUser, changeScopeToSnapshotYear, changeScopeToComment, saveToDatabase)); }
public void SubmissionBusinessLogic_IsInScopeForThisReportYear_ReturnsTrueFalseCorrectly(int returnId, int maxEmployees, ScopeStatuses scope, bool expected) { // Arrange var submissionBusinessLogic = new SubmissionBusinessLogic( Mock.Of <ISharedBusinessLogic>(), Mock.Of <IDataRepository>(), Mock.Of <IRecordLogger>()); var organisation = OrganisationHelper.GetOrganisationInAGivenScope(scope, "employerRefInScope", 2017); var returnToConvert = ReturnHelper.CreateTestReturn(organisation); returnToConvert.ReturnId = returnId; returnToConvert.MaxEmployees = maxEmployees; // Act var actualConvertedReturnViewModel = submissionBusinessLogic.ConvertSubmissionReportToReturnViewModel(returnToConvert); // Assert Assert.AreEqual(expected, actualConvertedReturnViewModel.IsInScopeForThisReportYear); }
public IActionResult ManageOrganisation(string id) { // Check for feature flag and redirect if enabled if (FeatureFlagHelper.IsFeatureEnabled(FeatureFlag.NewManageOrganisationsJourney)) { return(RedirectToAction("ManageOrganisationGet", "ManageOrganisations", new { encryptedOrganisationId = id })); } //Ensure user has completed the registration process IActionResult checkResult = CheckUserRegisteredOk(out User currentUser); if (checkResult != null) { return(checkResult); } // Decrypt org id if (!id.DecryptToId(out long organisationId)) { return(new HttpBadRequestResult($"Cannot decrypt organisation id {id}")); } // Check the user has permission for this organisation UserOrganisation userOrg = currentUser.UserOrganisations.FirstOrDefault(uo => uo.OrganisationId == organisationId); if (userOrg == null || userOrg.PINConfirmedDate == null) { return(new HttpForbiddenResult($"User {currentUser?.EmailAddress} is not registered for organisation id {organisationId}")); } // clear the stash this.ClearStash(); //Get the current snapshot date DateTime currentSnapshotDate = userOrg.Organisation.SectorType.GetAccountingStartDate(); //Make sure we have an explicit scope for last and year for organisations new to this year if (userOrg.HasBeenActivated() && userOrg.Organisation.Created >= currentSnapshotDate) { ScopeStatuses scopeStatus = ScopeBusinessLogic.GetLatestScopeStatusForSnapshotYear(organisationId, currentSnapshotDate.Year - 1); if (!scopeStatus.IsAny(ScopeStatuses.InScope, ScopeStatuses.OutOfScope)) { return(RedirectToAction(nameof(DeclareScope), "Organisation", new { id })); } } // get any associated users for the current org List <UserOrganisation> associatedUserOrgs = userOrg.GetAssociatedUsers().ToList(); // build the view model List <int> yearsWithDraftReturns = DataRepository.GetAll <DraftReturn>() .Where(d => d.OrganisationId == organisationId) .Select(d => d.SnapshotYear) .ToList(); var model = new ManageOrganisationModel { CurrentUserOrg = userOrg, AssociatedUserOrgs = associatedUserOrgs, EncCurrentOrgId = Encryption.EncryptQuerystring(organisationId.ToString()), ReportingYearsWithDraftReturns = yearsWithDraftReturns }; return(View(model)); }
private void SetInitialScopeForYear(Organisation organisation, DateTime snapshotDate, ScopeStatuses scopeStatus) { var organisationScope = new OrganisationScope { Organisation = organisation, ScopeStatus = scopeStatus, ScopeStatusDate = VirtualDateTime.Now, SnapshotDate = snapshotDate, Status = ScopeRowStatuses.Active, StatusDetails = "Generated by the system" }; organisation.OrganisationScopes.Add(organisationScope); dataRepository.Insert(organisationScope); }
public OrganisationScopeBuilder WithScopeStatus(ScopeStatuses scopeStatus) { this.scopeStatus = scopeStatus; return(this); }
public void Is_False_When_ModifiedDate_Is_Late_And_ExcludeFromLateFlagEnforcement_Year_And_AnyScope(SectorTypes sector, ScopeStatuses scopeStatus) { // Arrange int testYear = Global.ReportingStartYearsToExcludeFromLateFlagEnforcement.First(); int modifiedDateOffset = 2; Return testReturn = ReturnHelper.CreateLateReturn(testYear, sector, scopeStatus, modifiedDateOffset); // Act bool actual = testReturn.IsLateSubmission; // Assert Assert.AreEqual(false, actual); }
public void Is_False_When_ModifiedDate_Is_Late_And_OutOfScope(SectorTypes sector, ScopeStatuses scopeStatus) { // Arrange int testYear = GetRandomReportingYear(); int modifiedDateOffset = 2; Return testReturn = ReturnHelper.CreateLateReturn(testYear, sector, scopeStatus, modifiedDateOffset); // Act bool actual = testReturn.IsLateSubmission; // Assert Assert.AreEqual(false, actual); }
public void Is_True_When_ModifiedDate_Is_Late_And_InScope(SectorTypes sector, ScopeStatuses scopeStatus) { // Arrange int testYear = GetRandomReportingYear(ignoreYearsExcludedFromLateFlagEnforcement: true); DateTime snapshotDate = sector.GetAccountingStartDate(testYear); DateTime modifiedDate = ReportingYearsHelper.GetDeadlineForAccountingDate(snapshotDate).AddDays(2); Organisation testOrganisation = sector == SectorTypes.Private ? OrganisationHelper.GetPrivateOrganisation() : OrganisationHelper.GetPublicOrganisation(); OrganisationScope testScope = ScopeHelper.CreateScope(scopeStatus, snapshotDate); Return testReturn = ReturnHelper.CreateLateReturn(testOrganisation, snapshotDate, modifiedDate, testScope); // Act bool actual = testReturn.IsLateSubmission; // Assert Assert.AreEqual(true, actual); }
public void Is_False_When_ModifiedDate_Is_Late_And_OutOfScope(SectorTypes sector, ScopeStatuses scopeStatus) { var totalYearOffsets = 4; for (var yearOffset = 0; yearOffset < totalYearOffsets; yearOffset++) { // Arrange int testYear = VirtualDateTime.Now.Year - yearOffset; DateTime snapshotDate = sector.GetAccountingStartDate(testYear); DateTime nextSnapshotDate = snapshotDate.AddYears(1); DateTime modifiedDate = nextSnapshotDate.AddDays(2); Organisation testOrganisation = sector == SectorTypes.Private ? OrganisationHelper.GetPrivateOrganisation() : OrganisationHelper.GetPublicOrganisation(); OrganisationScope testScope = ScopeHelper.CreateScope(scopeStatus, snapshotDate); Return testReturn = ReturnHelper.CreateLateReturn(testOrganisation, snapshotDate, modifiedDate, testScope); // Act bool actual = testReturn.IsLateSubmission; // Assert Assert.AreEqual(false, actual); } }