/* * • pay period = per calendar month * • gross income = annual salary / 12 months * • income tax = based on the tax table provide below * • net income = gross income - income tax * • super = gross income x super rate */ // could be public, no difference, just we could test it, // but how do we access the values? // maybe return a hash private int calculate() { //this is what we calculate: // public uint grossIncome; // public uint incomeTax; // public uint netIncome; // public uint super; // pay period = per calendar month // gross income = annual salary / 12 months this.grossIncome = (uint)Math.Round(this.annualSalary / 12.00); // income tax = based on the tax table provide below //just the sample here: // so the start tax IncomeTaxRate incomeTaxRate = getIrdIncomeTaxRate(annualSalary); // now we can calculate the band // incomeTax = (3572 + (60050 - 37000) * 0.325) / 12; decimal fixedTaxAmount = incomeTaxRate.fixedTaxAmount; // lower taxable income is one dollar ore than the basis for calculation. // lower is 18001 and the amount is salary-18000, it is why we have minus 1. uint variableTaxAmount = annualSalary - (incomeTaxRate.lowerTaxableIncome - 1); decimal variableTaxValue = variableTaxAmount * incomeTaxRate.taxPerDollar; this.incomeTax = Math.Round((fixedTaxAmount + variableTaxValue) / 12); //• net income = gross income - income tax this.netIncome = grossIncome - (uint)incomeTax; //super = gross income x super rate // TODO: Have to manage integers divided by 100. // 2/100 is 0, not 0.02 this.super = grossIncome * superRate / 100; return(0); }
// made it public so we can test it. public IncomeTaxRate getIrdIncomeTaxRate(uint salary) { IncomeTaxRate incomeTaxRate = null; incomeTaxRate = IncomeTaxRates.getInstance().getRateForIncome(salary); return(incomeTaxRate); }
public IncomeTax(decimal salary) { _salary = salary; _percentDiscounte = 5; _aliquota = new IncomeTaxRate(0, 2) .NextRange(new IncomeTaxRate(7.5m, 4) .NextRange(new IncomeTaxRate(15, 5) .NextRange(new IncomeTaxRate(22.5m, 7) .NextRange(new IncomeTaxRate(27.5m))))); }
public void AliquotaErradaSemProxima() { //Arrange var aliquota = new IncomeTaxRate(15, 5); var salarioMinimo = 1000; var rendaLiquida = 6000; //Act var valor = aliquota.GetIncomeTax(salarioMinimo, rendaLiquida); //Assert valor.Should().Be(0); }
public void AliquotaMaxima() { //Arrange var aliquota = new IncomeTaxRate(27.5m); var salarioMinimo = 1000; var rendaLiquida = 40000; //Act var valor = aliquota.GetIncomeTax(salarioMinimo, rendaLiquida); var valorEsperado = ((rendaLiquida * 27.5m) / 100); //Assert valor.Should().Be(valorEsperado); }
public void AliquotaCorretaComProxima() { //Arrange var aliquota = new IncomeTaxRate(15, 5) .NextRange(new IncomeTaxRate(22.5m, 7)); var salarioMinimo = 1000; var rendaLiquida = 4000; //Act var valor = aliquota.GetIncomeTax(salarioMinimo, rendaLiquida); var valorEsperado = ((rendaLiquida * 15) / 100); //Assert valor.Should().Be(valorEsperado); }