예제 #1
0
        // 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));
            }
        }
예제 #2
0
        // GET: MLFSAdvisors/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var mLFSAdvisor = await _advisorData.GetAdvisor((int)id);

            if (mLFSAdvisor == null)
            {
                return(NotFound());
            }
            ViewBag.ReplacementAdvisorId = await _advisorData.SelectList();

            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 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"));
        }