public async Task <TaxForm> CreateNewTaxFormAsync(int TaxYear) { try { var Anyexisting = _db.TaxForms.Any(c => c.TaxYear == TaxYear && c.isFiled == false); if (Anyexisting) { return(_db.TaxForms.First(c => c.TaxYear == TaxYear && c.isFiled == false)); } TaxForm t = new TaxForm(); var userID = _httpContextAccessor.HttpContext.User.Claims.First().Value; t.TaxYear = TaxYear; t.FilingStatus = "Continue"; t.UserID = userID; t.Person = _db.Person.Where(c => c.UserId == userID).First(); t.FilingStatusID = _db.FilingStatus.First(c => c.Name == "GetStarted").Id; _db.TaxForms.Add(t); await _db.SaveChangesAsync(); return(t); } catch (Exception e) { throw; } }
private static decimal GetCP(TaxForm form, decimal rateUSD, decimal rateEUR) { decimal carPrice = 0; decimal transportationUAH = 0; switch (form.CarPriceCurrency) { case CurrencyType.USD: carPrice = form.CarPrice * rateUSD; break; case CurrencyType.EUR: carPrice = form.CarPrice * rateEUR; break; } switch (form.TransportToUABorderCurrency) { case CurrencyType.USD: transportationUAH = form.TransportToUABorderCost * rateUSD; break; case CurrencyType.EUR: transportationUAH = form.TransportToUABorderCost * rateEUR; break; } return(carPrice + transportationUAH); }
public ActionResult Create(int selectedyear) { try { if (!_db.TaxForms.Any(c => c.TaxYear == selectedyear && c.UserID == User.Claims.First().Value)) { var f = _db.FilingStatus.First(c => c.Name == "GetStarted"); TaxForm t = new TaxForm(); t.UserID = User.Claims.First().Value; t.TaxYear = selectedyear; t.isFiled = false; t.Person = _db.Person.First(c => c.UserId == User.Claims.First().Value); t.Filingstatus = f; t.FilingStatus = "GetStarted"; t.FilingStatusID = f.Id; t.CreatedOn = DateTime.Now; t.UpdatedOn = DateTime.Now; _db.Add(t); _db.SaveChanges(); return(RedirectToAction(nameof(Create), new { id = t.ID, status = "GetStarted" })); } else { var t = _db.TaxForms.First(c => c.TaxYear == selectedyear && c.UserID == User.Claims.First().Value); return(RedirectToAction(nameof(Create), new { id = t.ID, status = "Continue" })); } } catch (Exception) { return(View()); } }
private static decimal GetKE(TaxForm form, decimal rateEUR) { switch (form.CarEngineType) { case EngineType.Petrol: if (form.EngineVolume <= 3000) { return((50m * form.EngineVolume / 1000m) * rateEUR); } else { return((100m * form.EngineVolume / 1000m) * rateEUR); } case EngineType.Diesel: if (form.EngineVolume <= 3500) { return((75m * form.EngineVolume / 1000m) * rateEUR); } else { return((150m * form.EngineVolume / 1000m) * rateEUR); } case EngineType.Hybrid: return(100m * rateEUR); case EngineType.Electro: return(form.EngineVolume * rateEUR); default: return(0); } }
public void Init(ApplicationDbContext db) { _db = db; CurrentTaxForm = new TaxForm(); CurrentUser = new Person(); Address = new Address(); CriteriaOptions = new List <CriteriaOption>(); Dependent = new Dependent(); }
public ReportData() { taxtForm = new TaxForm(); dependent = new List <Dependent>(); filingStatus = new FilingStatus(); taxFormAddress = new TaxFormAddress(); taxFormCriteria = new TaxFormCriteria(); taxFormAddress = new TaxFormAddress(); CareProvider = new DependentCareProviders(); }
private static decimal GetVAT(TaxForm form, decimal CP, decimal TF, decimal EXC) { if (form.CarEngineType == EngineType.Electro) { return(0); } else { return((CP + TF + EXC) * 0.2m); } }
private static decimal GetEXC(TaxForm form, decimal KY, decimal KE) { if (form.CarEngineType == EngineType.Petrol || form.CarEngineType == EngineType.Diesel) { return(KY * KE); } else { return(KE); } }
private static decimal GetTF(TaxForm form, decimal CP) { if (form.CarEngineType == EngineType.Electro) { return(0); } else { return(CP * 0.1m); } }
public ActionResult Edit(int id, TaxForm model) { TaxFormViewModel tfvm = new TaxFormViewModel(); tfvm.Init(_db); var editTaxForm = tfvm.GetTaxById(id); editTaxForm.TaxYear = model.TaxYear; _db.Update <TaxForm>(editTaxForm); _db.SaveChanges(); return(RedirectToAction(nameof(Index))); }
public ReportData(ApplicationDbContext db) { _db = db; taxtForm = new TaxForm(); dependent = new List <Dependent>(); filingStatus = new FilingStatus(); taxFormAddress = new TaxFormAddress(); taxFormCriteria = new TaxFormCriteria(); taxFormAddress = new TaxFormAddress(); CareProvider = new DependentCareProviders(); }
public ReportData(ApplicationDbContext db, IHttpContextAccessor httpContextAccessor, IWebHostEnvironment env) { _db = db; _httpContextAccessor = httpContextAccessor; _env = env; taxtForm = new TaxForm(); dependent = new List <Dependent>(); filingStatus = new FilingStatus(); taxFormAddress = new TaxFormAddress(); taxFormCriteria = new TaxFormCriteria(); taxFormAddress = new TaxFormAddress(); CareProvider = new DependentCareProviders(); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } TaxForm = await _context.TaxForms.FirstOrDefaultAsync(m => m.ID == id); if (TaxForm == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } TaxForm = await _context.TaxForms.FindAsync(id); if (TaxForm != null) { _context.TaxForms.Remove(TaxForm); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public (int, string) CheckIfCurrentTaxYearExist() { var currentYear = DateTime.Now.Year; var result = _db.TaxForms.Where(c => c.TaxYear == currentYear).FirstOrDefault(); if (result != null) { return(result.ID, result.FilingStatus); } TaxForm t = new TaxForm(); var userID = _httpContextAccessor.HttpContext.User.Claims.First().Value; t.TaxYear = DateTime.Now.Year; t.FilingStatus = "GetStarted"; t.UserID = userID; t.Person = _db.Person.First(c => c.UserId == userID); t.Filingstatus = _db.FilingStatus.First(c => c.Name == "GetStarted"); _db.TaxForms.Add(t); _db.SaveChanges(); return(t.ID, "GetStarted"); }
public static string CalculateTax(TaxForm form) { decimal rateUSD = 0, rateEUR = 0; decimal TAX, VAT, TF, EXC, CP, KY, KE, PF; List <Currency> currencies = CurrencyRates.GetExchangeRate(); foreach (Currency currency in currencies) { switch (currency.cc) { case "USD": rateUSD = currency.rate; break; case "EUR": rateEUR = currency.rate; break; } } CP = GetCP(form, rateUSD, rateEUR); KY = GetKY(form.YearOfManufacture); KE = GetKE(form, rateEUR); TF = GetTF(form, CP); EXC = GetEXC(form, KY, KE); VAT = GetVAT(form, CP, TF, EXC); PF = GetPF(CP); /////// TAX TAX = VAT + TF + EXC; VAT = Math.Round(VAT, 2); TF = Math.Round(TF, 2); EXC = Math.Round(EXC, 2); TAX = Math.Round(TAX, 2); string fuelToOutput = null; switch (form.CarEngineType) { case EngineType.Petrol: fuelToOutput = "Бензин"; break; case EngineType.Diesel: fuelToOutput = "Дизель"; break; case EngineType.Hybrid: fuelToOutput = "Гибрид"; break; case EngineType.Electro: fuelToOutput = "Электро"; break; } string engVolToOutput = ""; if (form.CarEngineType == EngineType.Petrol || form.CarEngineType == EngineType.Diesel) { engVolToOutput = $"{form.EngineVolume} куб.см"; } if (form.CarEngineType == EngineType.Electro) { engVolToOutput = $"{form.EngineVolume} кВт/ч"; } string yearToOutput = ""; if (form.CarEngineType == EngineType.Petrol || form.CarEngineType == EngineType.Diesel) { yearToOutput = $"Год выпуска: {form.YearOfManufacture}\n"; } decimal rateToOutput = 0; switch (form.CarPriceCurrency) { case CurrencyType.USD: rateToOutput = rateUSD; break; case CurrencyType.EUR: rateToOutput = rateEUR; break; } string result = $"Расчёт на {DateTime.Now.Day:d2}/{DateTime.Now.Month:d2}/{DateTime.Now.Year}г.\n\n" + $"\U000027A1 ИТОГО: {GetFormattedPrice(TAX)} грн.\n\n" + $"В том числе\n" + $"Акцизный сбор: {GetFormattedPrice(EXC)} грн.\n" + $"Пошлина: {GetFormattedPrice(TF)} грн.\n" + $"НДС: {GetFormattedPrice(VAT)} грн.\n\n" + "-------------\n\n" + $"ИТОГО: {GetFormattedPrice(TAX / rateToOutput)} {form.CarPriceCurrency}\n\n" + $"В том числе\n" + $"Акцизный сбор: {GetFormattedPrice(EXC / rateToOutput)} {form.CarPriceCurrency}\n" + $"Пошлина: {GetFormattedPrice(TF / rateToOutput)} {form.CarPriceCurrency}\n" + $"НДС: {GetFormattedPrice(VAT / rateToOutput)} {form.CarPriceCurrency}\n\n" + "-------------\n\n" + $"Платёж в пенсионный фонд:\n{GetFormattedPrice(PF)}грн. ({GetFormattedPrice(PF / rateUSD)} USD)\n\n" + "-------------\n\n" + $"Рассчитано на основании введенных данных:\n" + $"Цена автомобиля: {form.CarPrice} {form.CarPriceCurrency}\n" + $"{fuelToOutput} {engVolToOutput}\n" + yearToOutput + $"Стоимость транспортировки: {form.TransportToUABorderCost} {form.TransportToUABorderCurrency}"; return(result); }
private void ReportBody(TaxForm t) { var fontStyleBold = FontFactory.GetFont("Tahoma)", 9f, 1); _fontStyle = FontFactory.GetFont("Tahoma)", 9f, 0); #region Detail Table Header _pdfCell = new PdfPCell(new Phrase("Tax Year", fontStyleBold)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.Gray; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); #endregion #region Detail table body #region Main Applicant information #region Main Constituent _pdfCell = new PdfPCell(new Phrase($"{t.Person.FirstName} {t.Person.LastName}", _fontStyle)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.Colspan = 3; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase($"{t.Person.Phone}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase($"{t.Person.Birthday}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase($"{t.Person.Email}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase($"{t.Person.Occupation}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); #endregion #region Spouse _pdfCell = new PdfPCell(new Phrase($"{t.Person.FirstName} {t.Person.LastName}", _fontStyle)); _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.Colspan = 3; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase($"{t.Person.Phone}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase($"{t.Person.Birthday}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase($"{t.Person.Email}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase($"{t.Person.Occupation}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); #endregion #region Address _pdfCell = new PdfPCell(new Phrase($"{t.Person.Address.Address1}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfCell = new PdfPCell(new Phrase($"{t.Person.Address.Address2}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase($"{t.Person.Address.City}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase($"{t.Person.Address.State}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); _pdfCell = new PdfPCell(new Phrase($"{t.Person.Address.Zip}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); #endregion #region foreach (var item in t.TaxFormCriterias) { _pdfCell = new PdfPCell(new Phrase($"{item.Name}", _fontStyle)); _pdfCell.Colspan = 3; _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE; _pdfCell.BackgroundColor = BaseColor.White; _pdfTable.AddCell(_pdfCell); _pdfTable.CompleteRow(); } #endregion #endregion #endregion }
public NotificationCenterVM() { Notification = new Notifications(); taxForm = new TaxForm(); Notifications = new List <Notifications>(); }