コード例 #1
0
        public async Task <int> Add(MLFSSale sale)
        {
            _db.MLFSSales.Add(sale);
            await _db.SaveChangesAsync();

            return(sale.Id);
        }
コード例 #2
0
        public void CreateNTUTest()
        {
            //arrange
            MLFSSale sale = new MLFSSale()
            {
                Id = 1,
                ReportingPeriodId = 6,
                Investment        = 100,
                NetAmount         = 4,
                OnGoingPercentage = (decimal)0.005,
                RelevantDate      = DateTime.Parse("01/02/2020")
            };
            MLFSReportingPeriod period = new MLFSReportingPeriod(5, 2020)
            {
                Id = 2
            };

            //act
            MLFSDebtorAdjustment adj = sale.CreateNTU(period);

            //assert
            Assert.AreEqual(-4, adj.Amount, "Amount is not the inverse of the debtor");
            Assert.AreEqual(2, adj.ReportingPeriodId, "Correct reporting period not given.");
            Assert.AreEqual(true, adj.NotTakenUp, "Not reporting as an NTU adjustment");
        }
コード例 #3
0
        // GET: MLFSDebtorAdjustments/Create
        public async Task <IActionResult> CreateAdjustment(int debtorId)
        {
            MLFSDebtorAdjustment adj    = new MLFSDebtorAdjustment();
            MLFSSale             debtor = await _salesData.GetSaleById(debtorId);

            adj.DebtorId              = debtorId;
            adj.Amount                = debtor.Outstanding * -1;
            adj.IsVariance            = false;
            adj.NotTakenUp            = false;
            ViewBag.ReportingPeriodId = await _periodData.SelectList();

            return(PartialView("Create", adj));
        }
