Esempio n. 1
0
 public IncomeReport(MLFSIncome income)
 {
     Period       = income.ReportingPeriod.Description;
     PeriodId     = income.ReportingPeriod.Id;
     Organisation = income.Organisation;
     if (income.Advisor != null)
     {
         Advisor   = income.Advisor.Fullname;
         AdvisorId = income.AdvisorId;
     }
     else
     {
         Advisor   = "Unknown";
         AdvisorId = 0;
     }
     if (income.IsNewBusiness)
     {
         New_Amount = income.Amount;
     }
     else
     {
         Existing_Amount = income.Amount;
     }
     Amount = income.Amount;
     Budget = 0;
 }
 public IActionResult Edit(MLFSIncome income)
 {
     if (ModelState.IsValid)
     {
         _incomeData.Update(income);
         return(Redirect(TempData["sendingURL"].ToString()));
     }
     return(RedirectToAction("Edit", income.Id));
 }
        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 <IActionResult> AlterAdvisor(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            MLFSIncome income = await _incomeData.GetIncomeById((int)id);

            ViewBag.AdvisorId = await _advisorData.SelectList(income.AdvisorId);

            return(PartialView("_AlterAdvisor", income));
        }
        public async Task <IActionResult> ConvertToRecurring(int incomeId)
        {
            MLFSIncome income = await _incomeData.GetIncomeById(incomeId);

            if (income == null)
            {
                return(NotFound());
            }
            income.IncomeType = "Converted";
            _incomeData.Update(income);
            return(Ok());
        }
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            TempData["sendingURL"] = HttpContext.Request.Headers["Referer"].ToString();
            MLFSIncome income = await _incomeData.GetIncomeById((int)id);

            ViewBag.AdvisorId = await _advisorData.SelectList(income.AdvisorId);

            return(PartialView("_Edit", income));
        }
        public async Task <IActionResult> AlterAdvisor(int?id, int?advisorId)
        {
            if (id == null || advisorId == null)
            {
                return(NotFound());
            }
            MLFSIncome income = await _incomeData.GetIncomeById((int)id);

            income.AdvisorId = (int)advisorId;
            _incomeData.Update(income);

            return(Ok());
        }
Esempio n. 8
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);
        }
        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());
        }
        public async Task <IActionResult> ConvertToGross(int incomeId)
        {
            MLFSIncome income = await _incomeData.GetIncomeById(incomeId);

            if (income == null)
            {
                return(NotFound());
            }
            income.Amount += income.VAT;
            income.VAT     = 0;
            _incomeData.Update(income);
            //add to register for next month
            _issueData.Add(income.IOReference);
            return(Ok());
        }
Esempio n. 11
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"));
        }
        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 async Task UpdateClientOnboardDate(MLFSReportingPeriod period)
        {
            List <MLFSIncome> incomeLines = await _db.MLFSIncome.Where(x => x.ReportingPeriodId == period.Id && x.ClientOnBoardDate == null).ToListAsync();

            incomeLines = incomeLines.Where(x => x.IsNewBusiness).ToList();
            if (incomeLines.Count > 0)
            {
                string[] ids = incomeLines.Select(x => x.ClientId).ToArray();
                while (ids.Length != 0)
                {
                    string[] idsForSubmission;
                    string   idString = "";
                    if (ids.Length > 100)
                    {
                        idsForSubmission = ids.Take(100).ToArray();
                    }
                    else
                    {
                        idsForSubmission = ids;
                    }
                    foreach (string id in idsForSubmission)
                    {
                        if (!String.IsNullOrEmpty(id))
                        {
                            idString += id + ",";
                        }
                    }
                    idString = idString.TrimEnd(',');
                    idString = "(" + idString + ")";
                    List <MLFSClient> clients = await _clientData.GetClients(idString);

                    if (clients != null)
                    {
                        MLFSIncome.UpdateFromIO(incomeLines, clients);
                    }
                    ids = ids.Except(idsForSubmission).ToArray();
                }
            }
        }
Esempio n. 14
0
 public MLFSIncomeReport(MLFSIncome income)
 {
     Reporting_Period = income.ReportingPeriod.Description;
     if (income.Advisor == null)
     {
         Advisor = "Unknown";
     }
     else
     {
         Advisor = income.Advisor.Fullname;
     }
     Organisation = income.Organisation;
     Campaign     = income.Campaign;
     if (income.IsNewBusiness)
     {
         New_Amount       = income.Amount;
         Recurring_Amount = 0;
     }
     else
     {
         New_Amount       = 0;
         Recurring_Amount = income.Amount;
     }
 }
Esempio n. 15
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());
        }
        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");
        }
Esempio n. 17
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");
        }
        public async Task <MLFSIncome> GetIncomeById(int incomeId)
        {
            MLFSIncome income = await _db.MLFSIncome.Include(x => x.ReportingPeriod).Where(y => y.Id == incomeId).FirstOrDefaultAsync();

            return(income);
        }
 public void Update(MLFSIncome income)
 {
     _db.Entry(income).State = EntityState.Modified;
     _db.SaveChanges();
 }
 public void Insert(MLFSIncome income)
 {
     _db.MLFSIncome.Add(income);
     _db.SaveChanges();
 }
        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);
        }