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")); }
// GET: MLFSAdvisors public async Task <IActionResult> Index() { return(View(await _advisorData.GetAdvisors())); }
public async Task <IActionResult> SalesReport(int?periodId, string entity = "advisor") { MLFSReportingPeriod period; List <SalesReport> report = new List <SalesReport>(); //get period if (periodId == null) { return(NotFound()); } period = await _periodData.GetPeriodById((int)periodId); if (period == null) { return(NotFound()); } //get advsiors List <MLFSAdvisor> advisors = await _advisorData.GetAdvisors(); List <MLFSIncome> income = await _incomeData.GetIncome(period); List <MLFSSale> sales = await _salesData.GetSales(period); List <MLFSDebtorAdjustment> adjs = await _adjustmentData.GetAdjustments(period); List <MLFSBudget> budgets = await _budgetData.GetBudgets(period); if (entity.ToLower() == "advisor") { foreach (MLFSAdvisor adv in advisors) { SalesReport line = new SalesReport(income, sales, adjs, budgets, adv, period); report.Add(line); } } if (entity.ToLower() == "organisation") { report = report.GroupBy(x => x.Organisation).Select(y => new ViewModels.SalesReport() { Period = y.FirstOrDefault().Period, PeriodId = y.FirstOrDefault().PeriodId, Advisor = y.Key, AdvisorId = 0, Organisation = y.Key, Budget = y.Sum(z => z.Budget), New_Business = y.Sum(z => z.New_Business), Renewals = y.Sum(z => z.Renewals), Unallocated = y.Sum(z => z.Unallocated), Clawback = y.Sum(z => z.Clawback), NotTakenUp = y.Sum(z => z.NotTakenUp), Adjustment = y.Sum(z => z.Adjustment), Debtors_Variance = y.Sum(z => z.Debtors_Variance), Debtors_Adjustment = y.Sum(z => z.Debtors_Adjustment), Total = y.Sum(z => z.Total) }).ToList(); } else if (entity.ToLower() == "campaign") { report = ViewModels.SalesReport.CreateByCampaign(income, period); } return(PartialView("_SalesReport", report.OrderBy(x => x.Advisor))); }