Пример #1
0
        internal IncomeVm GetIncomeVmByReportVm(ReportVm reportVm)
        {
            decimal         TotalIncome   = 0;
            decimal         TotalSales    = 0;
            decimal         TotalPurchase = 0;
            List <Sale>     Sales         = reportDal.GetSalesByReportVm(reportVm);
            List <Purchase> Purchase      = reportDal.GetPurchasesByReportVm(reportVm);

            if (Sales != null)
            {
                foreach (var item in Sales)
                {
                    TotalSales = TotalSales + item.Total;
                }
            }
            if (Purchase != null)
            {
                foreach (var item in Purchase)
                {
                    TotalPurchase = TotalPurchase + item.Total;
                }
            }

            TotalIncome = TotalSales - TotalPurchase;
            IncomeVm incomeVm = new IncomeVm();

            incomeVm.Sales          = Sales;
            incomeVm.Purchases      = Purchase;
            incomeVm.SalesTotal     = TotalSales;
            incomeVm.PurchasesTotal = TotalPurchase;
            incomeVm.TotalIncome    = TotalIncome;
            return(incomeVm);
        }
        public async Task YourIncomePostTest()
        {
            string id = Guid.NewGuid().ToString();

            this._controller.RouteData.Values.Add("id", id);
            this._portalSettings.Features.EnablePartialSave = true;

            IncomeAndExpenditure iAndE = new IncomeAndExpenditure();
            IncomeVm             vm    = new IncomeVm();

            this._sessionState.Setup(x => x.CheckSessionStatus(id));
            this._sessionState.Setup(x => x.GetIncomeAndExpenditure(Guid.Parse(id))).Returns(iAndE);
            this._mapper.Setup(x => x.Map(vm, iAndE)).Returns(iAndE);
            this._sessionState.Setup(x => x.SaveIncomeAndExpenditure(iAndE, Guid.Parse(id)));

            string lowellReference = "123456789";

            this._sessionState.Setup(x => x.GetLowellReferenceFromSurrogate(Guid.Parse(id))).Returns(lowellReference);
            this._webActivityService.Setup(x => x.LogBudgetCalculatorBillsAndOutgoings1(
                                               lowellReference, this._caseflowUserId)).Returns(Task.CompletedTask);

            RedirectToActionResult result = (RedirectToActionResult)await this._controller.YourIncomePost(vm, "testing");

            Assert.AreEqual("BillsAndOutgoings", result.ActionName);
            Assert.AreEqual(id, result.RouteValues["id"]);
            Assert.IsTrue(vm.EnabledPartialSave);
        }
        public async Task YourIncomePostTest_SaveForLater()
        {
            string id = Guid.NewGuid().ToString();

            this._controller.RouteData.Values.Add("id", id);
            this._portalSettings.Features.EnablePartialSave = true;

            IncomeAndExpenditure iAndE = new IncomeAndExpenditure();
            IncomeVm             vm    = new IncomeVm();

            this._sessionState.Setup(x => x.CheckSessionStatus(id));
            this._sessionState.Setup(x => x.GetIncomeAndExpenditure(Guid.Parse(id))).Returns(iAndE);
            this._mapper.Setup(x => x.Map(vm, iAndE)).Returns(iAndE);
            this._sessionState.Setup(x => x.SaveIncomeAndExpenditure(iAndE, Guid.Parse(id)));

            string lowellReference = "123456789";

            this._sessionState.Setup(x => x.GetLowellReferenceFromSurrogate(Guid.Parse(id))).Returns(lowellReference);
            this._webActivityService.Setup(x => x.LogBudgetCalculatorBillsAndOutgoings1(
                                               lowellReference, this._caseflowUserId)).Returns(Task.CompletedTask);

            this._budgetCalculatorService.Setup(x => x.PartiallySaveIncomeAndExpenditure(
                                                    iAndE, lowellReference, Guid.Parse(this._caseflowUserId))).Returns(Task.FromResult(true));

            ViewResult result = (ViewResult)await this._controller.YourIncomePost(vm, "saveforlater");

            Assert.AreEqual("YourIncome", result.ViewName);
            Assert.AreEqual(vm, result.Model);
            Assert.IsTrue(vm.EnabledPartialSave);
            Assert.IsTrue(vm.PartialSavedEvent);
            Assert.IsTrue(vm.PartialSavedIAndE);
            Assert.IsFalse(vm.HasErrorPartialSavedIAndE);
        }
        public void YourIncomeTest()
        {
            string id = Guid.NewGuid().ToString();

            this._controller.RouteData.Values.Add("id", id);
            this._portalSettings.Features.EnablePartialSave = true;

            this._sessionState.Setup(x => x.CheckSessionStatus(id));

            IncomeAndExpenditure iAndE = new IncomeAndExpenditure()
            {
                HousingStatus    = "housing-status",
                EmploymentStatus = "employment-status"
            };

            IncomeVm vm = new IncomeVm();

            this._sessionState.Setup(x => x.GetIncomeAndExpenditure(Guid.Parse(id))).Returns(iAndE);
            this._gtmService.Setup(x => x.RaiseBudgetCalculatorHouseholdDetailsEvent(
                                       vm, this._caseflowUserId, "housing-status", "employment-status"));

            this._mapper.Setup(x => x.Map(iAndE, vm)).Returns(vm);


            ViewResult result = (ViewResult)this._controller.YourIncome(vm);

            Assert.AreEqual(vm, result.Model);
            Assert.AreEqual(true, vm.EnabledPartialSave);
        }
