// GET: Debtor public async Task <IActionResult> Index(int?advisorId, string financialYear) { List <MLFSReportingPeriod> periods = await _periodData.GetPeriods(); SelectList yearList = new SelectList(periods.Select(x => x.FinancialYear).Distinct()); ViewBag.Year = yearList; ViewBag.AdvisorId = await _advisorData.SelectList(); if (advisorId == null) { BudgetReview review = new BudgetReview(); return(View(review)); } else { if (String.IsNullOrEmpty(financialYear)) { financialYear = yearList.FirstOrDefault().Value; } MLFSAdvisor advisor = await _advisorData.GetAdvisor((int)advisorId); List <MLFSBudget> budgets = await _budgetData.GetBudgets(periods.Where(x => x.FinancialYear == financialYear).ToList()); BudgetReview review = new BudgetReview(advisor, budgets, periods, financialYear); return(View(review)); } }
public void AssignTestWithUnknown() { //arrange List <MLFSAdvisor> advisors = new List <MLFSAdvisor>(); MLFSAdvisor advisor = new MLFSAdvisor() { Id = 6, FirstName = "Joe", LastName = "Smith", PrimaryID = "4", Username = "******" }; advisors.Add(advisor); MLFSAdvisor unknownAdvisor = new MLFSAdvisor() { Id = 2, FirstName = "Unknown", LastName = "", PrimaryID = "", Username = "******" }; advisors.Add(unknownAdvisor); //act MLFSAdvisor adv = MLFSAdvisor.Assign("12", advisors); //assert Assert.AreEqual(2, adv.Id, "Assignment to unknown has not worked"); }
public BudgetReview(MLFSAdvisor advisor, List <MLFSBudget> budgets, List <MLFSReportingPeriod> periods, string financialYear) { Budgets = new List <MLFSBudget>(); AdvisorId = advisor.Id; Advisor = advisor; Year = financialYear; budgets = budgets.Where(x => x.ReportingPeriod.FinancialYear == financialYear && x.AdvisorId == advisor.Id).ToList(); if (budgets.Count != 12) { periods = periods.Where(x => x.FinancialYear == financialYear).ToList(); for (int i = 0; i < periods.Count; i++) { if (budgets.Where(x => x.ReportingPeriodId == periods[i].Id).Count() == 0) { budgets.Add(new MLFSBudget() { ReportingPeriodId = periods[i].Id, ReportingPeriod = periods[i], Budget = 0, Advisor = Advisor, AdvisorId = AdvisorId }); } } } if (budgets != null) { Budgets = budgets; } }
public void Update(MLFSAdvisor adv) { if (adv.Name == null) { adv.Name = adv.FirstName + " " + adv.LastName; } _db.Entry(adv).State = EntityState.Modified; _db.SaveChanges(); }
public IActionResult Create([Bind("Grade,Username,Department,Office,PrimaryID,Title,FirstName,LastName")] MLFSAdvisor mLFSAdvisor) { if (ModelState.IsValid) { _advisorData.Add(mLFSAdvisor); return(RedirectToAction(nameof(Index))); } return(View(mLFSAdvisor)); }
public void Add(MLFSAdvisor adv) { adv.Active = true; if (adv.Name == null) { adv.Name = adv.FirstName + " " + adv.LastName; } _db.MLFSAdvisors.Add(adv); _db.SaveChanges(); }
public IActionResult Edit(int id, [Bind("ReplacementAdvisorId,Grade,Username,Department,Office,Active,Id,PrimaryID,Title,FirstName,LastName")] MLFSAdvisor mLFSAdvisor) { if (id != mLFSAdvisor.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _advisorData.Update(mLFSAdvisor); } catch (DbUpdateConcurrencyException) { throw; } return(RedirectToAction(nameof(Index))); } return(View(mLFSAdvisor)); }
public async Task <IActionResult> CreateClawback([Bind("ReportingPeriodId,AdvisorId,ClientName,RelevantDate,Amount,IgnoreFromCommission")] MLFSIncome income) { if (ModelState.IsValid) { MLFSAdvisor adv = await _advisorData.GetAdvisor(income.AdvisorId); //make sure it is a negative value if (income.Amount > 0) { income.Amount *= -1; } income.IsClawBack = true; income.Organisation = adv.Department; _incomeData.Insert(income); } else { return(NotFound()); } return(RedirectToAction("Index", "MLFSReport")); }
public SalesSummary(MLFSAdvisor adv, List <SalesReport> lines) { Advisor = adv.Fullname; AdvisorId = adv.Id; Organisation = adv.Department; Q1Budget = lines.Where(x => x.Quarter == 1).Sum(y => y.Budget); Q1Actual = lines.Where(x => x.Quarter == 1).Sum(y => y.Total); if (Q1Budget != 0) { Q1Variance = (int)decimal.Round(Q1Actual / Q1Budget * 100, 0); } Q2Budget = lines.Where(x => x.Quarter == 2).Sum(y => y.Budget); Q2Actual = lines.Where(x => x.Quarter == 2).Sum(y => y.Total); if (Q2Budget != 0) { Q2Variance = (int)decimal.Round(Q2Actual / Q2Budget * 100, 0); } Q3Budget = lines.Where(x => x.Quarter == 3).Sum(y => y.Budget); Q3Actual = lines.Where(x => x.Quarter == 3).Sum(y => y.Total); if (Q3Budget != 0) { Q3Variance = (int)decimal.Round(Q3Actual / Q3Budget * 100, 0); } Q4Budget = lines.Where(x => x.Quarter == 4).Sum(y => y.Budget); Q4Actual = lines.Where(x => x.Quarter == 4).Sum(y => y.Total); if (Q4Budget != 0) { Q4Variance = (int)decimal.Round(Q4Actual / Q4Budget * 100, 0); } YearToDateBudget = Q1Budget + Q2Budget + Q3Budget + Q4Budget; YearToDateActual = Q1Actual + Q2Actual + Q3Actual + Q4Actual; if (YearToDateBudget != 0) { YearToDateVariance = (int)decimal.Round(YearToDateActual / YearToDateBudget * 100, 0); } }
public async Task <MLFSAdvisor> GetAdvisor(int id) { MLFSAdvisor adv = await _db.MLFSAdvisors.FindAsync(id); return(adv); }
private List <MLFSReportingPeriod> MockEntries() { 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 <MLFSIncome> income = new List <MLFSIncome>(); MLFSIncome inc = new MLFSIncome() { Id = 1, IOReference = "123456", Advisor = advisor, AdvisorId = advisor.Id, Organisation = "FPP", ReportingPeriodId = periods[0].Id, ReportingPeriod = periods[0], RelevantDate = DateTime.Now, ClientOnBoardDate = DateTime.Now.AddMonths(-2), ClientId = "234", Amount = 100, PlanNumber = "9876" }; income.Add(inc); MLFSIncome inc2 = new MLFSIncome() { Id = 2, IOReference = "1234567", Advisor = advisor, AdvisorId = advisor.Id, Organisation = "MLFS", ReportingPeriodId = periods[0].Id, ReportingPeriod = periods[0], RelevantDate = DateTime.Now, ClientOnBoardDate = DateTime.Now.AddMonths(-2), ClientId = "345", Amount = 100, PlanNumber = "9877" }; income.Add(inc2); List <MLFSBudget> budgets = new List <MLFSBudget>(); MLFSBudget budget = new MLFSBudget() { Id = 9, Advisor = advisor, AdvisorId = advisor.Id, Budget = (decimal)20000, ReportingPeriodId = periods[0].Id, ReportingPeriod = periods[0] }; budgets.Add(budget); periods[0].Receipts = income; periods[0].Budgets = budgets; return(periods); }
public SalesReport(List <MLFSIncome> income, List <MLFSSale> sales, List <MLFSDebtorAdjustment> adjustments, List <MLFSBudget> budgets, MLFSAdvisor advisor, MLFSReportingPeriod period) { List <MLFSIncome> relevantIncome = income.Where(x => x.AdvisorId == advisor.Id && x.ReportingPeriodId == period.Id).ToList(); List <MLFSDebtorAdjustment> relevantAdjustments = adjustments.Where(x => x.ReportingPeriodId == period.Id && x.Debtor.AdvisorId == advisor.Id).ToList(); Organisation = advisor.Department; Period = period.Description; PeriodId = period.Id; decimal q = period.ReportOrder / 3; Quarter = period.Quarter; Advisor = advisor.Fullname; AdvisorId = advisor.Id; MLFSBudget budget = budgets.Where(x => x.AdvisorId == advisor.Id && x.ReportingPeriodId == period.Id).FirstOrDefault(); if (budget != null) { Budget = budget.Budget; } else { Budget = 0; } New_Business = sales.Where(x => x.AdvisorId == advisor.Id).Distinct().Sum(y => y.NetAmount); Renewals = relevantIncome.Where(x => !x.IsNewBusiness && !x.IsClawBack).Distinct().Sum(y => y.Amount); Unallocated = relevantIncome.Where(x => x.IsNewBusiness && !x.IsClawBack && x.MLFSDebtorAdjustment == null).Distinct().Sum(y => y.Amount); Clawback = relevantIncome.Where(x => x.IsClawBack).Distinct().Sum(y => y.Amount); NotTakenUp = relevantAdjustments.Where(x => x.NotTakenUp).Distinct().Sum(y => y.Amount); Adjustment = relevantIncome.Where(x => x.IsAdjustment).Distinct().Sum(y => y.Amount); Debtors_Adjustment = relevantAdjustments.Where(x => x.ReceiptId == null && !x.NotTakenUp && !x.IsVariance).Distinct().Sum(y => y.Amount); Debtors_Variance = relevantAdjustments.Where(x => x.IsVariance).Distinct().Sum(y => y.Amount); Total = New_Business + Adjustment + Renewals + Unallocated + Clawback + NotTakenUp + Debtors_Adjustment + Debtors_Variance; }
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"); }
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"); }
public void MLFSIncomeCreateFromIODataRowTest() { //arrange DataTable table = new DataTable(); table.Columns.Add("IORef", typeof(string)); table.Columns.Add("GroupOne", typeof(string)); table.Columns.Add("Submitted", typeof(DateTime)); table.Columns.Add("CRMContactId", typeof(int)); table.Columns.Add("Provider", typeof(string)); table.Columns.Add("ClientName", typeof(string)); table.Columns.Add("ClientId", typeof(string)); table.Columns.Add("JointClientName", typeof(string)); table.Columns.Add("JointClientId", typeof(string)); table.Columns.Add("CampaignType", typeof(string)); table.Columns.Add("CampaignSource", typeof(string)); table.Columns.Add("GrossFCI Excl.VAT", typeof(decimal)); table.Columns.Add("FeeStatus", typeof(string)); table.Columns.Add("PlanType", typeof(string)); table.Columns.Add("PlanNumber", typeof(string)); table.Columns.Add("IsTopup", typeof(bool)); table.Columns.Add("IncomeType", typeof(string)); DataRow row = table.NewRow(); row["IORef"] = "IOF123456"; row["GroupOne"] = "MLFS"; row["Submitted"] = DateTime.Now; row["CRMContactId"] = 4; row["Provider"] = "Elevate"; row["ClientName"] = "Jeff Bloggs"; row["ClientId"] = 5; row["JointClientName"] = "Jane Bloggs"; row["JointClientId"] = 6; row["Campaigntype"] = "Teachers"; row["CampaignSource"] = "ML"; row["GrossFCI Excl.VAT"] = 1100; row["FeeStatus"] = "Paid"; row["PlanType"] = "Pension"; row["PlanNumber"] = "123456"; row["IsTopup"] = true; row["IncomeType"] = "InitialFee"; table.Rows.Add(row); List <MLFSAdvisor> advisors = new List <MLFSAdvisor>(); MLFSAdvisor advisor = new MLFSAdvisor() { Id = 6, FirstName = "Joe", LastName = "Smith", PrimaryID = "4", Username = "******" }; advisors.Add(advisor); MLFSAdvisor unknownAdvisor = new MLFSAdvisor() { Id = 2, FirstName = "Unknown", LastName = "", PrimaryID = "", Username = "******" }; advisors.Add(unknownAdvisor); //act MLFSIncome income = new MLFSIncome(row, advisors); //assert Assert.AreEqual("Elevate", income.ProviderName, "Provider doesn't match"); Assert.AreEqual(1100, income.Amount, "Amount does not match"); Assert.AreEqual(6, income.AdvisorId, "Advisor has not been updated"); }