Ejemplo n.º 1
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");
        }
Ejemplo n.º 2
0
        public void Delete(int adjustmentId)
        {
            MLFSDebtorAdjustment adj = _context.MLFSDebtorAdjustments.Find(adjustmentId);

            if (adj != null)
            {
                _context.MLFSDebtorAdjustments.Remove(adj);
                _context.SaveChanges();
            }
        }
Ejemplo n.º 3
0
 public IActionResult Create([Bind("Id,ReportingPeriodId,DebtorId,ReceiptId,Amount,IsVariance,NotTakenUp")] MLFSDebtorAdjustment adj)
 {
     if (ModelState.IsValid)
     {
         _adjustmentData.Insert(adj);
     }
     else
     {
         //return error
     }
     return(RedirectToAction("Index", "Debtor"));
 }
Ejemplo n.º 4
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));
        }
        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());
        }
Ejemplo n.º 6
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"));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Reverse(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var adj = await _adjustmentData.GetAdjustmentById((int)id);

            if (adj == null)
            {
                return(NotFound());
            }
            MLFSDebtorAdjustment clone = adj.Clone();

            clone.Amount  = adj.Amount * -1;
            adj.ReceiptId = null;
            _adjustmentData.Insert(clone);
            _adjustmentData.Update(adj);
            return(RedirectToAction("Index", "Debtor"));
        }
Ejemplo n.º 8
0
        public void CloneTest()
        {
            //arrange
            MLFSDebtorAdjustment adj = new MLFSDebtorAdjustment()
            {
                Id = 1,
                ReportingPeriodId = 2,
                DebtorId          = 3,
                ReceiptId         = 4,
                Amount            = 100,
                IsVariance        = false,
                NotTakenUp        = false
            };

            //act
            MLFSDebtorAdjustment adj2 = adj.Clone();

            //assert
            Assert.AreEqual(adj.Amount, adj2.Amount, "Amounts don't match");
            Assert.AreEqual(adj.Receipt, adj2.ReceiptId, "Receipt Id don't match");
            Assert.AreEqual(adj.NotTakenUp, adj2.NotTakenUp, "NTU status doesn't match");
        }
        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"));
        }
Ejemplo n.º 10
0
 public void Update(MLFSDebtorAdjustment adjustment)
 {
     _context.Entry(adjustment).State = EntityState.Modified;
     _context.SaveChanges();
 }
Ejemplo n.º 11
0
 public void Insert(MLFSDebtorAdjustment adjustment)
 {
     _context.MLFSDebtorAdjustments.Add(adjustment);
     _context.SaveChanges();
 }
Ejemplo n.º 12
0
        public async Task <MLFSDebtorAdjustment> GetAdjustmentById(int adjustmentId)
        {
            MLFSDebtorAdjustment adj = await _context.MLFSDebtorAdjustments.FindAsync(adjustmentId);

            return(adj);
        }