Пример #5
0
        public void Income_AllIncome_AmounthasValue_And_FrequencySet_NoValidationErrors()
        {
            var model = new IncomeVm()
            {
                BenefitsAndTaxCredits = new IncomeSourceVm()
                {
                    Amount    = 100,
                    Frequency = "Monthly"
                },
                Earning = new IncomeSourceVm()
                {
                    Amount    = 100,
                    Frequency = "Monthly"
                },
                Other = new IncomeSourceVm()
                {
                    Amount    = 100,
                    Frequency = "Monthly"
                },
                Pension = new IncomeSourceVm()
                {
                    Amount    = 100,
                    Frequency = "Monthly"
                }
            };

            var result = _validator.Validate(model);

            Assert.IsTrue(result.IsValid);
            Assert.AreEqual(result.Errors.Count, 0);
        }
Пример #6
0
        public void Income_AllIncome_AmountSetToValue0_And_FrequencyNotSet_FailsValidation()
        {
            var model = new IncomeVm()
            {
                BenefitsAndTaxCredits = new IncomeSourceVm()
                {
                    Amount = 0
                },
                Earning = new IncomeSourceVm()
                {
                    Amount = 0
                },
                Other = new IncomeSourceVm()
                {
                    Amount = 0
                },
                Pension = new IncomeSourceVm()
                {
                    Amount = 0
                }
            };

            var result = _validator.Validate(model);

            Assert.IsTrue(result.IsValid == false);
            Assert.AreEqual(1, result.Errors.Count);
            Assert.AreEqual("All income fields cannot be zero", result.Errors[0].ErrorMessage);
        }
Пример #7
0
        internal IncomeVm GetIncomeVmByReportVm(ReportVm reportVm)
        {
            decimal         totalIncome   = 0;
            decimal         totalSales    = 0;
            decimal         totalPurchase = 0;
            List <Sale>     sales         = _reportDal.GetSalesByReportVm(reportVm);
            List <Purchase> purchase      = _reportDal.GetPurchasesByReportVm(reportVm);

            if (sales != null)
            {
                foreach (var item in sales)
                {
                    totalSales = totalSales + item.Total;
                }
            }
            if (purchase != null)
            {
                foreach (var item in purchase)
                {
                    totalPurchase = totalPurchase + item.Total;
                }
            }

            totalIncome = totalSales - totalPurchase;
            IncomeVm incomeVm = new IncomeVm();

            incomeVm.Sales          = sales;
            incomeVm.Purchases      = purchase;
            incomeVm.SalesTotal     = totalSales;
            incomeVm.PurchasesTotal = totalPurchase;
            incomeVm.TotalIncome    = totalIncome;
            return(incomeVm);
        }
        public ActionResult IncomeReport(ReportVm reportVm)
        {
            IncomeVm incomeVm = reportBll.GetIncomeVmByReportVm(reportVm);

            incomeVmForPdf   = incomeVm;
            ViewBag.OutletId = reportBll.GetOutlet();
            return(View(incomeVm));
        }
