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); }
public static string CalculateTax(TaxEuroForm form) { if (!form.isValidYear) { return("!!!Поплава!!!"); } decimal rateEUR = 0; List <Currency> currencies = CurrencyRates.GetExchangeRate(); foreach (Currency currency in currencies) { if (currency.cc == "EUR") { rateEUR = currency.rate; } } decimal excise, vat, tax, PF; decimal fineUAH = 8500; decimal fineEUR = fineUAH / rateEUR; decimal SB = GetSB(form.YearOfManufacture); decimal VE = GetVE(form.EngineVolume); decimal FE = GetFE(form.CarEngineType); excise = SB + VE + FE; PF = GetPF(excise); vat = excise * 0.2m; tax = excise + vat; string fuelToOutput = null; switch (form.CarEngineType) { case EngineType.Petrol: fuelToOutput = "Бензин"; break; case EngineType.Diesel: fuelToOutput = "Дизель"; break; case EngineType.Hybrid: fuelToOutput = "Гибрид"; break; } string result = "\U00002757 Евробляха\n\n" + $"Расчёт на {DateTime.Now.Day:d2}/{DateTime.Now.Month:d2}/{DateTime.Now.Year}г.\n\n" + $"\U000027A1 ИТОГО: {GetFormattedPrice((tax * rateEUR) + fineUAH)} грн.\n\n" + $"В том числе\n" + $"Акцизный сбор: {GetFormattedPrice(excise * rateEUR)} грн.\n" + $"НДС: {GetFormattedPrice(vat * rateEUR)} грн.\n\n" + $"Штраф: {GetFormattedPrice(fineUAH)} грн.\n\n" + "-------------\n\n" + $"ИТОГО: {GetFormattedPrice(tax + fineEUR)} EUR.\n\n" + $"В том числе\n" + $"Акцизный сбор: {GetFormattedPrice(excise)} EUR.\n" + $"НДС: {GetFormattedPrice(vat)} EUR.\n\n" + $"Штраф: {GetFormattedPrice(fineEUR)} EUR.\n\n" + "-------------\n\n" + $"Платёж в пенсионный фонд:\n{GetFormattedPrice(PF * rateEUR)}грн. ({GetFormattedPrice(PF)} EUR)\n\n" + "-------------\n\n" + $"Рассчитано на основании введенных данных:\n" + $"Год выпуска: {form.YearOfManufacture}\n" + $"{fuelToOutput} {form.EngineVolume} куб.см\n"; return(result); }