コード例 #4
0
        public async Task <IActionResult> CheckForMatches()
        {
            MLFSReportingPeriod period = await _periodData.GetCurrent();

            List <MLFSSale> debtors = await _debtorData.GetDebtors(period);

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

            income = income.Where(x => x.MLFSDebtorAdjustment == null && x.IncomeType.Contains("Initial")).ToList();
            List <MLFSDebtorAdjustment> adjs = MLFSSale.CheckForReceipts(debtors, income);

            _adjustmentData.InsertList(adjs);
            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public async Task <string> CreateEntities(List <MLFSAdvisor> advisors)
        {
            string response = "failure";

            DataTable salesTable      = new DataTable();
            DataTable incomeTable     = new DataTable();
            DataTable planTable       = new DataTable();
            DataTable commissionTable = new DataTable();

            foreach (IFormFile file in Files)
            {
                if (file.Length > 0)
                {
                    string newFilePath = Path.GetTempFileName();
                    using (var fileStream = new FileStream(newFilePath, FileMode.Create))
                    {
                        await file.CopyToAsync(fileStream);
                    }
                    if (file.FileName.Contains("MLFS Fees"))
                    {
                        salesTable = Tools.ConvertCSVToDataTable(newFilePath);
                    }
                    else if (file.FileName.Contains("Plans"))
                    {
                        planTable = Tools.ConvertCSVToDataTable(newFilePath);
                    }
                    else if (file.FileName.Contains("AdviserMonthlyFCI"))
                    {
                        incomeTable = Tools.ConvertCSVToDataTable(newFilePath);
                    }
                    else if (file.FileName.Contains("Commission"))
                    {
                        commissionTable = Tools.ConvertCSVToDataTable(newFilePath);
                    }
                    else
                    {
                        return(response);
                    }
                }
                else
                {
                    return(response);
                }
            }
            Sales    = MLFSSale.ConvertFromDataTable(salesTable, planTable, commissionTable, advisors, ReportingPeriod);
            Income   = MLFSIncome.CreateFromDataTable(incomeTable, advisors, ReportingPeriod);
            response = "Success";
            return(response);
        }
コード例 #6
0
        public async Task <IActionResult> CreateFromIncome(int incomeId)
        {
            MLFSIncome income = await _incomeData.GetIncomeById(incomeId);

            if (income.MLFSDebtorAdjustment != null)
            {
                return(NotFound());
            }
            MLFSSale             sale = new MLFSSale(income);
            MLFSDebtorAdjustment adj  = new MLFSDebtorAdjustment(sale, income);
            await _salesData.Add(sale);

            _adjData.Insert(adj);
            return(Ok());
        }
コード例 #7
0
        /// <summary>
        /// Displays a list of unmatched new business income.  If a debtor is supplied it will allow matching.  If a period is provided it will limit the list
        /// </summary>
        /// <param name="debtorId">the Id of the debtor we are trying to match</param>
        /// <returns>Partial view</returns>
        public async Task <IActionResult> Unmatched(int?debtorId, int?periodId = null)
        {
            List <MLFSIncome> income = await _incomeData.GetUnMatchedIncome();

            if (debtorId != null)
            {
                MLFSSale debtor = await _salesData.GetSaleById((int)debtorId);

                ViewBag.Debtor = debtor;
            }
            if (periodId != null)
            {
                income = income.Where(x => x.ReportingPeriodId == periodId).ToList();
            }
            return(PartialView("_SelectIndex", income));
        }
コード例 #8
0
        public async Task <JsonResult> ClearVAT(int?debtorId)
        {
            if (debtorId == null)
            {
                return(Json("Failed"));
            }
            MLFSSale debtor = await _salesData.GetSaleById((int)debtorId);

            if (debtor == null)
            {
                return(Json("Failed"));
            }
            debtor.VAT = 0;
            _salesData.Update(debtor);
            return(Json("Success"));
        }
コード例 #9
0
        /// <summary>
        /// Displays a list of potential matches for a debtor
        /// </summary>
        /// <param name="debtorId">the Id of the debtor we are trying to match</param>
        /// <returns>Partial view</returns>
        public async Task <IActionResult> PotentialDebtorMatches(int?debtorId)
        {
            if (debtorId == null)
            {
                return(NotFound());
            }
            MLFSSale debtor = await _salesData.GetSaleById((int)debtorId);

            if (debtor == null)
            {
                return(NotFound());
            }
            List <MLFSIncome> matches = await _incomeData.PotentialDebtorMatches(debtor);

            ViewBag.Debtor = debtor;
            return(PartialView("_SelectIndex", matches));
        }
コード例 #10
0
        public async Task <IActionResult> IncomeOnly(Upload upload)
        {
            if (upload.ReportingPeriodId == null)
            {
                return(NotFound());
            }
            MLFSReportingPeriod period = await _periodData.GetPeriodById((int)upload.ReportingPeriodId);

            if (period == null)
            {
                return(NotFound());
            }
            upload.ReportingPeriod   = period;
            upload.ReportingPeriodId = period.Id;
            if (upload.Files == null || upload.Files.Count != 4)
            {
                return(NotFound());
            }
            List <MLFSAdvisor> advisors = await _advisorData.GetAdvisors();

            DataTable incomeTable = new DataTable();

            foreach (IFormFile file in upload.Files)
            {
                if (file.Length > 0)
                {
                    string newFilePath = Path.GetTempFileName();
                    using (var fileStream = new FileStream(newFilePath, FileMode.Create))
                    {
                        await file.CopyToAsync(fileStream);
                    }
                    if (file.FileName.Contains("AdviserMonthlyFCI"))
                    {
                        incomeTable = Tools.ConvertCSVToDataTable(newFilePath);
                    }
                }
            }
            upload.Income = MLFSIncome.CreateFromDataTable(incomeTable, advisors, period);
            await _incomeData.InsertList(upload.Income);

            List <MLFSDebtorAdjustment> adjs = MLFSSale.CheckForReceipts(upload.Sales, upload.Income);

            _adjustmentData.InsertList(adjs);
            ViewBag.Result = "Uploaded Successfully";
            return(RedirectToAction("Index"));
        }
コード例 #11
0
 public DirectorsReport(MLFSSale sale)
 {
     SaleId = sale.Id;
     if (sale.Advisor != null)
     {
         Advisor = sale.Advisor.Fullname;
     }
     else
     {
         Advisor = "Unknown";
     }
     ClientName        = sale.ClientName;
     ClientId          = sale.ClientId;
     JointClientId     = sale.JointClientId;
     PlanId            = sale.PlanReference;
     ReportingPeriodId = (int)sale.ReportingPeriodId;
     Provider          = sale.ProviderName;
     if (sale.IsNew)
     {
         NewExisting = "New";
     }
     else
     {
         NewExisting = "Existing";
     }
     InitialFee        = sale.NetAmount;
     Investment        = sale.Investment;
     OngoingPercentage = sale.OnGoingPercentage;
     if (sale.TwelveMonthTrail == 0)
     {
         if (Investment != 0 && sale.OnGoingPercentage != 0)
         {
             TwelveMonthsTrail = Investment * sale.OnGoingPercentage / 100;
         }
         else
         {
             TwelveMonthsTrail = 0;
         }
     }
     else
     {
         TwelveMonthsTrail = sale.TwelveMonthTrail;
     }
     OtherIncome    = sale.EstimatedOtherIncome;
     RelatedClients = sale.RelatedClients;
 }
コード例 #12
0
        public void FeeCheckTests()
        {
            //arrange
            MLFSSale sale = new MLFSSale()
            {
                Id                = 1,
                Investment        = 100,
                NetAmount         = 4,
                OnGoingPercentage = (decimal)0.005
            };

            //act
            //Nothing to do

            //assert
            Assert.AreEqual(true, sale.InitialFeePass, "Initial Fee checked passed correctly");
            Assert.AreEqual(false, sale.OngoingFeePass, "Ogoing Fee check failed correctly");
        }
コード例 #13
0
        public void AddPlanDataTest()
        {
            //arrange
            MLFSReportingPeriod period = new MLFSReportingPeriod(1, 2020)
            {
                Id = 2
            };
            MLFSSale sale = new MLFSSale()
            {
                Id                = 1,
                Investment        = 100,
                ReportingPeriodId = period.Id,
                ReportingPeriod   = period,
                NetAmount         = 4,
                OnGoingPercentage = (decimal)0.005,
                RelevantDate      = DateTime.Parse("01/02/2020")
            };
            DataTable table = new DataTable();

            table.Columns.Add("Id", typeof(int));
            table.Columns.Add("Provider.Name", typeof(string));
            table.Columns.Add("Owner 1.Creation Date", typeof(string));
            table.Columns.Add("Total Premiums to Date", typeof(string));
            table.Columns.Add("On-going Fee Percentage", typeof(string));
            table.Columns.Add("Selling Adviser.Group.Name", typeof(string));

            DataRow row = table.NewRow();

            row["Id"]                         = "123465";
            row["Provider.Name"]              = "Elevate";
            row["Owner 1.Creation Date"]      = "01/01/2020";
            row["Total Premiums to Date"]     = "10000";
            row["On-going Fee Percentage"]    = "0.01";
            row["Selling Adviser.Group.Name"] = "Milsted Langdon Financial Services";
            table.Rows.Add(row);

            //act
            sale.AddPlanData(row);

            //assert
            Assert.AreEqual(true, sale.IsNew, "Client is not reporting as new");
            Assert.AreEqual((decimal)10000, sale.Investment, "Investment not updated");
        }
コード例 #14
0
        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());
        }