Пример #9
0
        public void ConvertTest()
        {
            IncomeVm source = new IncomeVm()
            {
                BenefitsAndTaxCredits = new IncomeSourceVm()
                {
                    Amount = 100, Frequency = "weekly"
                },
                Earning = new IncomeSourceVm()
                {
                    Amount = 3000, Frequency = "monthly"
                },
                Pension = new IncomeSourceVm()
                {
                    Amount = 125, Frequency = "fortnightly"
                },
                Other = new IncomeSourceVm()
                {
                    Amount = 50, Frequency = "weekly"
                },
                GtmEvents = new List <GtmEvent>()
                {
                    new GtmEvent()
                    {
                        account_ref = "123456789"
                    }
                },
                EnabledPartialSave        = true,
                HasErrorPartialSavedIAndE = true,
                PartialSavedEvent         = true,
                PartialSavedIAndE         = true
            };

            //Create a copy of source for later
            IncomeVm sourceCopy = Utilities.DeepCopy(source);

            IncomeAndExpenditure destination = Utilities.CreateDefaultTestIAndE();
            IncomeAndExpenditure expected    = Utilities.DeepCopy(destination);

            expected.BenefitsTotal          = 100;
            expected.BenefitsTotalFrequency = "weekly";
            expected.Salary               = 3000;
            expected.SalaryFrequency      = "monthly";
            expected.OtherIncome          = 50;
            expected.OtherincomeFrequency = "weekly";
            expected.Pension              = 125;
            expected.PensionFrequency     = "fortnightly";

            IncomeAndExpenditure result = _converter.Convert(source, destination, null);

            //Check that the result is as expected
            Assert.IsTrue(Utilities.DeepCompare(expected, result));

            //Check that source hasn't been modified
            Assert.IsTrue(Utilities.DeepCompare(source, sourceCopy));
        }
        public void ConvertTest_SourceNull()
        {
            IncomeAndExpenditure source      = null;
            IncomeVm             destination = new IncomeVm()
            {
                BenefitsAndTaxCredits = new IncomeSourceVm()
                {
                    Amount = Int32.MaxValue, Frequency = "test"
                },
                Earning = new IncomeSourceVm()
                {
                    Amount = Int32.MaxValue, Frequency = "test"
                },
                Other = new IncomeSourceVm()
                {
                    Amount = Int32.MaxValue, Frequency = "test"
                },
                Pension = new IncomeSourceVm()
                {
                    Amount = Int32.MaxValue, Frequency = "test"
                },
                PartialSavedEvent         = true,
                EnabledPartialSave        = true,
                PartialSavedIAndE         = true,
                HasErrorPartialSavedIAndE = true,
                GtmEvents = new List <GtmEvent>()
                {
                    new GtmEvent()
                    {
                        account_ref = "test"
                    }
                }
            };

            IncomeVm expected = Utilities.DeepCopy(destination);

            expected.BenefitsAndTaxCredits.Amount    = 0;
            expected.BenefitsAndTaxCredits.Frequency = null;
            expected.Earning.Amount    = 0;
            expected.Earning.Frequency = null;
            expected.Other.Amount      = 0;
            expected.Other.Frequency   = null;
            expected.Pension.Amount    = 0;
            expected.Pension.Frequency = null;

            IncomeVm result = _converter.Convert(source, destination, null);

            //Check result is as expected
            Assert.IsTrue(Utilities.DeepCompare(expected, result));
        }
        public async Task <IActionResult> YourIncomePost(IncomeVm viewModel, string submit)
        {
            if (submit == "saveforlater")
            {
                viewModel.PartialSavedEvent = true;
            }

            var id = RouteData.Values["id"];

            if (id == null)
            {
                return(RedirectToAction("Index", "MyAccounts"));
            }

            Guid guid = Guid.Parse(id.ToString());

            ApplicationSessionState.CheckSessionStatus(id.ToString());
            viewModel.EnabledPartialSave = _portalSettings.Features.EnablePartialSave && LoggedInUser.IsLoggedInUser;

            if (!ModelState.IsValid)
            {
                return(View("YourIncome", viewModel));
            }

            IncomeAndExpenditure incomeAndExpenditure = ApplicationSessionState.GetIncomeAndExpenditure(guid);

            incomeAndExpenditure = _mapper.Map(viewModel, incomeAndExpenditure);
            ApplicationSessionState.SaveIncomeAndExpenditure(incomeAndExpenditure, guid);

            string lowellReference = ApplicationSessionState.GetLowellReferenceFromSurrogate(guid);

            await _webActivityService.LogBudgetCalculatorBillsAndOutgoings1(lowellReference, LoggedInUserId);

            if (submit == "saveforlater" && LoggedInUser.IsLoggedInUser && _portalSettings.Features.EnablePartialSave)
            {
                bool isPartialSaved = await PartialSave(incomeAndExpenditure, lowellReference);

                viewModel.PartialSavedIAndE         = isPartialSaved;
                viewModel.HasErrorPartialSavedIAndE = !isPartialSaved;

                return(View("YourIncome", viewModel));
            }

            return(RedirectToAction("BillsAndOutgoings", new { id }));
        }
        public async Task YourIncomePostTest_ModelStateInvalid()
        {
            string id = Guid.NewGuid().ToString();

            this._controller.RouteData.Values.Add("id", id);
            this._controller.ModelState.AddModelError("testing", "testing");
            this._portalSettings.Features.EnablePartialSave = true;

            IncomeVm vm = new IncomeVm();

            this._sessionState.Setup(x => x.CheckSessionStatus(id));

            ViewResult result = (ViewResult)await this._controller.YourIncomePost(vm, "testing");

            Assert.AreEqual("YourIncome", result.ViewName);
            Assert.AreEqual(vm, result.Model);
            Assert.IsTrue(vm.EnabledPartialSave);
        }
