Exemplo n.º 1
0
        public void FillMandate_ShouldMatchMandates_WhenInstrumentCodeMatches()
        {
            //Arrange
            PortfolioVM portfolioVM = new PortfolioVM();

            portfolioVM.Positions.Add(new PositionVM()
            {
                Code = "NL0000287100", Name = "Optimix Mix Fund", Value = 23456
            });
            List <MandateVM> expectedListOfMandates = new List <MandateVM>()
            {
                new MandateVM()
                {
                    Name = "Robeco Factor Momentum Mandaat", Allocation = (decimal)0.355, Value = 8327
                },
                new MandateVM()
                {
                    Name = "BNPP Factor Value Mandaat", Allocation = (decimal)0.383, Value = 8984
                },
                new MandateVM()
                {
                    Name = "Robeco Factor Quality Mandaat", Allocation = (decimal)0.261, Value = 6122
                },
                new MandateVM()
                {
                    Name = "Liquidity", Allocation = (decimal)0.001, Value = 23
                },
            };
            FundsOfMandatesData fundsOfMandatesData = portfolioServices.GetFundOfMandates(path);

            //Act
            List <MandateVM> actualListOfMandates = portfolioServices.FillMandate(portfolioVM, fundsOfMandatesData).Positions[0].Mandates;
            MandateVM        actualMandateVM      = actualListOfMandates.Where(x => x.Name == "Robeco Factor Momentum Mandaat").FirstOrDefault();

            //Assert
            actualListOfMandates.Should().BeEquivalentTo(expectedListOfMandates);
            actualMandateVM.Should().BeEquivalentTo(new MandateVM()
            {
                Name = "Robeco Factor Momentum Mandaat", Allocation = (decimal)0.355, Value = 8327
            });
        }
Exemplo n.º 2
0
        public virtual async System.Threading.Tasks.Task <ActionResult> PdfTest(int id)
        {
            List <KeyValuePair <RessourceVM, string> > listWS = new List <KeyValuePair <RessourceVM, string> >();



            HttpClient Client = new HttpClient();

            Client.BaseAddress = new Uri("http://localhost:18080/l4c_map-v2-web/");
            Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage response = await Client.GetAsync("rest/efficiencies?id=" + id);

            string data = await response.Content.ReadAsStringAsync();

            JavaScriptSerializer JSserializer = new JavaScriptSerializer();

            listWS            = ListToDictionary(JSserializer.Deserialize <List <List <Object> > >(data));
            ViewBag.rate      = listWS[0].Value;
            ViewBag.Ressource = listWS[0].Key;
            List <MandateVM> l = new List <MandateVM>();

            foreach (mandate s in ms.getMandates(id))
            {
                ProjectVM p = new ProjectVM {
                    name = ps.getProject(s.idProject).name, adresse = ps.getProject(s.idProject).adresse
                };
                MandateVM m = new MandateVM {
                    dateBegin = s.dateBegin.ToString(), dateEnd = s.dateEnd.ToString(), project = p
                };
                l.Add(m);
            }

            ViewBag.mandates = l;

            ViewBag.test = id;


            return(Pdf(new int[] { 1, 2, 3 }));
        }
Exemplo n.º 3
0
        public ActionResult Create(MandateVM m)
        {
            ResourceDropList();
            ProjectDropList();
            string pId = Request.Form["Project"].ToString();
            string rId = Request.Form["Resource"].ToString();


            var client  = new RestClient("http://localhost:18080/map-web/rest/");
            var request = new RestRequest(Method.POST);

            client.AddHandler("application/json", new JsonDeserializer());
            request.RequestFormat = DataFormat.Json;
            request.Resource      = "mandates";
            var obj = new
            {
                startDate = "2015-11-30",
                endDate   = "2018-12-30",
                mandatepk = new
                {
                    projectId  = Int32.Parse(pId),
                    resourceId = Int32.Parse(rId)
                }
            };

            request.AddJsonBody(obj);
            request.AddHeader("Authorization", "Bearer " + Session["token"]);
            request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };
            var response = client.Execute(request);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(RedirectToAction("Create", "Mandate"));
            }
        }
        /// <summary>
        /// THIS METHOD IS USED TO UPDATE POSITION VIEWMODEL TO MAP CORRESPONDING MANDATES WITH IT PRESENT UNDER PASSED FUNDOFMANDATE.
        /// METHOD USE POSITION VIEW MODEL AND FUNDOFMANDATE OBJECTS AND RETURN UPDATED POSITIONVM BACK TO CLIENT.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="fundOfmandates"></param>
        /// <returns></returns>
        public PositionVM GetCalculatedMandates(PositionVM position, FundOfMandates fundOfmandates)
        {
            if (position.Code == fundOfmandates.InstrumentCode && fundOfmandates.Mandates != null && fundOfmandates.Mandates.Length > 0)
            {
                position.Mandates = new List <MandateVM>();
                position.Mandates.AddRange
                (
                    fundOfmandates.Mandates.ToList().Select(x => new MandateVM
                {
                    name       = x.MandateName,
                    Value      = Math.Round((position.Value * x.Allocation) / 100),
                    Allocation = x.Allocation / 100
                })
                );

                if (fundOfmandates.LiquidityAllocation > 0)
                {
                    var newMandate = new MandateVM
                    {
                        name = "Liquidity",
                        //NOT VERY CLEAR OF THE LOGIC MENTIONED IN THE WORD DOC SHARED WITH EXERCISE. IT SAYS SUBSTRACT FROM POSITION VALUE BUT THE EXAMPLE IN THE DOC SHOWS THAT ITS STRAIGHT POSITION.VALUE * LIQUIDITY ALLOCATION.
                        //SO COMENTING THE BELOW LINE OF CODE AND KEEPING IT SIMPLE BASED ON EXAMPLE
                        //Value = (position.Value - ((position.Value * fundOfmandates.LiquidityAllocation) / 100)),
                        Value      = Math.Round((position.Value * fundOfmandates.LiquidityAllocation) / 100),
                        Allocation = fundOfmandates.LiquidityAllocation / 100
                    };

                    position.Mandates.Add(newMandate);
                }
            }
            else
            {
                //Maybe we can Log something here as needed..
            }

            return(position);
        }