コード例 #15
0
        public async Task <IActionResult> NotTakenUp(int?debtorId)
        {
            if (debtorId == null)
            {
                return(NotFound());
            }

            MLFSSale mLFSSale = await _salesData.GetSaleById((int)debtorId);

            if (mLFSSale == null)
            {
                return(NotFound());
            }
            MLFSReportingPeriod period = await _periodData.GetCurrent();

            MLFSDebtorAdjustment adj = mLFSSale.CreateNTU(period);

            _adjustmentData.Insert(adj);
            return(RedirectToAction("Index", "Debtor"));
        }
コード例 #16
0
        public async Task <IActionResult> Create(MLFSSale sale)
        {
            sale.Advisor = await _advisorData.GetAdvisor(sale.AdvisorId);

            sale.Organisation = sale.Advisor.Department;
            sale.IOId         = sale.IOReference.Substring(2);
            int newId = await _salesData.Add(sale);

            if (sale.ReportingPeriodId == null)
            {
                return(NotFound());
            }
            sale.ReportingPeriod = await _periodData.GetPeriodById((int)sale.ReportingPeriodId);

            List <MLFSReportingPeriod> periods = await _periodData.GetPeriods();

            MLFSReportingPeriod period;

            if (sale.ReportingPeriod.ReportOrder == 12)
            {
                period = periods.Where(x => x.Year == sale.ReportingPeriod.Year && x.ReportOrder == 1).FirstOrDefault();
            }
            else
            {
                period = periods.Where(x => x.FinancialYear == sale.ReportingPeriod.FinancialYear && x.ReportOrder == sale.ReportingPeriod.ReportOrder + 1).FirstOrDefault();
            }
            //create an entry in the next month to balance out
            MLFSDebtorAdjustment adj = new MLFSDebtorAdjustment()
            {
                DebtorId          = newId,
                Amount            = sale.GrossAmount * -1,
                ReportingPeriodId = period.Id
            };

            _adjData.Insert(adj);
            return(RedirectToAction("Index", "MLFSReport"));
        }
