public async Task <OperationResult <decimal> > CalculateTaxAsync(TaxYear taxYear, decimal annualIncome) { TaxYear = taxYear; await LoadSettingsAsync(); var baseValidationResult = BaseValidation(); if (baseValidationResult.HasErrors) { return(baseValidationResult); } var validationResult = Validate(); if (validationResult.HasErrors) { return(validationResult); } var taxAmountResult = CalculateTax(annualIncome); taxAmountResult.Response = RoundOffAmount(taxAmountResult.Response); return(taxAmountResult); }
public async Task GetTaxYearAsync_Should_Search_By_Date() { //Arrange DateTime requestDate = new DateTime(2020, 02, 20); DateTime expectedFromDate = new DateTime(2020, 01, 01); DateTime expectedToDate = new DateTime(2020, 12, 01); const string expectedTaxYearName = "2020 Tax Year"; var options = new DbContextOptionsBuilder <ApplicationContext>() .UseInMemoryDatabase(databaseName: GetType().Name + Guid.NewGuid()) .Options; await using var context = new ApplicationContext(options); var taxYear = new TaxYear() { FromDate = expectedFromDate, ToDate = expectedToDate, Name = expectedTaxYearName }; context.TaxYears.Add(taxYear); await context.SaveChangesAsync(); _repository = new TaxYearRepository(context); //Act var entity = await _repository.GetTaxYearAsync(requestDate); //Assert Assert.AreEqual(expectedFromDate, entity.FromDate); Assert.AreEqual(expectedToDate, entity.ToDate); Assert.AreEqual(expectedTaxYearName, entity.Name); }
public async Task CalculateTax_Should_Return_Error_When_No_Tax_Setting_Found() { //Arrange var taxYear = new TaxYear() { ToDate = new DateTime(2019, 10, 12), FromDate = new DateTime(2018, 10, 23), Name = "Tax year 1990" }; const int expectedErrorCount = 1; _repository.Setup(r => r.GetByTaxYearAsync(It.IsAny <TaxYear>())) .ReturnsAsync(new List <ProgressiveTaxRateSetting>()); //Act var operationResult = await _calculator.CalculateTaxAsync(taxYear, 100M); //Assert _repository.Verify(r => r.GetByTaxYearAsync(taxYear), Times.Once); Assert.IsTrue(operationResult.HasErrors); var errors = operationResult.GetErrorMessages(); Assert.AreEqual(expectedErrorCount, errors.Count); Assert.AreEqual(string.Empty, errors.Keys.First()); Assert.AreEqual("No Tax Rate setting have been found for the tax year: Tax year 1990 (23-Oct-2018 - 12-Oct-2019)", errors.Values.First().First()); }
public async Task CalculateTax_Should_Calculate_FlatRateTax_Correctly(decimal annualIncome, decimal flatRatePerc, decimal expectedTaxAmount) { //Arrange var taxYear = new TaxYear() { ToDate = new DateTime(2019, 10, 12), FromDate = new DateTime(2018, 10, 23), Name = "Tax year 1990" }; _repository.Setup(r => r.GetByTaxYearAsync(It.IsAny <TaxYear>())) .ReturnsAsync(new List <FlatRateSetting>() { new FlatRateSetting { FlatRatePerc = flatRatePerc } }); //Act var operationResult = await _calculator.CalculateTaxAsync(taxYear, annualIncome); //Assert _repository.Verify(r => r.GetByTaxYearAsync(taxYear), Times.Once); Assert.IsFalse(operationResult.HasErrors); Assert.AreEqual(expectedTaxAmount, operationResult.Response); }
public Task <IList <TTaxRateSetting> > GetByTaxYearAsync(TaxYear taxYear) { return(_cache.GetOrCreateAsync($"{GetType().Name}_{taxYear}", entry => { entry.SlidingExpiration = TimeSpan.FromSeconds(DefaultValues.CacheTimeInSeconds); return _settingRepository.GetByTaxYearAsync(taxYear); })); }
public ActionResult DeleteConfirmed(int id) { TaxYear taxYear = db.TaxYears.Find(id); db.TaxYears.Remove(taxYear); db.SaveChanges(); return(RedirectToAction("Index")); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { TaxYear TaxY = new TaxYear(_ConnStr); gvTaxYears.DataSource = TaxY.GetAllTaxYears(); gvTaxYears.DataBind(); } }
public ActionResult Edit([Bind(Include = "TaxYearId,Tax_Year,Default_Code")] TaxYear taxYear) { if (ModelState.IsValid) { db.Entry(taxYear).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(taxYear)); }
public ActionResult Create([Bind(Include = "TaxYearId,Tax_Year,Default_Code")] TaxYear taxYear) { if (ModelState.IsValid) { db.TaxYears.Add(taxYear); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(taxYear)); }
public ActionResult Create_Document() { List <TaxYear> taxlist = db.TaxYears.Where(a => a.Default_Code == true).ToList <TaxYear>(); TaxYear tax = new TaxYear(); tax = taxlist.FirstOrDefault(); string taxyear = tax.Tax_Year; ViewBag.Tax_Year = taxyear; return(View()); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { TaxYear TaxY = new TaxYear(_ConnStr, int.Parse(Request["year"].ToString())); lblTaxYear.Text = TaxY._TaxYear.ToString(); txtSDate.Text = TaxY.Start_DateTime.ToShortDateString(); txtEDate.Text = TaxY.End_DateTime.ToShortDateString(); txtEmail.Text = TaxY.SupportEmail.ToString(); txtPhone.Text = TaxY.SupportPhone.ToString(); } }
public void WhenSalaryIsZero_ShouldReturnZero(TaxYear taxYear) { // Arrange var taxRepo = new StubTaxRepository(); var taxHelper = new TaxHelper(taxYear, taxRepo); const int salaryExpected = 0; // Act var salaryResulted = taxHelper.Calculate(0); // Assert Assert.That(salaryResulted, Is.EqualTo(salaryExpected)); }
public void WhenSalaryIsZero_ShouldReturnZero(TaxYear taxYear) { //Arrange var taxRepo = new StubTaxRepository {TaxRate = 10}; var taxHelper = new TaxHelper(TaxYear.Year2013, taxRepo); const int salaryExpected = 0; //Act var salaryResulted = taxHelper.Calculate(0); //Assert Assert.That(salaryResulted, Is.EqualTo(salaryExpected)); }
// GET: TaxYear/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TaxYear taxYear = db.TaxYears.Find(id); if (taxYear == null) { return(HttpNotFound()); } return(View(taxYear)); }
private void GetDonorData(DataTable pDonorData) { try { ReportDataSource rdsMainRec = new ReportDataSource("TaxReceipt", pDonorData); rvTaxReceipt.LocalReport.DataSources.Clear(); rvTaxReceipt.LocalReport.DataSources.Add(rdsMainRec); TaxYear TYear = new TaxYear(_ConnStr); DataTable dtTaxYear = new DataTable(); dtTaxYear = TYear.GetTaxYear(int.Parse(Request["taxyear"].ToString())); ReportDataSource rdsTaxYear = new ReportDataSource("TaxYear", dtTaxYear); rvTaxReceipt.LocalReport.DataSources.Add(rdsTaxYear); // Create table with values DataTable dtData = new DataTable(); dtData.Clear(); dtData.Columns.Add("Donation_Date", typeof(DateTime)); dtData.Columns.Add("Amount", typeof(float)); if (pDonorData.Rows.Count > 0) { DataRow drRow = pDonorData.Rows[0]; for (int i = 1; i <= 25; i++) { try { float fltTry = float.Parse(drRow["AMOUNT_" + i.ToString()].ToString()); DataRow dr = dtData.NewRow(); dr["Donation_Date"] = drRow["DONATION_DATE_" + i.ToString()]; dr["Amount"] = drRow["AMOUNT_" + i.ToString()]; dtData.Rows.Add(dr); } catch { } } ReportDataSource rdsListRec = new ReportDataSource("TaxDataList", dtData); rvTaxReceipt.LocalReport.DataSources.Add(rdsListRec); } } catch (Exception EX) { } }
public void TimeIdentifiersAreAlikeWhenTheyAreEqual() { Assert.True(AcademicYear.IsAlike(AcademicYear)); Assert.True(CalendarYear.IsAlike(CalendarYear)); Assert.True(FinancialYear.IsAlike(FinancialYear)); Assert.True(TaxYear.IsAlike(TaxYear)); Assert.True(AcademicYearQ1.IsAlike(AcademicYearQ1)); Assert.True(CalendarYearQ1.IsAlike(CalendarYearQ1)); Assert.True(FinancialYearQ1.IsAlike(FinancialYearQ1)); Assert.True(TaxYearQ1.IsAlike(TaxYearQ1)); Assert.True(January.IsAlike(January)); Assert.True(SpringTerm.IsAlike(SpringTerm)); Assert.True(ReportingYear.IsAlike(ReportingYear)); Assert.True(Week1.IsAlike(Week1)); Assert.True(FinancialYearPart1.IsAlike(FinancialYearPart1)); }
protected void btnSave_Click(object sender, EventArgs e) { try { TaxYear TaxY = new TaxYear(_ConnStr, int.Parse(Request["year"].ToString())); TaxY.Start_DateTime = DateTime.Parse(txtSDate.Text.ToString()); TaxY.End_DateTime = DateTime.Parse(txtEDate.Text.ToString()); TaxY.SupportEmail = txtEmail.Text.ToString(); TaxY.SupportPhone = txtPhone.Text.ToString(); TaxY.Update(); } catch (Exception EX) { lblMessage.Text = EX.Message; } }
public async Task CalculateTax_Should_Calculate_FlatRateTax_Correctly(decimal annualIncome, decimal expectedTaxAmount) { //Arrange var taxYear = new TaxYear() { ToDate = new DateTime(2019, 10, 12), FromDate = new DateTime(2018, 10, 23), Name = "Tax year 1990" }; _repository.Setup(r => r.GetByTaxYearAsync(It.IsAny <TaxYear>())) .ReturnsAsync(new List <ProgressiveTaxRateSetting> { new ProgressiveTaxRateSetting { FromAmount = 0M, ToAmount = 205900M, TaxRatePerc = 18M }, new ProgressiveTaxRateSetting { FromAmount = 205901M, ToAmount = 321600M, TaxRatePerc = 26M }, new ProgressiveTaxRateSetting { FromAmount = 321601M, ToAmount = 445100M, TaxRatePerc = 31M }, new ProgressiveTaxRateSetting { FromAmount = 445101M, ToAmount = 584200M, TaxRatePerc = 36M }, new ProgressiveTaxRateSetting { FromAmount = 584201M, ToAmount = 744800M, TaxRatePerc = 39M }, new ProgressiveTaxRateSetting { FromAmount = 744801M, ToAmount = 1577300M, TaxRatePerc = 41M }, new ProgressiveTaxRateSetting { FromAmount = 1577301M, ToAmount = null, TaxRatePerc = 45M }, }); //Act var operationResult = await _calculator.CalculateTaxAsync(taxYear, annualIncome); //Assert _repository.Verify(r => r.GetByTaxYearAsync(taxYear), Times.Once); Assert.IsFalse(operationResult.HasErrors); Assert.AreEqual(expectedTaxAmount, operationResult.Response); }
protected override void Seed(DatabaseContext context) { var employee = new Employee() { EmployeeNo = "1", FirstName = "ali", LastName = "boz", City = "bursa", Address = "adress", Postcode = "123", NationalInsuranceNo = "123", DOB = DateTime.Now, DateJoined = DateTime.Now }; var c = context.Employees.Add(employee); var x = context.SaveChanges(); var taxyears = new TaxYear() { YearOfTax = "2020" }; var taxyears2 = new TaxYear() { YearOfTax = "2022" }; var t = context.TaxYears.Add(taxyears); var t2 = context.TaxYears.Add(taxyears2); var login = new Login() { Username = "******", Password = "******" }; context.Login.Add(login); var y = context.SaveChanges(); }
public async Task GetTaxYearAsync_Should_Throw_Exception_For_Duplicated_Years() { //Arrange DateTime requestDate = new DateTime(2020, 02, 20); DateTime expectedFromDate = new DateTime(2020, 01, 01); DateTime expectedToDate = new DateTime(2020, 12, 01); const string expectedTaxYearName = "2020 Tax Year"; var options = new DbContextOptionsBuilder <ApplicationContext>() .UseInMemoryDatabase(databaseName: GetType().Name + Guid.NewGuid()) .Options; await using var context = new ApplicationContext(options); var taxYear = new TaxYear() { FromDate = expectedFromDate, ToDate = expectedToDate, Name = expectedTaxYearName }; context.TaxYears.Add(taxYear); var taxYear2 = new TaxYear() { FromDate = expectedFromDate, ToDate = expectedToDate, Name = expectedTaxYearName }; context.TaxYears.Add(taxYear2); await context.SaveChangesAsync(); _repository = new TaxYearRepository(context); //Act & Assert Assert.ThrowsAsync <InvalidOperationException>(async() => await _repository.GetTaxYearAsync(requestDate)); }
public static async Task GetTaxYearAsync_Should_Search_By_Date <TTaxSetting>() where TTaxSetting : BaseTaxRateSetting, new() { //Arrange var options = new DbContextOptionsBuilder <ApplicationContext>() .UseInMemoryDatabase(databaseName: "TaxRateSettingRepositoryTests" + Guid.NewGuid()) .Options; await using var context = new ApplicationContext(options); var taxYear = new TaxYear() { FromDate = new DateTime(2020, 01, 01), ToDate = new DateTime(2020, 12, 01), Name = "2020 Tax Year" }; context.TaxYears.Add(taxYear); var taxRateSetting = new TTaxSetting { TaxYear = taxYear }; context.Set <TTaxSetting>().Add(taxRateSetting); await context.SaveChangesAsync(); var repository = new TaxRateSettingRepository <TTaxSetting>(context); //Act var entity = await repository.GetByTaxYearAsync(taxYear); //Assert CollectionAssert.AreEqual(new List <TTaxSetting> { taxRateSetting }, entity); }
protected void Page_Load(object sender, EventArgs e) { lblMessage.Text = ""; intTaxYear = DateTime.Now.Year - 1; TaxYear TaxY = new TaxYear(_ConnStr, intTaxYear); lblYear.Text = TaxY._TaxYear.ToString(); lblYear2.Text = TaxY._TaxYear.ToString(); lblYear3.Text = TaxY._TaxYear.ToString(); DateTime dtStart = DateTime.Parse(TaxY.Start_DateTime.ToString()); lblStartDate.Text = TaxY.Start_DateTime.ToShortDateString(); DateTime dtEnd = DateTime.Parse(TaxY.End_DateTime.ToString()); lblEndDate.Text = TaxY.End_DateTime.ToShortDateString(); lblDateGood.Text = dtEnd.ToString("MMMM") + " " + dtEnd.Day.ToString() + ", " + dtEnd.Year.ToString(); lblPhone.Text = TaxY.SupportPhone.ToString(); lblPhone2.Text = TaxY.SupportPhone.ToString(); hlEmail.NavigateUrl = "mailto:" + TaxY.SupportEmail.ToString(); hlEmail.Text = TaxY.SupportEmail.ToString(); hlEmail2.NavigateUrl = "mailto:" + TaxY.SupportEmail.ToString(); if (dtStart < DateTime.Now && dtEnd > DateTime.Now) { pnlReceipt.Visible = true; pnOther.Visible = false; } else { pnlReceipt.Visible = false; pnOther.Visible = true; } }
public async Task <IActionResult> Create(TaxYearCreateViewModel model) { var taxYearRepo = _unitOfWork.TaxYearRepository.Find(x => x.YearOfTax == model.YearOfTax); if (taxYearRepo != null) { Alert("Tax year already exist!", NotificationType.error); } var taxYear = new TaxYear() { Id = model.Id, YearOfTax = model.YearOfTax }; await _unitOfWork.TaxYearRepository.AddAsync(taxYear); if (await _unitOfWork.SaveAsync()) { Alert("Successfully created!", NotificationType.success); } return(RedirectToAction(nameof(Index))); }
public static void Initialize(ApplicationContext context) { context.Database.EnsureCreated(); if (context.TaxYears.Any()) { return; // DB has been seeded } var createdBy = Guid.Parse("9353e4af-3686-4f22-9ee5-bc1ea819f676"); var taxYear = new TaxYear { CreatedBy = createdBy, CreationDate = DateTime.UtcNow, FromDate = new DateTime(2020, 03, 01), ToDate = new DateTime(2021, 02, 28, 23, 59, 59), Name = "2021 tax year" }; context.TaxYears.AddRange(taxYear); context.SaveChanges(); var postalCodeMappings = new[] { new PostalCodeCalculationTypeMapping { CalculationType = TaxCalculationType.PROGRESSIVE_TAX, PostalCode = "7441", CreationDate = DateTime.UtcNow, CreatedBy = createdBy }, new PostalCodeCalculationTypeMapping { CalculationType = TaxCalculationType.FLAT_VALUE, PostalCode = "A100", CreationDate = DateTime.UtcNow, CreatedBy = createdBy }, new PostalCodeCalculationTypeMapping { CalculationType = TaxCalculationType.FLAT_RATE, PostalCode = "7000", CreationDate = DateTime.UtcNow, CreatedBy = createdBy }, new PostalCodeCalculationTypeMapping { CalculationType = TaxCalculationType.PROGRESSIVE_TAX, PostalCode = "1000", CreationDate = DateTime.UtcNow, CreatedBy = createdBy } }; context.PostalCodeCalculationTypeMappings.AddRange(postalCodeMappings); context.SaveChanges(); var flatRateSettings = new [] { new FlatRateSetting { FlatRatePerc = 17.5M, TaxYear = taxYear, CreatedBy = createdBy, CreationDate = DateTime.UtcNow }, }; context.FlatRateSettings.AddRange(flatRateSettings); context.SaveChanges(); var flatValueSettings = new[] { new FlatValueSetting { LowIncomeThreshold = 200000M, LowIncomeTaxRatePerc = 5M, HighIncomeTaxAmount = 10000M, TaxYear = taxYear, CreatedBy = createdBy, CreationDate = DateTime.UtcNow }, }; context.FlatValueSettings.AddRange(flatValueSettings); context.SaveChanges(); var progressiveTaxSettings = new[] { new ProgressiveTaxRateSetting { TaxYear = taxYear, FromAmount = 0M, ToAmount = 8350M, TaxRatePerc = 10M, CreatedBy = createdBy, CreationDate = DateTime.UtcNow }, new ProgressiveTaxRateSetting { TaxYear = taxYear, FromAmount = 8351M, ToAmount = 33950M, TaxRatePerc = 15M, CreatedBy = createdBy, CreationDate = DateTime.UtcNow }, new ProgressiveTaxRateSetting { TaxYear = taxYear, FromAmount = 33951M, ToAmount = 82250M, TaxRatePerc = 25M, CreatedBy = createdBy, CreationDate = DateTime.UtcNow }, new ProgressiveTaxRateSetting { TaxYear = taxYear, FromAmount = 82251M, ToAmount = 171550M, TaxRatePerc = 28M, CreatedBy = createdBy, CreationDate = DateTime.UtcNow }, new ProgressiveTaxRateSetting { TaxYear = taxYear, FromAmount = 171551M, ToAmount = 372950M, TaxRatePerc = 33M, CreatedBy = createdBy, CreationDate = DateTime.UtcNow }, new ProgressiveTaxRateSetting { TaxYear = taxYear, FromAmount = 372951M, ToAmount = null, TaxRatePerc = 35M, CreatedBy = createdBy, CreationDate = DateTime.UtcNow }, }; context.ProgressiveTaxSettings.AddRange(progressiveTaxSettings); context.SaveChanges(); }
public int GetTaxRate(TaxYear taxYear) { // To Do return(-1); }
public async Task CalculateTax_Should_Successfully_Calculate_Tax() { //Arrange const string postalCode = "12234"; const decimal incomeAmount = 23000M; var requestDate = new DateTime(2020, 12, 15); var calculationRequest = new TaxCalculationRequest() { AnnualIncome = incomeAmount, PostalCode = postalCode }; const int expectedTaxAmount = 100; const TaxCalculationType expectedCalculationType = TaxCalculationType.PROGRESSIVE_TAX; const string expectedTaxYear = "Tax Year (01-Jan-2020 - 02-Jan-2021)"; var taxYear = new TaxYear { FromDate = new DateTime(2020, 01, 01), ToDate = new DateTime(2021, 01, 02), Name = "Tax Year" }; var taxCalculationResult = new OperationResult <decimal> { Response = expectedTaxAmount }; _clock.Setup(c => c.GetCurrentDateTime()).Returns(requestDate); _validationRuleEngine.Setup(s => s.Validate(It.IsAny <TaxCalculationRequest>())) .Returns(new OperationResult <TaxCalculationResponse>()); _calculationMappingRepository.Setup(f => f.GetByPostalCodeAsync(It.IsAny <string>())) .ReturnsAsync(new PostalCodeCalculationTypeMapping { CalculationType = expectedCalculationType }); _taxCalculatorFactory.Setup(f => f.GetCalculator(It.IsAny <TaxCalculationType>())) .Returns(_taxCalculator.Object); _taxYearRepository.Setup(t => t.GetTaxYearAsync(It.IsAny <DateTime>())) .ReturnsAsync(taxYear); _taxCalculator.Setup(t => t.CalculateTaxAsync(It.IsAny <TaxYear>(), It.IsAny <decimal>())) .ReturnsAsync(taxCalculationResult); //Act var operationResult = await _calculatorManager.CalculateTax(calculationRequest); //Assert Assert.IsNotNull(operationResult?.Response); Assert.IsFalse(operationResult.HasErrors); _validationRuleEngine.Verify(s => s.Validate(calculationRequest), Times.Once); _calculationMappingRepository.Verify(f => f.GetByPostalCodeAsync(postalCode), Times.Once); _taxCalculatorFactory.Verify(f => f.GetCalculator(expectedCalculationType), Times.Once); _taxYearRepository.Verify(t => t.GetTaxYearAsync(requestDate), Times.Once); _taxCalculator.Verify(t => t.CalculateTaxAsync(taxYear, incomeAmount), Times.Once()); Assert.AreEqual(expectedTaxAmount, operationResult.Response.TaxAmount); Assert.AreEqual(expectedCalculationType, operationResult.Response.CalculationType); Assert.AreEqual(expectedTaxYear, operationResult.Response.TaxYear); }
public int GetTaxRate(TaxYear taxYear) { //ToDo return -1; }
public int GetTaxRate(TaxYear taxYear) { return TaxRate; }
public async Task CalculateTax_Should_Save_Successfully_Calculated_Tax() { //Arrange const string expectedPostalCode = "12234"; const decimal expectedAnnualIncome = 23000M; const int expectedTaxAmount = 100; const TaxCalculationType expectedCalculationType = TaxCalculationType.PROGRESSIVE_TAX; DateTime expectedCreationDate = new DateTime(2020, 12, 16); Guid expectedRequestedBy = Guid.Parse("e64a32e6-f2a9-43d5-b87b-79c845955f93"); var calculationRequest = new TaxCalculationRequest() { AnnualIncome = expectedAnnualIncome, PostalCode = expectedPostalCode, RequestedBy = expectedRequestedBy }; TaxCalculation savedRecord = null; var taxYear = new TaxYear { FromDate = new DateTime(2020, 01, 01), ToDate = new DateTime(2021, 01, 02), Name = "Tax Year" }; var taxCalculationResult = new OperationResult <decimal> { Response = expectedTaxAmount }; _clock.Setup(c => c.GetCurrentDateTime()).Returns(expectedCreationDate); _validationRuleEngine.Setup(s => s.Validate(It.IsAny <TaxCalculationRequest>())) .Returns(new OperationResult <TaxCalculationResponse>()); _calculationMappingRepository.Setup(f => f.GetByPostalCodeAsync(It.IsAny <string>())) .ReturnsAsync(new PostalCodeCalculationTypeMapping { CalculationType = expectedCalculationType }); _taxCalculatorFactory.Setup(f => f.GetCalculator(It.IsAny <TaxCalculationType>())) .Returns(_taxCalculator.Object); _taxYearRepository.Setup(t => t.GetTaxYearAsync(It.IsAny <DateTime>())) .ReturnsAsync(taxYear); _taxCalculator.Setup(t => t.CalculateTaxAsync(It.IsAny <TaxYear>(), It.IsAny <decimal>())) .ReturnsAsync(taxCalculationResult); _calculationRepository.Setup(r => r.AddAsync(It.IsAny <TaxCalculation>())) .Callback((TaxCalculation c) => savedRecord = c); //Act var operationResult = await _calculatorManager.CalculateTax(calculationRequest); //Assert Assert.IsNotNull(operationResult?.Response); Assert.IsFalse(operationResult.HasErrors); _calculationRepository.Verify(r => r.AddAsync(It.IsAny <TaxCalculation>()), Times.Once); Assert.IsNotNull(savedRecord); Assert.AreEqual(expectedAnnualIncome, savedRecord.AnnualIncome); Assert.AreEqual(expectedTaxAmount, savedRecord.TaxAmount); Assert.AreEqual(expectedCalculationType, savedRecord.CalculationType); Assert.AreEqual(expectedRequestedBy, savedRecord.CreatedBy); Assert.AreEqual(expectedCreationDate, savedRecord.CreationDate); Assert.AreEqual(expectedPostalCode, savedRecord.PostalCode); Assert.AreEqual(taxYear, savedRecord.TaxYear); }
public int GetTaxRate(TaxYear taxYear) { return(TaxRate); }
public override int GetTaxRate(TaxYear taxYear) { return TaxRate; }
public override int GetTaxRate(TaxYear taxYear) { return(TaxRate); }
public TaxHelper(TaxYear taxYear, ITaxRepository taxRepo) { this._taxYear = taxYear; this._taxRepo = taxRepo; }
public TaxHelper(TaxYear taxYear, ITaxRepository taxRepo) { this._taxYear = taxYear; this._taxRepo = taxRepo; }
public virtual int GetTaxRate(TaxYear taxYear) { //ToDo return -1; }
private async Task SaveCalculation(TaxCalculationRequest request, TaxCalculationResponse response, TaxYear taxYear) { var calculation = new TaxCalculation { AnnualIncome = request.AnnualIncome, TaxAmount = response.TaxAmount, CalculationType = response.CalculationType, CreatedBy = request.RequestedBy, CreationDate = _clock.GetCurrentDateTime(), PostalCode = request.PostalCode, TaxYear = taxYear }; await _calculationRepository.AddAsync(calculation).ConfigureAwait(false); }