public IActionResult Index(TaxViewModel taxViewModel) { if (ModelState.IsValid) { var taxCalculatedResponse = _taxCalculation.CalculationIncomeTax(taxViewModel); if (taxCalculatedResponse != null) { var taxCalculationModel = new Models.DbModel.TaxCalculation { AnnualIncome = (decimal)taxViewModel.AnnualIncome, Name = taxViewModel.Name.ToLower(), TaxCalculated = (decimal)taxCalculatedResponse.CalculatedTax, CalculationType = taxCalculatedResponse.CalculationType.ToLower(), DateCreated = DateTime.Now }; var hasSaved = _sqlRepository.Save(taxCalculationModel); //this is just to send a message to rabbitMQ //disable this if you do not have a local instance of rabbit installed :) if (doRabbitPublish) { _publisher.PublishMessage(taxCalculationModel); } } } return(RedirectToAction("Index", "Data")); }
public ActionResult Edit(int id) { Tax tax = new Tax(); TaxViewModel model = new TaxViewModel(); tax = taxDal.ReadTaxById(id); model.TaxId = tax.TaxId; model.TaxName = tax.TaxName; model.Value = tax.Value; var lst = taxDal.ReadAllTax(); model.lst = new List <TaxViewModel>(); model.lst = lst.ConvertAll(x => new TaxViewModel { TaxId = x.TaxId, TaxName = x.TaxName, Value = x.Value }); model.IsEdit = true; return(View("Index", model)); }
public JsonResult GetTaxes(TaxViewModel tViewModel) { PaginationInfo pager = new PaginationInfo(); pager = tViewModel.Pager; PaginationViewModel pViewModel = new PaginationViewModel(); try { pViewModel.dt = _tRepo.GetTaxes(tViewModel.Filter.TaxName, tViewModel.Filter.IsActive, ref pager); pViewModel.Pager = pager; Logger.Debug("Tax Controller GetTaxes"); } catch (Exception ex) { tViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01")); Logger.Error("Tax Controller - GetTaxes" + ex.ToString()); } return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> AddTax(TaxViewModel input) { if (ModelState.IsValid) { var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } await _userTaxRepository.AddUserTax(new UserTax { UserId = user.Id, CharityPaidAmount = input.CharityPaidAmount.Value, TotalIncome = input.TotalIncome.Value, NumberOfChildren = input.NumberOfChildren.Value, Year = input.Year.Value, TaxDueAmount = _taxService.CalculateTax(input.Year.Value, input.NumberOfChildren.Value, input.CharityPaidAmount.Value, input.TotalIncome.Value) }); _logger.LogInformation("New Tax Created"); return(LocalRedirect($"/Tax/getTax?year={input.Year}")); } return(View(input)); }
public async Task AddTax_SubmitInvalidYear_ThrowValidation() { // Arrange var taxViewModel = new TaxViewModel { CharityPaidAmount = 10, NumberOfChildren = 1, TotalIncome = 10000, Year = 0 }; var taxViewModelData = taxViewModel.ToDictionary(); // Act await UserManager.CreateAsync(new ApplicationUser { Email = Email, UserName = Email }, Password); var response = await PostAsync(AddTaxUrl, taxViewModelData, Email, Password); var responseContent = await response.Content.ReadAsStringAsync(); var taxResult = await UserTaxRepository.GetUserTax(User.Id, taxViewModel.Year.Value); //Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); // checking no data is inserted Assert.Null(taxResult); Assert.Contains("The field Tax Year must be between 2000 and 2020.", responseContent); }
public ActionResult Index(TaxViewModel model) { Tax tax = new Tax(); if (ModelState.IsValid) { tax.TaxName = model.TaxName; tax.Value = Convert.ToDecimal(model.Value); tax.CreatedBy = "Admin"; tax.CreatedOn = DateTime.Now; taxDal.Create(tax); TempData["SuccessMsg"] = "Tax Created Successfully"; return(RedirectToAction("Index")); } var lst = taxDal.ReadAllTax(); model.lst = new List <TaxViewModel>(); model.lst = lst.ConvertAll(x => new TaxViewModel { TaxId = x.TaxId, TaxName = x.TaxName, Value = x.Value }); model.IsEdit = false; return(View(model)); }
public async Task <IActionResult> GetTax(int?year) { if (!year.HasValue) { _logger.LogError("no year is provided"); throw new ApplicationException("Year must be provided"); } var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var userTax = await _userTaxRepository.GetUserTax(user.Id, year.Value); var result = new TaxViewModel { CharityPaidAmount = userTax.CharityPaidAmount, NumberOfChildren = userTax.NumberOfChildren, TotalIncome = userTax.TotalIncome, Year = userTax.Year, TaxDueAmount = userTax.TaxDueAmount }; return(View(result)); }
public AddTax() { TaxViewModel ViewModel; InitializeComponent(); ViewModel = new TaxViewModel(); this.DataContext = ViewModel; }
public IHttpActionResult Get() { var vm = new TaxViewModel(); vm.HandleRequest(); vm.IsValid = true; return(Ok(vm)); }
// GET: DonorTax/Home public ActionResult Index() { var vm = new TaxViewModel(); vm.HandleRequest(); vm.IsValid = true; return(View(vm)); }
public IActionResult Index(TaxViewModel model) { var command = new CalculateTaxCommand(); model.Tax = command.CalculateTax(model.TaxCode, model.Income); return(View(model)); }
public ActionResult Index(TaxViewModel tViewModel) { if (TempData["tViewModel"] != null) { tViewModel = (TaxViewModel)TempData["tViewModel"]; } return(View("Index", tViewModel)); }
void TaxViewController_Loaded(object sender, RoutedEventArgs e) { taxViewModel = new TaxViewModel(); taxViewModel.LoadTCodeEntitys(); taxViewModel.LoadTaxClass(); taxViewModel.ViewSource.Source = taxViewModel.GoodsTaxRates; this.DataContext = taxViewModel; }
public TaxViewModel DisplayTaxes() { TaxViewModel taxViewModel = new TaxViewModel(); Tax taxList = db.Taxes.Single(); taxViewModel.CGST = (float)taxList.CGST; taxViewModel.SGST = (float)taxList.SGST; taxViewModel.ServiceTax = (float)taxList.ServiceTax; return(taxViewModel); }
public ActionResult Edit(TaxViewModel tax) { if (ModelState.IsValid) { var entity = Mapper.Map <Tax>(tax); taxService.Update(entity); return(RedirectToAction("Index")); } return(View(tax)); }
/// <summary> /// Add Tax Method updates tax table with new values /// </summary> /// <param name="tax"></param> /// <returns></returns> public bool AddTax(TaxViewModel tax) { Tax taxConfig = db.Taxes.FirstOrDefault(); taxConfig.CGST = tax.CGST; taxConfig.SGST = tax.SGST; taxConfig.ServiceTax = tax.ServiceTax; db.Entry(taxConfig).State = EntityState.Modified; db.SaveChanges(); return(true); }
public override List <TaxViewModel> ParseFile(string fileName, System.IO.Stream inputStream) { StreamReader csvreader = new StreamReader(inputStream); List <TaxViewModel> modelList = new List <TaxViewModel>(); for (int i = 0; i < 5; i++) { csvreader.ReadLine(); } try { while (!csvreader.EndOfStream) { var line = csvreader.ReadLine(); if (String.IsNullOrEmpty(line)) { break; } var values = line.Split(';'); var taxModel = new TaxViewModel(); taxModel.DocumentName = fileName; if (!string.IsNullOrEmpty(values[0])) { taxModel.Account = values[0]; } if (!string.IsNullOrEmpty(values[1])) { taxModel.Description = values[1]; } if (!string.IsNullOrEmpty(values[2])) { taxModel.CurrencyCode = values[2]; } if (!string.IsNullOrEmpty(values[3])) // if (decimal.TryParse(values[3], out amount)) { taxModel.Amount = values[3]; } modelList.Add(taxModel); } } catch (Exception ex) { throw new Exception(ex.Message); } finally { csvreader.Close(); } return(modelList); }
private static void SetPostalCode(TaxViewModel viewModel, List <PostalCode> postalCodes) { foreach (var tax in viewModel.Taxes) { var postalCode = postalCodes.FirstOrDefault(p => p.Id == int.Parse(tax.PostalCode)); if (postalCode != null) { tax.PostalCode = postalCode.Code; } } }
private async Task <string> SetCalculationType(string result, TaxViewModel viewModel) { foreach (var tax in viewModel.Taxes) { result = await HttpClientGet($"calctype/gettypebypostalcode?Id={tax.PostalCode}"); var calculationType = JsonConvert.DeserializeObject <CalculationType>(result); tax.CalculationType = calculationType.Description; } return(result); }
public TaxViewModel GetTaxInfo() { Tax t = _context.Tax.First(); // det går också att använda ett anonymt objekt TaxViewModel tax = new TaxViewModel() { ActualTax = t.ActualTax, TotalPayed = t.TotalPayed }; return(tax); }
public ActionResult GetTax(int?id) { //var tax = ComputePaye((double)id); var tax = _payeRepo.ComputePaye((double)id); var d = new TaxViewModel { Tax = _payeRepo.Dictionary }; ViewBag.TotalTax = _payeRepo.TotalTax; ViewBag.FinalBalance = _payeRepo.FinalBalance; return(View(d)); }
public TaxList() { InitializeComponent(); ViewModel = new TaxViewModel(); this.DataContext = ViewModel; //dataGrid.ItemsSource = ListGrid1; //CatGridRef = dataGrid; dataGrid.ItemsSource = ListGrid; ListGridRef = dataGrid; dataGrid1.ItemsSource = ListGridBuss; ListGrdMainRef = dataGrid1; }
// GET: Taxes/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TaxViewModel tax = Mapper.Map <TaxViewModel>(taxService.Get(id.Value)); if (tax == null) { return(HttpNotFound()); } return(View(tax)); }
public ActionResult Continue(TaxViewModel model) { var tax = db.Taxes.Where(m => m.Name.Equals(model.Name)).FirstOrDefault(); if (tax != null) { model.Iban = tax.TaxIban; return(View("TaxConfirmation", model)); } else { return(RedirectToAction("Home", "Home")); } }
public CalculationResponse CalculationIncomeTax(TaxViewModel taxViewModel) { var annualIncome = taxViewModel.AnnualIncome; var postalCode = _sqlRepository.GetPostalCode(taxViewModel.PostalCode); var taxType = _sqlRepository .GetCalculationType(postalCode.TaxTypeId) .TaxTypeName; taxType = taxType.Replace(" ", "").ToLower(); switch (taxType) { case _flatValue: { _taxCalculator = new FlatValueTaxCalculator(); var tax = _taxCalculator.CalcualtionTax(annualIncome); return(new CalculationResponse { CalculatedTax = tax, CalculationType = taxType }); } case _flatRate: { _taxCalculator = new FlatRateTaxCalculator(); var tax = _taxCalculator.CalcualtionTax(annualIncome); return(new CalculationResponse { CalculatedTax = tax, CalculationType = taxType }); } case _progressive: { var rates = _sqlRepository.GetRates().ToList(); _taxCalculator = new ProgressiveTaxCalculator(rates); var tax = _taxCalculator.CalcualtionTax(annualIncome); return(new CalculationResponse { CalculatedTax = tax, CalculationType = taxType }); } default: return(null); } }
public ActionResult TaxConfig(TaxViewModel taxView) { if (taxView == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } bool flag = manage.AddTax(taxView); if (flag == true) { return(RedirectToAction("Dashboard")); } else { return(HttpNotFound()); } }
public ActionResult Index() { var lst = taxDal.ReadAllTax(); TaxViewModel taxViewModel = new TaxViewModel(); taxViewModel.lst = new List <TaxViewModel>(); taxViewModel.lst = lst.ConvertAll(x => new TaxViewModel { TaxId = x.TaxId, TaxName = x.TaxName, Value = x.Value }); taxViewModel.IsEdit = false; return(View(taxViewModel)); }
public void AddTax_InvalidInput_ThrowValidation() { // Arrange var model = new TaxViewModel(); var context = new ValidationContext(model, null, null); var result = new List <ValidationResult>(); // Act var valid = Validator.TryValidateObject(model, context, result, true); // Assert Assert.False(valid); Assert.Equal(4, result.Count); Assert.Contains(result, i => i.ErrorMessage == "The Tax Year field is required."); Assert.Contains(result, i => i.ErrorMessage == "The Total Income field is required."); Assert.Contains(result, i => i.ErrorMessage == "The Charity Paid Amount field is required."); Assert.Contains(result, i => i.ErrorMessage == "The Number Of Children field is required."); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { TaxViewModel tmodel = ((TaxViewModel)validationContext.ObjectInstance); var currentcode = tmodel.CurrencyCode; if ((from culture in System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.InstalledWin32Cultures) where culture.Name.Length > 0 && !culture.IsNeutralCulture let region = new System.Globalization.RegionInfo(culture.LCID) where String.Equals(region.ISOCurrencySymbol, currentcode, StringComparison.InvariantCultureIgnoreCase) select region).FirstOrDefault() == null) { string[] memberNames = new string[] { validationContext.MemberName }; return(new ValidationResult("Currency code is not valid", memberNames)); } return(ValidationResult.Success); }
public ActionResult Create(TaxViewModel model) { if (ModelState.IsValid) { var tax = db.Taxes.Where(m => m.Name.Equals(model.Name)).FirstOrDefault(); var accountSrc = db.Accounts.Where(m => m.Iban.Equals(model.SenderIban)).FirstOrDefault(); if (tax != null && accountSrc != null) { if (accountSrc.Balance > (double)model.Amount) { if (accountSrc.CardLimit < (double)(accountSrc.Balance - (double)model.Amount)) { var transaction = new Transaction((double)model.Amount, "out", accountSrc.AccountId, 0, model.SaveToMyServices, model.Details, model.TransactionName); accountSrc.Transactions.Add(transaction); accountSrc.Balance -= (double)model.Amount; if (!string.IsNullOrEmpty(model.TransactionName)) { model.SaveToMyServices = true; transaction.SaveToMyTransfers = true; } transaction.Created = DateTime.Now; db.Transactions.Add(transaction); db.SaveChanges(); return(RedirectToAction("Home", "Home")); } else { return(View("ErrorInsufficientFunds")); } } else { return(View("ErrorInsufficientFunds")); } } else { return(View("ErrorDestOrSourceAccountNotFound")); } } return(View("Error")); }