コード例 #17
0
        public async Task <IActionResult> Match(int?id, int?debtorId)
        {
            if (debtorId == null || id == null)
            {
                return(NotFound());
            }
            MLFSSale debtor = await _debtorData.GetSaleById((int)debtorId);

            MLFSIncome receipt = await _incomeData.GetIncomeById((int)id);

            if (debtor == null || receipt == null)
            {
                return(NotFound());
            }
            List <MLFSDebtorAdjustment> adjs = new List <MLFSDebtorAdjustment>();

            adjs.Add(new MLFSDebtorAdjustment(debtor, receipt));
            if (debtor.Outstanding != 0 && ((debtor.Outstanding < 0 && (debtor.Outstanding * -1) / debtor.GrossAmount < (decimal)0.020) || debtor.Outstanding / debtor.GrossAmount < (decimal)0.005))
            {
                adjs.Add(debtor.ClearToVariance(receipt.ReportingPeriod));
            }
            _adjustmentData.InsertList(adjs);
            return(Ok());
        }
コード例 #18
0
        public async Task <IActionResult> Index(Upload upload)
        {
            if (upload.ReportingPeriodId == null)
            {
                return(NotFound());
            }
            MLFSReportingPeriod period = await _periodData.GetPeriodById((int)upload.ReportingPeriodId);

            if (period == null)
            {
                return(NotFound());
            }
            upload.ReportingPeriod   = period;
            upload.ReportingPeriodId = period.Id;
            if (upload.Files == null || upload.Files.Count != 4)
            {
                return(NotFound());
            }
            List <MLFSAdvisor> advisors = await _advisorData.GetAdvisors();

            string response = await upload.CreateEntities(advisors);

            if (response != "Success")
            {
                return(NotFound());
            }
            await _salesData.InsertList(upload.Sales);

            await _incomeData.InsertList(upload.Income);

            List <MLFSDebtorAdjustment> adjs = MLFSSale.CheckForReceipts(upload.Sales, upload.Income);

            _adjustmentData.InsertList(adjs);
            ViewBag.Result = "Uploaded Successfully";
            return(RedirectToAction("Index"));
        }
