public async Task <IHttpActionResult> Get(string identifier, OrganisationType organisationType)
        {
            var query = new GetOrganisationQuery
            {
                OrganisationType = organisationType,
                Identifier       = identifier
            };

            try
            {
                var response = await _mediator.SendAsync(query);

                return(Ok(response.Organisation));
            }
            catch (BadOrganisationIdentifierException e)
            {
                return(BadRequest(e.Message));
            }
            catch (OperationNotSupportedForOrganisationTypeException e)
            {
                return(BadRequest(e.Message));
            }
            catch (OrganisationNotFoundException)
            {
                return(NotFound());
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }
        }
Exemple #2
0
        private async Task <EnhetsregisteretContract> GetEnhet(string orgnr, OrganisationType organisationType)
        {
            try
            {
                var responseMessage = await httpClient.GetAsync($"enhetsregisteret/{organisationType.ToString().ToLower()}/{orgnr}.json");

                if (responseMessage.IsSuccessStatusCode)
                {
                    var result = await responseMessage.Content.ReadAsStringAsync();

                    var enhetsregisterContract = JsonConvert.DeserializeObject <EnhetsregisteretContract>(result);


                    return(enhetsregisterContract);
                }
                if (responseMessage.StatusCode == HttpStatusCode.NotFound)
                {
                    return(null);
                }
                throw new Exception($"Unexcpected http response from Brreg: {responseMessage.StatusCode}");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
        public IList <OrganisationType> Get()
        {
            try
            {
                Logger.LogInfo("Get: Organisation type process start");
                IList <OrganisationType> lstOrganisationType = new List <OrganisationType>();

                DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(string.Format(SELECT_ALL));
                foreach (DataRow dr in dtAppConfig.Rows)
                {
                    OrganisationType OrganisationType = convertToOrganisationTypeObject(dr);
                    lstOrganisationType.Add(OrganisationType);
                }
                Logger.LogInfo("Get: Organisation type process completed.");
                return(lstOrganisationType);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                return(null);
            }
        }
        public async Task <ActionResult> Confirm(
            string hashedAccountId, string name, string code, string address, DateTime?incorporated,
            string legalEntityStatus, OrganisationType organisationType, short?publicSectorDataSource, string sector)
        {
            var request = new CreateNewLegalEntityViewModel
            {
                HashedAccountId        = hashedAccountId,
                Name                   = name,
                Code                   = code,
                Address                = address,
                IncorporatedDate       = incorporated,
                ExternalUserId         = OwinWrapper.GetClaimValue(@"sub"),
                LegalEntityStatus      = string.IsNullOrWhiteSpace(legalEntityStatus) ? null : legalEntityStatus,
                Source                 = (short)organisationType,
                PublicSectorDataSource = publicSectorDataSource,
                Sector                 = sector
            };

            var response = await _orchestrator.CreateLegalEntity(request);

            var flashMessage = new FlashMessageViewModel
            {
                HiddenFlashMessageInformation = "page-organisations-added",
                Headline = $"{response.Data.EmployerAgreement.LegalEntityName} has been added",
                Severity = FlashMessageSeverityLevel.Success
            };

            AddFlashMessageToCookie(flashMessage);

            return(RedirectToAction("Index", "EmployerAgreement", new { hashedAccountId }));
        }
Exemple #5
0
        public async Task ThenAAddedLegalEntityEventIsPublished(OrganisationType inputOrganisationType, Types.Models.OrganisationType expectedOrganisationType)
        {
            const string organisationName = "Org";

            //Arrange
            var createAccountCommand = new CreateAccountCommand
            {
                PayeReference       = "123EDC", AccessToken = "123rd", RefreshToken = "45YT", OrganisationStatus = "active",
                OrganisationName    = organisationName, ExternalUserId = _user.Ref.ToString(),
                OrganisationType    = inputOrganisationType, OrganisationReferenceNumber = ExpectedOrganisationReferenceNumber,
                OrganisationAddress = ExpectedOrganisationAddress
            };

            //Act
            await _handler.Handle(createAccountCommand);

            //Assert
            var addedLegalEntityEvent = _eventPublisher.Events.OfType <AddedLegalEntityEvent>().Single();

            addedLegalEntityEvent.AgreementId.Should().Be(ExpectedEmployerAgreementId);
            addedLegalEntityEvent.LegalEntityId.Should().Be(ExpectedLegalEntityId);
            addedLegalEntityEvent.OrganisationName.Should().Be(organisationName);
            addedLegalEntityEvent.AccountId.Should().Be(ExpectedAccountId);
            addedLegalEntityEvent.AccountLegalEntityId.Should().Be(ExpectedAccountLegalEntityId);
            addedLegalEntityEvent.AccountLegalEntityPublicHashedId.Should().Be(ExpectedAccountLegalEntityPublicHashString);
            addedLegalEntityEvent.UserName.Should().Be(_user.FullName);
            addedLegalEntityEvent.UserRef.Should().Be(_user.Ref);
            addedLegalEntityEvent.OrganisationReferenceNumber.Should().Be(ExpectedOrganisationReferenceNumber);
            addedLegalEntityEvent.OrganisationAddress.Should().Be(ExpectedOrganisationAddress);
            addedLegalEntityEvent.OrganisationType.Should().Be(expectedOrganisationType);
            //addedLegalEntityEvent.Created.Should().Be(rightAboutNow);
        }
Exemple #6
0
        /// <summary>
        /// Update a OrganisationType
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="user"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="code"></param>
        /// <param name="lockID"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        public void DeleteOrganisationType(string currentUser, string user, string appID, string overrideID, string code, string lockID, IRepository <OrganisationType> dataRepository, IUnitOfWork uow)
        {
            try
            {
                #region Parameter validation

                // Validate parameters
                if (string.IsNullOrEmpty(currentUser))
                {
                    throw new ArgumentOutOfRangeException("currentUser");
                }
                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentOutOfRangeException("user");
                }
                if (string.IsNullOrEmpty(appID))
                {
                    throw new ArgumentOutOfRangeException("appID");
                }
                if (string.IsNullOrEmpty(code))
                {
                    throw new ArgumentOutOfRangeException("code");
                }
                if (string.IsNullOrEmpty(lockID))
                {
                    throw new ArgumentOutOfRangeException("lockID");
                }
                if (null == dataRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }

                #endregion

                using (uow)
                {
                    // Convert string to guid
                    Guid codeGuid = Guid.Parse(code);

                    // Find item based on ID
                    OrganisationType dataEntity = dataRepository.Single(x => x.Code == codeGuid);

                    // Delete the item
                    dataRepository.Delete(dataEntity);

                    // Commit unit of work
                    uow.Commit();
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                ExceptionManager.ShieldException(e);
            }
        }
Exemple #7
0
        public async Task <HttpResponseMessage> CallGetAsync(string identifier, OrganisationType organisationType)
        {
            var controller = CreateOrganisationController();

            var cont = await controller.Get(identifier, organisationType);

            return(await cont.ExecuteAsync(CancellationToken.None));
        }
        private OrganisationType convertToOrganisationTypeObject(DataRow dr)
        {
            OrganisationType OrganisationType = new OrganisationType();

            OrganisationType.Id   = dr.Field <int>("ID");
            OrganisationType.Type = dr.Field <string>("Type");
            return(OrganisationType);
        }
 public UpdateOrganisationTypeDetails(Guid id, OrganisationType type, string name, string tradingName, string companiesRegistrationNumber)
 {
     OrganisationId              = id;
     OrganisationType            = type;
     Name                        = name;
     TradingName                 = tradingName;
     CompaniesRegistrationNumber = companiesRegistrationNumber;
 }
Exemple #10
0
        public bool IsValidOrganisationType(OrganisationType organisationType)
        {
            if (organisationType == null)
            {
                return(false);
            }

            return(IsValidOrganisationTypeId(organisationType.Id));
        }
Exemple #11
0
        public Organisation(string orgName, OrganisationType orgType, string location, string director)
        {
            OrganisationName = orgName;
            OrganisationType = orgType;
            Location         = location;
            Director         = director;

            Contracts  = new HashSet <Contract>();
            Recruiters = new HashSet <RecruiterAccount>();
        }
Exemple #12
0
        public ReferenceDataApiClientTestFixtures WithGetLatestDetailsResponse(OrganisationType organisationType, string registrationId, Organisation data, HttpStatusCode statusCode)
        {
            HttpClientMock
            .Setup(c => c.GetAsync($"{BaseUrl}get?identifier={registrationId}&organisationType={organisationType}", It.IsAny <Func <HttpResponseMessage, bool> >()))
            .Callback <string, Func <HttpResponseMessage, bool> >((url, responseChecker) =>
            {
                CalledUrls.Add(url);
                responseChecker(new HttpResponseMessage(statusCode));
            })
            .ReturnsAsync(() => JsonConvert.SerializeObject(data));

            return(this);
        }
Exemple #13
0
        private Organisation ValidOrganisation(OrganisationType organisationType)
        {
            if (organisationType == OrganisationType.SoleTraderOrIndividual)
            {
                return(Organisation.CreateSoleTrader("Trading Name"));
            }

            if (organisationType == OrganisationType.Partnership)
            {
                return(Organisation.CreatePartnership("Trading Name"));
            }

            return(Organisation.CreateRegisteredCompany("Company Name", "AB123456", "Trading Name"));
        }
        private Organisation ValidOrganisation(OrganisationType organisationType)
        {
            if (organisationType == OrganisationType.SoleTraderOrIndividual)
            {
                return Organisation.CreateSoleTrader("Trading Name");
            }

            if (organisationType == OrganisationType.Partnership)
            {
                return Organisation.CreatePartnership("Trading Name");
            }

            return Organisation.CreateRegisteredCompany("Company Name", "AB123456", "Trading Name");
        }
 public AddAccountLegalEntityCommand(long accountId, long accountLegalEntityId, long maLegalEntityId,
                                     string accountLegalEntityPublicHashedId, string organisationName, OrganisationType organisationType,
                                     string organisationReferenceNumber, string organisationAddress, DateTime created)
 {
     AccountId                        = accountId;
     AccountLegalEntityId             = accountLegalEntityId;
     MaLegalEntityId                  = maLegalEntityId;
     AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId;
     OrganisationName                 = organisationName;
     OrganisationType                 = organisationType;
     OrganisationReferenceNumber      = organisationReferenceNumber;
     OrganisationAddress              = organisationAddress;
     Created = created;
 }
        private static bool IsFinancialExempt(ApplyTypes.FHADetails financials, OrganisationType orgType)
        {
            if (financials == null)
            {
                return(false);
            }

            bool financialExempt        = financials.FinancialExempt ?? false;
            bool orgTypeFinancialExempt = (orgType != null) && orgType.FinancialExempt;

            bool financialIsNotDue = (financials.FinancialDueDate?.Date ?? DateTime.MinValue) > DateTime.Today;

            return(financialExempt || financialIsNotDue || orgTypeFinancialExempt);
        }
Exemple #17
0
 public AccountLegalEntity(Account account, long id, long maLegalEntityId, string legalEntityId, string publicHashedId,
                           string name, OrganisationType organisationType, string address, DateTime created)
 {
     Id               = id;
     LegalEntityId    = legalEntityId;
     MaLegalEntityId  = maLegalEntityId;
     PublicHashedId   = publicHashedId;
     Account          = account;
     AccountId        = account.Id;
     Name             = name;
     OrganisationType = organisationType;
     Address          = address;
     Created          = created;
     Deleted          = null;
 }
Exemple #18
0
 public void ChangeDetails(OrganisationType organisationType, string organisationName, string departmentName, string contactFirstName, string contactSurname, string streetAddress, string city, string state, string postCode, string countryCode, string contactNumber, string contactEmail)
 {
     OrganisationType = organisationType;
     OrganisationName = organisationName;
     DepartmentName   = departmentName;
     ContactFirstName = contactFirstName;
     ContactSurname   = contactSurname;
     StreetAddress    = streetAddress;
     City             = city;
     State            = state;
     PostCode         = postCode;
     CountryCode      = countryCode;
     ContactNumber    = contactNumber;
     ContactEmail     = contactEmail;
 }
Exemple #19
0
        public void GetLatestDetails_SpecifiedStatusCode_ShouldCauseExpectedExceptionInClient(
            OrganisationType organisationType,
            string registeredId,
            HttpStatusCode statusCode,
            Type expectedException)
        {
            var expectedOrganisation = new Organisation {
                Code = registeredId
            };

            var fixtures = new ReferenceDataApiClientTestFixtures()
                           .WithBaseUrl(@"http://some-url/api/organisations/")
                           .WithGetLatestDetailsResponse(organisationType, registeredId, expectedOrganisation, statusCode);

            Assert.ThrowsAsync(expectedException, () => fixtures.GetLatestDetailsAsync(organisationType, registeredId));
        }
Exemple #20
0
 public ChangeContactDetailsCommand(int id, OrganisationType organisationType, string organisationName, string departmentName, string contactFirstName, string contactSurname, string streetAddress, string city, string state, string postCode, string countryCode, string contactNumber, string contactEmail) : this()
 {
     Id = id;
     OrganisationType = organisationType;
     OrganisationName = organisationName;
     DepartmentName   = departmentName;
     ContactFirstName = contactFirstName;
     ContactSurname   = contactSurname;
     StreetAddress    = streetAddress;
     City             = city;
     State            = state;
     PostCode         = postCode;
     CountryCode      = countryCode;
     ContactNumber    = contactNumber;
     ContactEmail     = contactEmail;
 }
Exemple #21
0
        public async Task <ActionResult> Confirm(
            string hashedAccountId, string name, string code, string address, DateTime?incorporated,
            string legalEntityStatus, OrganisationType organisationType, byte?publicSectorDataSource, string sector, bool newSearch)
        {
            var request = new CreateNewLegalEntityViewModel
            {
                HashedAccountId        = hashedAccountId,
                Name                   = name,
                Code                   = code,
                Address                = address,
                IncorporatedDate       = incorporated,
                ExternalUserId         = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName),
                LegalEntityStatus      = string.IsNullOrWhiteSpace(legalEntityStatus) ? null : legalEntityStatus,
                Source                 = organisationType,
                PublicSectorDataSource = publicSectorDataSource,
                Sector                 = sector
            };

            var response = await _orchestrator.CreateLegalEntity(request);

            var flashMessage = new FlashMessageViewModel
            {
                HiddenFlashMessageInformation = "page-organisations-added",
                Headline = $"{response.Data.EmployerAgreement.LegalEntityName} has been added",
                Severity = FlashMessageSeverityLevel.Success
            };

            AddFlashMessageToCookie(flashMessage);
            if (newSearch)
            {
                return(RedirectToAction(ControllerConstants.OrganisationAddedNextStepsSearchActionName,
                                        new
                {
                    hashedAccountId,
                    organisationName = name,
                    hashedAgreementId = response.Data.EmployerAgreement.HashedAgreementId
                }));
            }

            return(RedirectToAction(ControllerConstants.OrganisationAddedNextStepsActionName,
                                    new
            {
                hashedAccountId,
                organisationName = name,
                hashedAgreementId = response.Data.EmployerAgreement.HashedAgreementId
            }));
        }
        public Result Delete(OrganisationType OrganisationType)
        {
            var result = new Result();

            try
            {
                OrganisationTypeService OrganisationTypeService = new OrganisationTypeService();
                OrganisationTypeService.Delete(OrganisationType);
                result.IsSuccess = true;
            }
            catch (Exception exception)
            {
                result.IsSuccess     = false;
                result.ExceptionInfo = exception;
            }
            return(result);
        }
 public void Delete(OrganisationType OrganisationType)
 {
     try
     {
         DataBase.DBService.ExecuteCommand(string.Format(DELETE_BY_ID, OrganisationType.Id));
         Activity.ActivitiesService.Add(ActivityType.DeleteOrganisationType, EntryStatus.Success,
                                        Source.Server, OrganisationType.UpdatedByUserName, OrganisationType.Type, OrganisationType.MachineName);
     }
     catch (Exception ex)
     {
         StackTrace st = new StackTrace();
         StackFrame sf = st.GetFrame(0);
         MethodBase currentMethodName = sf.GetMethod();
         LogDebug(currentMethodName.Name, ex);
         throw ex;
     }
 }
Exemple #24
0
        public async Task <SaveResult> SaveEntity(OrganisationTypeViewModel viewModel)
        {
            SaveResult saveResult = new SaveResult();
            Dictionary <bool, string> dictionary = new Dictionary <bool, string>();


            try
            {
                var entity = new OrganisationType();
                if (viewModel.Id != 0)
                {
                    if (_context.OrganisationType.IgnoreQueryFilters().Any(a => a.Id == viewModel.Id))
                    {
                        entity = await _context.OrganisationType.IgnoreQueryFilters().FirstOrDefaultAsync(a => a.Id == viewModel.Id);
                    }
                    entity = viewModel.ToEntity(entity);
                    _context.OrganisationType.Update(entity);
                }
                else
                {
                    entity = viewModel.ToEntity(entity);
                    _context.OrganisationType.Add(entity);
                }

                await _context.SaveChangesAsync();

                if (entity.Id > 0)
                {
                    saveResult.IsSuccess = true;
                    saveResult.Id        = entity.Id;
                }
            }
            catch (DbUpdateException upDateEx)
            {
                var    results = upDateEx.GetSqlerrorNo();
                string msg     = results == (int)SqlErrNo.FK ? ConstEntity.MissingValueMsg : ConstEntity.UniqueKeyMsg;
                saveResult = dictionary.GetValidateEntityResults(msg).ToSaveResult();
            }
            catch (Exception ex)
            {
                saveResult.Message = CrudError.SaveErrorMsg;
            }


            return(saveResult);
        }
Exemple #25
0
        private async Task CheckSuccessfulCallReturnsExpectedStatus(HttpStatusCode expectedStatusCode)
        {
            const string           registeredId     = "123";
            const OrganisationType organisationType = OrganisationType.Company;

            var organisation = new Organisation
            {
                Type = organisationType,
                Code = registeredId
            };

            var fixtures = new OrganisationControllerTestFixtures()
                           .SetQueryResult(organisation);

            var result = await fixtures.CallGetAsync(registeredId, organisationType);

            Assert.AreEqual(expectedStatusCode, result.StatusCode);
        }
        public async Task <Organisation> GetLatestDetails(OrganisationType organisationType, string identifier)
        {
            var baseUrl = GetBaseUrl();
            var url     = $"{baseUrl}get?identifier={HttpUtility.UrlEncode(identifier)}&organisationType={organisationType}";

            var json = await _httpClient.GetAsync(url, response =>
            {
                switch (response.StatusCode)
                {
                case HttpStatusCode.NotFound: throw new OrganisationNotFoundException(response.ReasonPhrase);

                case HttpStatusCode.BadRequest: throw new InvalidGetOrganisationRequest(response.ReasonPhrase);
                }
                return(true);
            });

            return(JsonConvert.DeserializeObject <Organisation>(json));
        }
        public Organisation GetOrganisationWithDetails(string name, string tradingName, string companyRegistrationNumber, OrganisationType type, OrganisationStatus status)
        {
            Organisation organisation;

            if (type == OrganisationType.RegisteredCompany)
            {
                organisation = Organisation.CreateRegisteredCompany(name, companyRegistrationNumber, tradingName);
            }
            else if (type == OrganisationType.Partnership)
            {
                organisation = Organisation.CreatePartnership(tradingName);
            }
            else
            {
                organisation = Organisation.CreateSoleTrader(tradingName);
            }

            organisation.AddOrUpdateAddress(AddressType.OrganisationAddress, GetAddress());

            organisation.AddOrUpdateMainContactPerson(GetContact());

            if (status == OrganisationStatus.Complete)
            {
                organisation.CompleteRegistration();
            }

            var properties = typeof(Organisation).GetProperties();

            foreach (var propertyInfo in properties)
            {
                if (propertyInfo.Name.Equals("Id", StringComparison.InvariantCultureIgnoreCase))
                {
                    var baseProperty = typeof(Organisation).BaseType.GetProperty(propertyInfo.Name);

                    baseProperty.SetValue(organisation, Guid.NewGuid(), null);

                    break;
                }
            }

            return organisation;
        }
        public void Add(OrganisationType OrganisationType)
        {
            try
            {
                string clientName = DataBase.DBService.ExecuteCommandScalar(string.Format(GET_CLIENT_NAME_QUERY, 0));

                DataBase.DBService.ExecuteCommand(string.Format(INSERT_QUERY,
                                                                OrganisationType.Type,
                                                                OrganisationType.CreatedOn.ToString("yyyy-MM-dd hh:mm:ss"), OrganisationType.CreatedBy,
                                                                OrganisationType.UpdatedOn.ToString("yyyy-MM-dd hh:mm:ss"), OrganisationType.UpdatedBy));

                Activity.ActivitiesService.Add(ActivityType.CreateOrganisationType, EntryStatus.Success,
                                               Source.Server, OrganisationType.UpdatedByUserName, OrganisationType.Type, OrganisationType.MachineName);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                throw ex;
            }
        }
        public async Task PostType_TypeDetailsSelectionWithOrganisationId_RedirectsToCorrectControllerAction(OrganisationType type, string action)
        {
            // Arrange
            OrganisationData orgData = new OrganisationData
            {
                OrganisationType = type,
                Id = Guid.NewGuid()
            };

            IWeeeClient weeeClient = A.Fake<IWeeeClient>();
            A.CallTo(() => weeeClient.SendAsync(A<string>._, A<VerifyOrganisationExistsAndIncomplete>._))
                .Returns(true);
            A.CallTo(() => weeeClient.SendAsync(A<string>._, A<GetOrganisationInfo>._))
                .Returns(orgData);

            ISearcher<OrganisationSearchResult> organisationSearcher = A.Dummy<ISearcher<OrganisationSearchResult>>();

            OrganisationRegistrationController controller = new OrganisationRegistrationController(
                () => weeeClient,
                organisationSearcher);

            OrganisationTypeViewModel model = new OrganisationTypeViewModel(
                type,
                new Guid("35EFE82E-0706-4E80-8AFA-D81C4B58102A"));

            // Act
            ActionResult result = await controller.Type(model);

            // Assert
            var redirectToRouteResult = ((RedirectToRouteResult)result);

            Assert.Equal(action, redirectToRouteResult.RouteValues["action"]);
        }
        private void VerifyOrganisation(string expectedName, string expectedTradingName, string expectedCrn, OrganisationStatus expectedStatus, OrganisationType expectedType, Organisation fromDatabase)
        {
            Assert.NotNull(fromDatabase);

            if (expectedType == OrganisationType.RegisteredCompany)
            {
                Assert.Equal(expectedName, fromDatabase.Name);
            }
            else
            {
                Assert.Equal(expectedTradingName, fromDatabase.TradingName);
            }

            Assert.Equal(expectedCrn, fromDatabase.CompanyRegistrationNumber);
            Assert.Equal(expectedStatus, fromDatabase.OrganisationStatus);
            Assert.Equal(expectedType, fromDatabase.OrganisationType);

            var thisTestOrganisationAddress = fromDatabase.OrganisationAddress;
            Assert.NotNull(thisTestOrganisationAddress);
        }
Exemple #31
0
        public Task <Organisation> GetLatestDetailsAsync(OrganisationType organisationType, string registeredNumber)
        {
            var apiClient = CreateApiClient();

            return(apiClient.GetLatestDetails(organisationType, registeredNumber));
        }
 public bool IsFinancialExempt_ReturnsBool(bool?financialExempt, DateTime?financialDueDate, OrganisationType orgType)
 {
     return(FinancialReviewStatusHelper.IsFinancialExempt(financialExempt, financialDueDate, orgType));
 }
 internal bool IsLegalEntityAlreadyAddedToAccount(List <AccountSpecificLegalEntity> accountLegalEntities, string organisationName, string organisationCode, OrganisationType organisationType)
 {
     if (organisationType == OrganisationType.Charities || organisationType == OrganisationType.CompaniesHouse || organisationType == OrganisationType.PensionsRegulator)
     {
         return(accountLegalEntities.Any(x => x.Code.Equals(organisationCode.Trim(), StringComparison.CurrentCultureIgnoreCase) && x.Source == organisationType));
     }
     else
     {
         return(accountLegalEntities.Any(x => x.Name.Equals(organisationName.Trim(), StringComparison.CurrentCultureIgnoreCase) && x.Source == organisationType));
     }
 }
 public Organisation(int organisation_id, int entity_id, int parent_organisation_id, bool use_parent_offernig_prices, int organisation_type_id, int organisation_customer_type_id, string name, string acn, string abn,
             DateTime organisation_date_added, DateTime organisation_date_modified, bool is_debtor, bool is_creditor,string bpay_account, 
             int weeks_per_service_cycle, DateTime start_date, DateTime end_date, string comment, int free_services,
             bool excl_sun, bool excl_mon, bool excl_tue, bool excl_wed, bool excl_thu, bool excl_fri,
             bool excl_sat, 
             TimeSpan sun_start_time, TimeSpan sun_end_time, TimeSpan mon_start_time, TimeSpan mon_end_time, 
             TimeSpan tue_start_time, TimeSpan tue_end_time, TimeSpan wed_start_time, TimeSpan wed_end_time, 
             TimeSpan thu_start_time, TimeSpan thu_end_time, TimeSpan fri_start_time, TimeSpan fri_end_time, 
             TimeSpan sat_start_time, TimeSpan sat_end_time,
             TimeSpan sun_lunch_start_time, TimeSpan sun_lunch_end_time, TimeSpan mon_lunch_start_time, TimeSpan mon_lunch_end_time,
             TimeSpan tue_lunch_start_time, TimeSpan tue_lunch_end_time, TimeSpan wed_lunch_start_time, TimeSpan wed_lunch_end_time,
             TimeSpan thu_lunch_start_time, TimeSpan thu_lunch_end_time, TimeSpan fri_lunch_start_time, TimeSpan fri_lunch_end_time,
             TimeSpan sat_lunch_start_time, TimeSpan sat_lunch_end_time,
             DateTime last_batch_run, bool is_deleted)
 {
     this.organisation_id = organisation_id;
     this.entity_id = entity_id;
     this.parent_organisation = parent_organisation_id == 0 ? null : new Organisation(parent_organisation_id);
     this.use_parent_offernig_prices = use_parent_offernig_prices;
     this.organisationType = new OrganisationType(organisation_type_id);
     this.organisation_customer_type_id =  organisation_customer_type_id;
     this.name = name;
     this.acn = acn;
     this.abn = abn;
     this.organisation_date_added = organisation_date_added;
     this.organisation_date_modified = organisation_date_modified;
     this.is_debtor = is_debtor;
     this.is_creditor = is_creditor;
     this.bpay_account = bpay_account;
     this.weeks_per_service_cycle = weeks_per_service_cycle;
     this.start_date = start_date;
     this.end_date = end_date;
     this.comment = comment;
     this.free_services = free_services;
     this.excl_sun = excl_sun;
     this.excl_mon = excl_mon;
     this.excl_tue = excl_tue;
     this.excl_wed = excl_wed;
     this.excl_thu = excl_thu;
     this.excl_fri = excl_fri;
     this.excl_sat = excl_sat;
     this.sun_start_time = sun_start_time;
     this.sun_end_time   = sun_end_time;
     this.mon_start_time = mon_start_time;
     this.mon_end_time   = mon_end_time;
     this.tue_start_time = tue_start_time;
     this.tue_end_time   = tue_end_time;
     this.wed_start_time = wed_start_time;
     this.wed_end_time   = wed_end_time;
     this.thu_start_time = thu_start_time;
     this.thu_end_time   = thu_end_time;
     this.fri_start_time = fri_start_time;
     this.fri_end_time   = fri_end_time;
     this.sat_start_time = sat_start_time;
     this.sat_end_time   = sat_end_time;
     this.sun_lunch_start_time = sun_lunch_start_time;
     this.sun_lunch_end_time   = sun_lunch_end_time;
     this.mon_lunch_start_time = mon_lunch_start_time;
     this.mon_lunch_end_time   = mon_lunch_end_time;
     this.tue_lunch_start_time = tue_lunch_start_time;
     this.tue_lunch_end_time   = tue_lunch_end_time;
     this.wed_lunch_start_time = wed_lunch_start_time;
     this.wed_lunch_end_time   = wed_lunch_end_time;
     this.thu_lunch_start_time = thu_lunch_start_time;
     this.thu_lunch_end_time   = thu_lunch_end_time;
     this.fri_lunch_start_time = fri_lunch_start_time;
     this.fri_lunch_end_time   = fri_lunch_end_time;
     this.sat_lunch_start_time = sat_lunch_start_time;
     this.sat_lunch_end_time   = sat_lunch_end_time;
     this.last_batch_run = last_batch_run;
     this.is_deleted = is_deleted;
 }
Exemple #35
0
        public Organisation GetOrganisationWithDetails(string name, string tradingName, string companyRegistrationNumber, OrganisationType type, OrganisationStatus status)
        {
            Organisation organisation;

            if (type == OrganisationType.RegisteredCompany)
            {
                organisation = Organisation.CreateRegisteredCompany(name, companyRegistrationNumber, tradingName);
            }
            else if (type == OrganisationType.Partnership)
            {
                organisation = Organisation.CreatePartnership(tradingName);
            }
            else
            {
                organisation = Organisation.CreateSoleTrader(name, tradingName);
            }

            if (status == OrganisationStatus.Complete)
            {
                organisation.CompleteRegistration();
            }

            organisation.AddOrUpdateAddress(AddressType.RegisteredOrPPBAddress, GetAddress());

            var properties = typeof(Organisation).GetProperties();

            foreach (var propertyInfo in properties)
            {
                if (propertyInfo.Name.Equals("Id", StringComparison.InvariantCultureIgnoreCase))
                {
                    var baseProperty = typeof(Organisation).BaseType.GetProperty(propertyInfo.Name);

                    baseProperty.SetValue(organisation, Guid.NewGuid(), null);

                    break;
                }
            }

            return(organisation);
        }
		///////////////////////////////////////////////////////////////////////////////////////////////////
		////////////BUILD FROM V2 SCHEMA				 //////////////////////////////////////////////////
		///////////////////////////////////////////////////////////////////////////////////////////////////
		public AgencyCore(OrganisationType bean, IAgencyScheme parent) : base(bean, Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureType.GetFromEnum(SdmxStructureEnumType.AGENCY), bean.Id, bean.Uri, bean.NameList, bean.DescriptionList, bean.Annotations, parent) {
		}