static void Main(string[] args) { MedicareLevy medicareLevy = new MedicareLevy("Medicare Levy", 2); BudgetRepairLevy budgetRepairLevy = new BudgetRepairLevy("Budget Repair Levy", 2); IncomeTax incomeTax = new IncomeTax("Income Tax", 5); Income income = new Income(); SalaryDetails salaryDetails = new SalaryDetails(medicareLevy, budgetRepairLevy, incomeTax, income); salaryDetails.Runner(); System.Console.ReadKey(); }
public void Budget_Repair_Levy_Should_Be_Zero_If_Income_Is_In_First_Range() { //Arrange double taxableIncome = 100000; double tax = 0; MedicareLevy medicareLevy = new MedicareLevy("Medicare Levy", 2); BudgetRepairLevy budgetRepairLevy = new BudgetRepairLevy("Budget Repair Levy", 2); IncomeTax incomeTax = new IncomeTax("Income Tax", 5); Income income = new Income(); SalaryDetails sd = new SalaryDetails(medicareLevy, budgetRepairLevy, incomeTax, income); //Act tax = sd.CalculateBudgetRepairLevy(taxableIncome); //Assert Assert.AreEqual(0, tax, "Tax should be zero"); }
public void Calculate(decimal grossPackage, char payFrequencyUserInput) { //1. Find the taxation year var taxYear = DateTime.Now.Year; // read file into a string and deserialize JSON to a type var taxFile = GetTaxFile.RetrieveTaxFile(_logger); try { //Locate the tax data from tax file based on the current year and load the tax slabs if (taxFile == null) { _logger.Log("no data in tax file."); return; } var currentTaxRate = taxFile.TaxRates != null && taxFile.TaxRates.Any() ? taxFile.TaxRates.Find(x => x.Year == taxYear) : null; if (currentTaxRate == null) { _logger.Log("no tax data found for the current year in tax file."); return; } //2. find the percentage of Super var superPercentage = currentTaxRate.SuperRate; //3. Calculate Super component var taxableIncome = grossPackage / ((100 + superPercentage) / 100); var super = taxableIncome * (superPercentage / 100); //4. Do deductions //4.1. Tax decimal incomeTax = new IncomeTax().Calculate(currentTaxRate, taxableIncome); //4.2. Medicare Levy decimal medicareLevy = new MedicareLevy().Calculate(currentTaxRate, taxableIncome); //4.3. Budget Repair Levy decimal budgetRepairLevy = new BudgetRepairLevy().Calculate(currentTaxRate, taxableIncome); //5. Find Net Pay var netIncome = grossPackage - super - incomeTax - medicareLevy - budgetRepairLevy; //6. Net pay per passed frequency .i.e., Monthly, Weekly or fortnightly Frequency frequency; decimal netPay = 0; frequency = CalculateNetPayAndFrequency(payFrequencyUserInput, netIncome, ref netPay); //7. Build and return the result var salary = new Salary() { Super = super, TaxableIncome = taxableIncome, NetIncome = netIncome, BudgetRepairLevy = budgetRepairLevy, MedicareLevy = medicareLevy, IncomeTax = incomeTax, Frequency = frequency, NetPay = netPay, Gross = grossPackage }; DisplayOutput(grossPackage, salary); } catch (Exception ex) { _logger.Log("Error occurred during Calculate.. {0}", ex.Message); } }