コード例 #19
0
        public async Task <ActionResult> PostMonthlyData(IFormFile salesCSV, IFormFile planCSV, IFormFile fciCSV, string periodId)
        {
            //check we have a valid period
            if (periodId == null || !int.TryParse(periodId, out int pId))
            {
                return(BadRequest());
            }
            //Get the period we are using
            MLFSReportingPeriod period = await _periodData.GetPeriodById(pId);

            if (period == null)
            {
                return(BadRequest());
            }

            //convert our csvs into datatables
            string newSalesFilePath = Path.GetTempFileName();
            string newPlanFilePath  = Path.GetTempFileName();
            string newFCIFilePath   = Path.GetTempFileName();

            if (salesCSV.Length > 0)
            {
                using (var fileStream = new FileStream(newSalesFilePath, FileMode.Create))
                {
                    await salesCSV.CopyToAsync(fileStream);
                }
            }
            else
            {
                return(NotFound());
            }
            if (planCSV.Length > 0)
            {
                using (var fileStream = new FileStream(newPlanFilePath, FileMode.Create))
                {
                    await planCSV.CopyToAsync(fileStream);
                }
            }
            else
            {
                return(NotFound());
            }
            if (fciCSV.Length > 0)
            {
                using (var fileStream = new FileStream(newFCIFilePath, FileMode.Create))
                {
                    await fciCSV.CopyToAsync(fileStream);
                }
            }
            else
            {
                return(NotFound());
            }
            DataTable feeDt  = Tools.ConvertCSVToDataTable(newSalesFilePath);
            DataTable planDt = Tools.ConvertCSVToDataTable(newPlanFilePath);
            DataTable fciDt  = Tools.ConvertCSVToDataTable(newFCIFilePath);

            //load data to database and get response
            await _salesData.UploadSalesForPeriod(period, feeDt, planDt);

            List <MLFSIncome> receipts = await _incomeData.UploadIncomeForPeriod(period, fciDt);

            await _incomeData.UpdateClientOnboardDate(period);

            //Allocate Receipts
            List <MLFSSale> debtors = await _salesData.GetDebtors();

            List <MLFSDebtorAdjustment> adjs = MLFSSale.CheckForReceipts(debtors, receipts.Where(x => x.IncomeType.Contains("Initial")).ToList());

            _adjData.InsertList(adjs);
            return(Ok());
        }
コード例 #20
0
        public void MLFSSaleCreateFromIODataRowTest()
        {
            //arrange
            DataTable table = new DataTable();

            table.Columns.Add("Id", typeof(int));
            table.Columns.Add("Reference Number", typeof(string));
            table.Columns.Add("Fee Owner.Full Name", typeof(string));
            table.Columns.Add("Fee Owner.Id", typeof(string));
            table.Columns.Add("Fee Owner 2.Full Name", typeof(string));
            table.Columns.Add("Fee Owner 2.Id", typeof(string));
            table.Columns.Add("Selling Adviser.Id", typeof(int));
            table.Columns.Add("Selling Adviser.Full Name", typeof(string));
            table.Columns.Add("Related Plan Type", typeof(string));
            table.Columns.Add("Net Amount", typeof(decimal));
            table.Columns.Add("VAT", typeof(decimal));
            table.Columns.Add("Invoice Date", typeof(DateTime));
            table.Columns.Add("Related Plan Reference", typeof(string));


            DataRow row = table.NewRow();

            row["Id"] = "123465";
            row["Reference Number"]          = "IOF123456";
            row["Fee Owner.Id"]              = "654987";
            row["Fee Owner.Full Name"]       = "John Bloggs";
            row["Fee Owner 2.Full Name"]     = "Jane Bloggs";
            row["Fee Owner 2.Id"]            = "321654";
            row["Selling Adviser.Full Name"] = "Joe Smith";
            row["Selling Adviser.Id"]        = "9";
            row["Related Plan Type"]         = "Pension";
            row["Invoice Date"]              = DateTime.Now;
            row["Net Amount"]             = 1000;
            row["VAT"]                    = 100;
            row["Related Plan Reference"] = "IOB098767";
            table.Rows.Add(row);

            List <MLFSAdvisor> advisors = new List <MLFSAdvisor>();
            MLFSAdvisor        advisor  = new MLFSAdvisor()
            {
                Id        = 1,
                FirstName = "Joe",
                LastName  = "Smith",
                PrimaryID = "9",
                Username  = "******"
            };

            advisors.Add(advisor);
            MLFSAdvisor unknownAdvisor = new MLFSAdvisor()
            {
                Id        = 2,
                FirstName = "Unknown",
                LastName  = "",
                PrimaryID = "",
                Username  = "******"
            };

            advisors.Add(unknownAdvisor);
            MLFSReportingPeriod period = new MLFSReportingPeriod(1, 2020)
            {
                Id = 2
            };

            //act
            MLFSSale sale = new MLFSSale(row, advisors, period);

            //assert
            Assert.AreEqual("Joe Smith", sale.Advisor.Fullname, "Advisor doesn't match");
            Assert.AreEqual(1100, sale.GrossAmount, "Gross amount does not match");
            Assert.AreEqual(1, sale.AdvisorId, "Id has not been converted");
        }
