public async Task <List <MLFSClient> > GetClients(string idString)
        {
            idString = HttpUtility.UrlEncode(idString);
            string        url      = String.Format("clients?filter=id in {0}", idString);
            IRestResponse response = await IOConnection.GetResponse(url);

            if (response.Content.Length != 0 && response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                JToken token   = JToken.Parse(response.Content);
                JArray clients = Tools.ExtractItemsArrayFromJsonString(response.Content);
                if (clients.Count > 0)
                {
                    List <MLFSClient> clientList = MLFSClient.CreateList(clients);
                    return(clientList);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public void BuildAClientWithJustAnId()
        {
            //arrange
            string jsonRespoonse = "30944834";

            //act
            MLFSClient client = new MLFSClient(jsonRespoonse);

            //assert
            Assert.AreEqual(jsonRespoonse, client.PrimaryID);
        }
Ejemplo n.º 3
0
        public void UpdateFromIOTest()
        {
            //arrage
            List <MLFSIncome> income = new List <MLFSIncome>();
            MLFSIncome        i      = new MLFSIncome()
            {
                Id                = 1,
                IOReference       = "123456",
                ReportingPeriodId = 2,
                RelevantDate      = DateTime.Now,
                ClientId          = "234",
                Amount            = 100,
                PlanNumber        = "9876"
            };

            income.Add(i);
            MLFSIncome i2 = new MLFSIncome()
            {
                Id                = 2,
                IOReference       = "1234567",
                ReportingPeriodId = 2,
                RelevantDate      = DateTime.Now,
                ClientId          = "345",
                Amount            = 100,
                PlanNumber        = "9877"
            };

            income.Add(i2);
            List <MLFSClient> clients = new List <MLFSClient>();
            MLFSClient        c       = new MLFSClient()
            {
                PrimaryID = "234",
                Name      = "John Smith",
                IsActive  = true,
                CreatedOn = DateTime.Parse("01/01/2001")
            };
            MLFSClient c2 = new MLFSClient()
            {
                PrimaryID = "231",
                Name      = "John Adams",
                IsActive  = false,
                CreatedOn = DateTime.Parse("10/01/2001")
            };

            clients.Add(c);
            clients.Add(c2);


            //act
            MLFSIncome.UpdateFromIO(income, clients);

            //assert
            Assert.AreEqual(DateTime.Parse("01/01/2001"), i.ClientOnBoardDate, "On board date not updated");
        }
        public async Task <List <MLFSClient> > GetClients(string[] clientIds)
        {
            List <MLFSClient> clients = new List <MLFSClient>();

            foreach (string id in clientIds)
            {
                MLFSClient client = await _clientRepository.GetClient(id);

                clients.Add(client);
            }
            return(clients);
        }
Ejemplo n.º 5
0
        public void CreateListTest()
        {
            string            jsonString = "[{\"id\":25575177,\"href\":\"https://api.intelliflo.com/v2/clients/25575177\",\"name\":\"Marion Beck\",\"createdAt\":\"2019-02-27T15:14:46Z\",\"category\":\"Retail\",\"externalReference\":\"7690372-25575177\",\"secondaryReference\":\"BE424\",\"originalAdviser\":{\"id\":27066,\"name\":\"Garry Dornan\",\"href\":\"https://api.intelliflo.com/v2/advisers/27066\"},\"currentAdviser\":{\"id\":27066,\"name\":\"Garry Dornan\",\"href\":\"https://api.intelliflo.com/v2/advisers/27066\"},\"type\":\"Client\",\"partyType\":\"Person\",\"person\":{\"title\":\"Mrs\",\"firstName\":\"Marion\",\"middleName\":\"Elaine\",\"lastName\":\"Beck\",\"dateOfBirth\":\"1964-04-15\",\"gender\":\"Female\",\"niNumber\":\"NE103320B\",\"isDeceased\":false},\"addresses_href\":\"https://api.intelliflo.com/v2/clients/25575177/addresses\",\"contactdetails_href\":\"https://api.intelliflo.com/v2/clients/25575177/contactdetails\",\"plans_href\":\"https://api.intelliflo.com/v2/clients/25575177/plans\",\"relationships_href\":\"https://api.intelliflo.com/v2/clients/25575177/relationships\",\"servicecases_href\":\"https://api.intelliflo.com/v2/clients/25575177/servicecases\",\"dependants_href\":\"https://api.intelliflo.com/v2/clients/25575177/dependants\",\"isHeadOfFamilyGroup\":false,\"servicingAdministrator\":{\"id\":52724,\"href\":\"https://api.intelliflo.com/v2/users/52724\"},\"tags\":[]},{\"id\":25584235,\"href\":\"https://api.intelliflo.com/v2/clients/25584235\",\"name\":\"Graham Allen\",\"createdAt\":\"2019-03-04T11:47:34Z\",\"category\":\"Retail\",\"externalReference\":\"7690381-25584235\",\"secondaryReference\":\"AL279\",\"originalAdviser\":{\"id\":27075,\"name\":\"Dana Mackie\",\"href\":\"https://api.intelliflo.com/v2/advisers/27075\"},\"currentAdviser\":{\"id\":27075,\"name\":\"Dana Mackie\",\"href\":\"https://api.intelliflo.com/v2/advisers/27075\"},\"type\":\"Client\",\"partyType\":\"Person\",\"person\":{\"salutation\":\"\",\"title\":\"Mr\",\"firstName\":\"Graham\",\"middleName\":\"John\",\"lastName\":\"Allen\",\"dateOfBirth\":\"1967-03-24\",\"gender\":\"Male\",\"maidenName\":\"\",\"niNumber\":\"NM975566D\",\"isDeceased\":false,\"territorialProfile\":{\"ukResident\":false},\"healthProfile\":{\"isSmoker\":\"No\"},\"isPowerOfAttorneyGranted\":false,\"nationalClientIdentifier\":\"\"},\"addresses_href\":\"https://api.intelliflo.com/v2/clients/25584235/addresses\",\"contactdetails_href\":\"https://api.intelliflo.com/v2/clients/25584235/contactdetails\",\"plans_href\":\"https://api.intelliflo.com/v2/clients/25584235/plans\",\"relationships_href\":\"https://api.intelliflo.com/v2/clients/25584235/relationships\",\"servicecases_href\":\"https://api.intelliflo.com/v2/clients/25584235/servicecases\",\"dependants_href\":\"https://api.intelliflo.com/v2/clients/25584235/dependants\",\"isHeadOfFamilyGroup\":false,\"servicingAdministrator\":{\"id\":52733,\"href\":\"https://api.intelliflo.com/v2/users/52733\"},\"tags\":[]}]";
            JArray            _array     = JArray.Parse(jsonString);
            List <MLFSClient> clients    = new List <MLFSClient>();

            //act
            clients = MLFSClient.CreateList(_array);

            //assert
            Assert.AreEqual(2, clients.Count);
        }
Ejemplo n.º 6
0
        public void BuildMLFSClientFromJsonString()
        {
            //arrange
            string  jsonResponse = "{\"id\":30944834,\"href\":\"https://api.intelliflo.com/v2/clients/30944834\",\"name\":\"John Smith\",\"createdAt\":\"2020-06-24T11:29:34Z\",\"category\":\"Retail\",\"externalReference\":\"30929016-30944834\",\"secondaryReference\":\"\",\"originalAdviser\":{\"id\":91653,\"name\":\"A rowe.sy\",\"href\":\"https://api.intelliflo.com/v2/advisers/91653\"},\"currentAdviser\":{\"id\":91653,\"name\":\"A rowe.sy\",\"href\":\"https://api.intelliflo.com/v2/advisers/91653\"},\"type\":\"Client\",\"partyType\":\"Person\",\"person\":{\"title\":\"Mr\",\"firstName\":\"John\",\"middleName\":\"Arthur\",\"lastName\":\"Smith\",\"dateOfBirth\":\"1978-01-01\",\"gender\":\"Male\",\"niNumber\":\"\",\"isDeceased\":false},\"addresses_href\":\"https://api.intelliflo.com/v2/clients/30944834/addresses\",\"contactdetails_href\":\"https://api.intelliflo.com/v2/clients/30944834/contactdetails\",\"plans_href\":\"https://api.intelliflo.com/v2/clients/30944834/plans\",\"relationships_href\":\"https://api.intelliflo.com/v2/clients/30944834/relationships\",\"servicecases_href\":\"https://api.intelliflo.com/v2/clients/30944834/servicecases\",\"dependants_href\":\"https://api.intelliflo.com/v2/clients/30944834/dependants\",\"tags\":[]}";
            JObject obj          = JObject.Parse(jsonResponse);

            //act
            MLFSClient client = new MLFSClient(obj);

            //assert
            Assert.AreEqual("John Smith", client.Name);
        }
Ejemplo n.º 7
0
        public void CreateSummaryListTest()
        {
            //arrange
            string            jsonString = "[{\"id\":30945926,\"href\":\"https://api.intelliflo.com/v2/clients/30945926\"},{\"id\":30944834,\"href\":\"https://api.intelliflo.com/v2/clients/30944834\"}]";
            JArray            _array     = JArray.Parse(jsonString);
            List <MLFSClient> clients    = new List <MLFSClient>();

            //act
            clients = MLFSClient.CreateSummaryList(_array);

            //assert
            Assert.AreEqual(2, clients.Count);
        }
        private static async Task <JArray> GetRelated(MLFSClient client)
        {
            string        url      = String.Format("clients/{0}/{1}", client.PrimaryID, "relationships");
            IRestResponse response = await IOConnection.GetResponse(url);

            if (response.Content.Length != 0)
            {
                JArray _array = Tools.ExtractItemsArrayFromJsonString(response.Content);
                return(_array);
            }
            else
            {
                return(null);
            }
        }
        private static async Task <MLFSClient> GetBasicClientData(string id)
        {
            string        url      = String.Format("clients/{0}", id);
            IRestResponse response = await IOConnection.GetResponse(url);

            if (response.Content.Length != 0)
            {
                JToken     token  = JToken.Parse(response.Content);
                MLFSClient client = new MLFSClient(token);
                return(client);
            }
            else
            {
                return(null);
            }
        }
        public async Task <IActionResult> UpdateData(int?periodId, int?saleId = null)
        {
            List <MLFSSale> sales = new List <MLFSSale>();

            if (saleId == null)
            {
                if (periodId == null)
                {
                    return(NotFound());
                }
                MLFSReportingPeriod period = await _periodData.GetPeriodById((int)periodId);

                if (period == null)
                {
                    return(NotFound());
                }
                sales = await _salesData.GetSales(period);
            }
            else
            {
                MLFSSale soleSale = await _salesData.GetSaleById((int)saleId);

                sales.Add(soleSale);
            }
            for (int i = 0; i < sales.Count; i++)
            {
                MLFSSale sale = sales[i];
                //only interested in clients which haven't been updated already or where we are forcing a particular line
                //if (saleId != null || (sale.EstimatedOtherIncome == 0))
                //{
                Console.WriteLine("Client: " + sale.ClientId + ":" + sale.Client + ":" + i.ToString());
                MLFSClient client = await _clientData.GetClient(sale.ClientId);

                List <MLFSIncome> income = await _incomeData.GetIncome(client);

                sale.AddClientData(client, income);
                _salesData.Update(sale);
                //}
            }

            return(Ok());
        }
        private static async void GetAdditionalData(MLFSClient client, string endpoint)
        {
            string        url      = String.Format("clients/{0}/{1}", client.PrimaryID, endpoint);
            IRestResponse response = await IOConnection.GetResponse(url);

            if (response.Content.Length != 0)
            {
                JArray              _array    = Tools.ExtractItemsArrayFromJsonString(response.Content);
                List <Address>      addresses = new List <Address>();
                List <Number>       numbers   = new List <Number>();
                List <EmailAddress> emails    = new List <EmailAddress>();
                if (endpoint == "addressess")
                {
                    addresses = Address.CreateList(_array);
                }
                if (endpoint == "contactdetails")
                {
                    JArray jarray = Tools.SplitContactDetails(_array);
                    numbers = Number.CreateList(jarray);
                    jarray  = Tools.SplitContactDetails(_array, true);
                    emails  = EmailAddress.CreateList(jarray);
                }
                if (client.IsIndividual)
                {
                    client.Person.Addresses      = addresses;
                    client.Person.EmailAddresses = emails;
                    client.Person.Numbers        = numbers;
                }
                else
                {
                    if (client.Organisation == null)
                    {
                        client.Organisation = new Organisation();
                    }
                    client.Organisation.Addresses = addresses;
                    client.Organisation.Numbers   = numbers;
                }
            }
        }
 public async Task <List <MLFSIncome> > GetIncome(MLFSClient client)
 {
     return(await _db.MLFSIncome.Where(x => x.ClientId == client.PrimaryID || x.JointClientId == client.PrimaryID).ToListAsync());
 }
        public async Task <MLFSClient> GetClient(string clientId)
        {
            MLFSClient client = await _clientRepository.GetClient(clientId);

            return(client);
        }
        public async Task <MLFSClient> GetClient(string id)
        {
            //Build the client
            MLFSClient client = await GetBasicClientData(id);

            //then get the plans
            List <MLFSPlan> plans = await GetClientPlans(id);

            if (plans != null)
            {
                client.Plans.AddRange(plans);
            }
            //for each plan get the other owners but only basic data
            foreach (MLFSPlan plan in client.Plans)
            {
                if (plan.ContributionsToDate == 0)
                {
                    plan.ContributionsToDate = await GetContributionTotal(plan);
                }
                for (int i = 0; i < plan.Clients.Count; i++)
                {
                    if (plan.Clients[i].PrimaryID != client.PrimaryID)
                    {
                        plan.Clients[i] = await GetBasicClientData(plan.Clients[i].PrimaryID);
                    }
                }
            }
            //get addresses
            GetAdditionalData(client, "addresses");
            GetAdditionalData(client, "contactdetails");
            List <MLFSFee> fees = await GetClientFees(client.PrimaryID);

            if (fees != null)
            {
                client.Fees.AddRange(fees);
            }
            JArray relatedClients = await GetRelated(client);

            if (relatedClients != null)
            {
                foreach (JObject obj in relatedClients)
                {
                    dynamic c = obj;
                    string  relId;
                    if (c.relation != null)
                    {
                        relId = c.relation.id;

                        fees = await GetClientFees(relId);

                        if (fees != null)
                        {
                            client.Fees.AddRange(fees);
                        }
                        plans = await GetClientPlans(relId);

                        if (plans != null)
                        {
                            client.Plans.AddRange(plans);
                        }
                        client.RelatedClients.Add(relId);
                    }
                }
            }
            return(client);
        }
Ejemplo n.º 15
0
        public void AddClientDataTest()
        {
            //arrange
            MLFSSale sale = new MLFSSale()
            {
                Id            = 1,
                ClientId      = "IOB123",
                ClientName    = "John",
                NetAmount     = 100,
                VAT           = 20,
                PlanReference = "IOP123"
            };
            MLFSClient client = new MLFSClient()
            {
                Name      = "John",
                PrimaryID = "IOB123",
                CreatedOn = DateTime.Now.AddYears(-1)
            };

            client.Plans.Add(new MLFSPlan()
            {
                PrimaryID           = "IOP123",
                Provider            = "XYZ Limited",
                ContributionsToDate = 10000,
                CurrentValuation    = 11000,
                IsPreExistingClient = true
            });
            client.Fees.Add(new MLFSFee()
            {
                PrimaryID     = "IOF123",
                FeePercentage = (decimal)0.1,
                IsRecurring   = true,
                Plan          = client.Plans.FirstOrDefault()
            });
            client.Plans.Add(new MLFSPlan()
            {
                PrimaryID           = "IOP987",
                Provider            = "XYZ Limited",
                ContributionsToDate = 200000,
                CurrentValuation    = 220000
            });
            client.Fees.Add(new MLFSFee()
            {
                PrimaryID     = "IOF987",
                FeePercentage = (decimal)0.1,
                IsRecurring   = true,
                Plan          = new MLFSPlan()
                {
                    PrimaryID           = "IOP987",
                    Provider            = "XYZ Limited",
                    ContributionsToDate = 200000,
                    CurrentValuation    = 220000
                }
            });
            List <MLFSIncome> income = new List <MLFSIncome>();

            //to do test income handling

            //act
            sale.AddClientData(client, income);

            //assert
            Assert.AreEqual("XYZ Limited", sale.ProviderName, "Provider name not updated");
            Assert.AreEqual(false, sale.IsNew, "IsNew not set correctly");
            Assert.AreEqual(11000, sale.Investment, "Investment incorrect");
            Assert.AreEqual((decimal)0.1, sale.OnGoingPercentage, "Percentage incorrect");
            Assert.AreEqual((decimal)22000, sale.EstimatedOtherIncome, "Other income not calculated correctly");
        }