Пример #13
0
        public void ConvertTest_SourceNull()
        {
            IncomeVm             source      = null;
            IncomeAndExpenditure destination = Utilities.CreateDefaultTestIAndE();
            IncomeAndExpenditure expected    = Utilities.DeepCopy(destination);

            expected.BenefitsTotal          = 0;
            expected.BenefitsTotalFrequency = null;
            expected.Salary               = 0;
            expected.SalaryFrequency      = null;
            expected.OtherIncome          = 0;
            expected.OtherincomeFrequency = null;
            expected.Pension              = 0;
            expected.PensionFrequency     = null;

            IncomeAndExpenditure result = _converter.Convert(source, destination, null);

            //Check result is as expected
            Assert.IsTrue(Utilities.DeepCompare(expected, result));
        }
        public IActionResult YourIncome(IncomeVm viewModel)
        {
            ModelState.Clear();

            var id = RouteData.Values["id"];

            if (id == null)
            {
                return(RedirectToAction("Index", "MyAccounts"));
            }

            ApplicationSessionState.CheckSessionStatus(id.ToString());
            viewModel.EnabledPartialSave = _portalSettings.Features.EnablePartialSave && LoggedInUser.IsLoggedInUser;

            Guid guid = Guid.Parse(id.ToString());

            IncomeAndExpenditure incomeAndExpenditure = ApplicationSessionState.GetIncomeAndExpenditure(guid);

            _gtmService.RaiseBudgetCalculatorHouseholdDetailsEvent(viewModel, LoggedInUserId, incomeAndExpenditure?.HousingStatus, incomeAndExpenditure?.EmploymentStatus);

            viewModel = _mapper.Map(incomeAndExpenditure, viewModel);

            return(View(viewModel));
        }
 public ActionResult ExportIncomePdf(IncomeVm incomeVm)
 {
     return(new ActionAsPdf("IncomeReportPdf"));
 }
        public void ConvertTest()
        {
            IncomeAndExpenditure source = new IncomeAndExpenditure()
            {
                Mortgage             = 100,
                MortgageArrears      = 10,
                MortgageFrequency    = "monthly",
                Rental               = 150,
                RentalArrears        = 0,
                RentalFrequency      = "weekly",
                Electricity          = 200,
                ElectricityArrears   = 20,
                ElectricityFrequency = "fortnightly",
                CCJs                      = 250,
                CCJsArrears               = 0,
                CCJsFrequency             = "monthly",
                ChildMaintenance          = 300,
                ChildMaintenanceArrears   = 30,
                ChildMaintenanceFrequency = "weekly",
                CouncilTax                = 350,
                CouncilTaxArrears         = 0,
                CouncilTaxFrequency       = "fortnightly",
                CourtFines                = 400,
                CourtFinesArrears         = 40,
                CourtFinesFrequency       = "monthly",
                Gas                           = 450,
                GasArrears                    = 0,
                GasFrequency                  = "weekly",
                OtherUtilities                = 500,
                OtherUtilitiesArrears         = 50,
                OtherUtilitiesFrequency       = "fortnightly",
                Rent                          = 550,
                RentArrears                   = 0,
                RentFrequency                 = "monthly",
                SecuredLoans                  = 600,
                SecuredloansArrears           = 60,
                SecuredLoansFrequency         = "weekly",
                TvLicence                     = 650,
                TvLicenceArrears              = 0,
                TvLicenceFrequency            = "fortnightly",
                Water                         = 700,
                WaterArrears                  = 70,
                WaterFrequency                = "monthly",
                AdultsInHousehold             = 1,
                ChildrenUnder16               = 2,
                Children16to18                = 3,
                HasArrears                    = true,
                UtilitiesTotal                = 750,
                UtilitiesTotalArrears         = 0,
                UtilitiesTotalFrequency       = "weekly",
                User                          = "******",
                Created                       = DateTime.Now.Date,
                Healthcare                    = 800,
                HealthcareFrequency           = "fortnightly",
                HomeContents                  = 850,
                HomeContentsArrears           = 0,
                HomeContentsFrequency         = "monthly",
                EmploymentStatus              = "student",
                Housekeeping                  = 900,
                HousekeepingFrequency         = "monthly",
                HousingStatus                 = "homeowner",
                DisposableIncome              = 999.99M,
                BenefitsTotal                 = 888.88M,
                BenefitsTotalFrequency        = "monthly",
                Leisure                       = 50,
                LeisureFrequency              = "weekly",
                OtherDebts                    = new List <SaveOtherDebts>(),
                OtherExpenditure              = 60,
                OtherExpenditureFrequency     = "fortnightly",
                OtherIncome                   = 500,
                OtherincomeFrequency          = "monthly",
                LowellReference               = "123456789",
                EarningsTotal                 = 10000,
                EarningsTotalFrequency        = "monthly",
                PersonalCosts                 = 225,
                PersonalCostsFrequency        = "monthly",
                Pension                       = 400,
                PensionFrequency              = "monthly",
                Salary                        = 9999,
                SalaryFrequency               = "monthly",
                SavingsContributions          = 55,
                SavingsContributionsFrequency = "weekly",
                SchoolCosts                   = 5,
                SchoolCostsFrequency          = "weekly",
                Travel                        = 45,
                TravelFrequency               = "fortnightly",
                ProfessionalCosts             = 123,
                ProfessionalCostsFrequency    = "monthly",
                IncomeTotal                   = 1234.56M,
                PensionInsurance              = 75,
                PensionInsuranceFrequency     = "monthly",
                ExpenditureTotal              = 1000
            };

            //Create a copy of source for later
            IncomeAndExpenditure sourceCopy = Utilities.DeepCopy(source);

            IncomeVm destination = new IncomeVm()
            {
                BenefitsAndTaxCredits = new IncomeSourceVm()
                {
                    Amount = Int32.MaxValue, Frequency = "test"
                },
                Earning = new IncomeSourceVm()
                {
                    Amount = Int32.MaxValue, Frequency = "test"
                },
                Other = new IncomeSourceVm()
                {
                    Amount = Int32.MaxValue, Frequency = "test"
                },
                Pension = new IncomeSourceVm()
                {
                    Amount = Int32.MaxValue, Frequency = "test"
                },
                PartialSavedEvent         = true,
                EnabledPartialSave        = true,
                PartialSavedIAndE         = true,
                HasErrorPartialSavedIAndE = true,
                GtmEvents = new List <GtmEvent>()
                {
                    new GtmEvent()
                    {
                        account_ref = "test"
                    }
                }
            };

            IncomeVm expected = Utilities.DeepCopy(destination);

            expected.BenefitsAndTaxCredits.Amount    = 888.88M;
            expected.BenefitsAndTaxCredits.Frequency = "monthly";
            expected.Earning.Amount    = 9999;
            expected.Earning.Frequency = "monthly";
            expected.Other.Amount      = 500;
            expected.Other.Frequency   = "monthly";
            expected.Pension.Amount    = 400;
            expected.Pension.Frequency = "monthly";

            IncomeVm result = _converter.Convert(source, destination, null);

            //Check that the result is as expected
            Assert.IsTrue(Utilities.DeepCompare(expected, result));

            //Check that source hasn't been modified
            Assert.IsTrue(Utilities.DeepCompare(source, sourceCopy));
        }