コード例 #21
0
        public async Task <List <MLFSIncome> > PotentialDebtorMatches(MLFSSale debtor)
        {
            List <MLFSIncome> matches = await _db.MLFSIncome.Include(x => x.MLFSDebtorAdjustment).Where(x => (x.ClientId == debtor.ClientId || x.ClientName == debtor.ClientName) && x.IncomeType.Contains("Initial") && x.MLFSDebtorAdjustment == null).ToListAsync();

            return(matches);
        }
コード例 #22
0
        public void CheckForReceiptsTest()
        {
            //arrange
            List <MLFSReportingPeriod> periods = new List <MLFSReportingPeriod>();

            for (int i = 1; i < 4; i++)
            {
                MLFSReportingPeriod period = new MLFSReportingPeriod(i, 2020)
                {
                    Id = i
                };
                periods.Add(period);
            }


            List <MLFSSale> debtors = new List <MLFSSale>();
            MLFSSale        sale    = new MLFSSale()
            {
                Id = 1,
                ReportingPeriodId = periods[0].Id,
                ReportingPeriod   = periods[0],
                Investment        = 100,
                NetAmount         = 4,
                OnGoingPercentage = (decimal)0.005,
                RelevantDate      = DateTime.Parse("01/02/2020")
            };

            debtors.Add(sale);
            MLFSSale sale2 = new MLFSSale()
            {
                Id                = 1,
                IOReference       = "1234567",
                ReportingPeriodId = periods[1].Id,
                ReportingPeriod   = periods[1],
                Investment        = 1000,
                NetAmount         = 100,
                OnGoingPercentage = (decimal)0.005,
                RelevantDate      = DateTime.Parse("01/02/2020")
            };

            debtors.Add(sale2);
            List <MLFSIncome> income = new List <MLFSIncome>();
            MLFSIncome        inc    = new MLFSIncome()
            {
                Id                = 1,
                IOReference       = "123456",
                ReportingPeriodId = periods[2].Id,
                ReportingPeriod   = periods[2],
                RelevantDate      = DateTime.Now,
                ClientId          = "234",
                Amount            = 100,
                PlanNumber        = "9876"
            };

            income.Add(inc);
            MLFSIncome inc2 = new MLFSIncome()
            {
                Id                = 2,
                IOReference       = "1234567",
                ReportingPeriodId = periods[2].Id,
                ReportingPeriod   = periods[2],
                RelevantDate      = DateTime.Now,
                ClientId          = "345",
                Amount            = 90,
                PlanNumber        = "9877"
            };

            income.Add(inc2);

            //act
            List <MLFSDebtorAdjustment> adjs = MLFSSale.CheckForReceipts(debtors, income);

            //assert
            Assert.AreEqual(1, adjs.Count, "Incorrect number of adjustments created");
            Assert.AreEqual((decimal)10, sale2.Outstanding, "Amount outstanding to sale2 not reflected");
        }
コード例 #23
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");
        }
コード例 #24
0
        public void MatchPlanTest()
        {
            //arrange
            MLFSReportingPeriod period = new MLFSReportingPeriod(1, 2020)
            {
                Id = 2
            };
            MLFSSale sale = new MLFSSale()
            {
                Id                = 1,
                ClientId          = "IOB123",
                ClientName        = "John",
                ReportingPeriod   = period,
                ReportingPeriodId = period.Id,
                NetAmount         = 100,
                VAT               = 20,
                PlanReference     = "IOP123",
                IOReference       = "IOF345",
                RelevantDate      = DateTime.Parse("01/02/2020")
            };
            DataTable table = new DataTable();

            table.Columns.Add("Id", typeof(int));
            table.Columns.Add("Provider.Name", typeof(string));
            table.Columns.Add("Owner 1.Creation Date", typeof(string));
            table.Columns.Add("Total Premiums to Date", typeof(string));
            table.Columns.Add("On-going Fee Percentage", typeof(string));
            table.Columns.Add("Selling Adviser.Group.Name", typeof(string));
            table.Columns.Add("Root Sequential Ref", typeof(string));
            table.Columns.Add("Sequential Ref", typeof(string));
            table.Columns.Add("Related Fee Reference", typeof(string));

            DataRow firstRow = table.NewRow();

            firstRow["Id"]                         = "123465";
            firstRow["Provider.Name"]              = "Elevate";
            firstRow["Owner 1.Creation Date"]      = "01/01/2020";
            firstRow["Total Premiums to Date"]     = "10000";
            firstRow["On-going Fee Percentage"]    = "0.01";
            firstRow["Selling Adviser.Group.Name"] = "Milsted Langdon Financial Services";
            firstRow["Sequential Ref"]             = "IOP123";
            firstRow["Root Sequential Ref"]        = "IOP124";
            firstRow["Related Fee Reference"]      = "IOF345";
            table.Rows.Add(firstRow);

            DataRow secondRow = table.NewRow();

            secondRow["Id"]                         = "123465";
            secondRow["Provider.Name"]              = "Elevate";
            secondRow["Owner 1.Creation Date"]      = "01/01/2020";
            secondRow["Total Premiums to Date"]     = "20000";
            secondRow["On-going Fee Percentage"]    = "0.01";
            secondRow["Selling Adviser.Group.Name"] = "Milsted Langdon Financial Services";
            secondRow["Sequential Ref"]             = "IOP123";
            secondRow["Root Sequential Ref"]        = "IOP124";
            secondRow["Related Fee Reference"]      = "IOF346";
            table.Rows.Add(secondRow);

            //act
            sale.MatchPlan(table);

            //assert
            Assert.AreEqual((decimal)10000, sale.Investment, "Investment doesn't match");
        }
コード例 #25
0
        public async Task <MLFSSale> GetSaleById(int saleId)
        {
            MLFSSale sale = await _db.MLFSSales.Include(x => x.ReportingPeriod).Include(y => y.Adjustments).Where(y => y.Id == saleId).FirstOrDefaultAsync();

            return(sale);
        }
コード例 #26
0
        public void CreateTest()
        {
            //arrange
            //arrange
            List <MLFSReportingPeriod> periods = new List <MLFSReportingPeriod>();

            for (int i = 1; i < 4; i++)
            {
                MLFSReportingPeriod period = new MLFSReportingPeriod(i, 2020)
                {
                    Id = i
                };
                periods.Add(period);
            }
            MLFSAdvisor advisor = new MLFSAdvisor()
            {
                Id        = 1,
                FirstName = "Geoff",
                LastName  = "Smith"
            };

            List <MLFSSale> debtors = new List <MLFSSale>();
            MLFSSale        sale    = new MLFSSale()
            {
                Id                = 1,
                Advisor           = advisor,
                AdvisorId         = advisor.Id,
                ClientName        = "Billy Bigwallet",
                ReportingPeriodId = periods[0].Id,
                ReportingPeriod   = periods[0],
                Investment        = 100,
                NetAmount         = 4,
                OnGoingPercentage = (decimal)0.005,
                RelevantDate      = DateTime.Parse("01/02/2020")
            };

            debtors.Add(sale);
            MLFSSale sale2 = new MLFSSale()
            {
                Id                = 1,
                Advisor           = advisor,
                AdvisorId         = advisor.Id,
                ClientName        = "Jonny Comelately",
                IOReference       = "1234567",
                ReportingPeriodId = periods[1].Id,
                ReportingPeriod   = periods[1],
                Investment        = 1000,
                NetAmount         = 100,
                OnGoingPercentage = (decimal)0.005,
                RelevantDate      = DateTime.Parse("01/02/2020")
            };

            debtors.Add(sale2);


            //act
            List <DirectorsReport> report = DirectorsReport.Create(debtors);

            //assert
            Assert.AreEqual(2, report.Count, "Wrong number of records");
            Assert.AreEqual(104, report.Sum(x => x.InitialFee), "Total fees does not match");
        }
コード例 #27
0
 public void Update(MLFSSale sale)
 {
     _db.Entry(sale).State = EntityState.Modified;
     _db.SaveChanges();
 }