public void NegativeValues_Hawaii_2017_Checks_And_Balances(decimal grossWages, PayrollFrequency freq, FilingStatus filingStatus, int allowances) { var table = TaxTables.GetForState(StateOrProvince.HI, year: 2017) as Hawaii.TaxTable; Assert.Throws <ArgumentOutOfRangeException>(() => table.Calculate(grossWages, freq, allowances, filingStatus)); }
public void California_2017_Checks_And_Balances(PayrollFrequency frequency, Decimal grossWages, FilingStatus status, int allowances, int deductions, Decimal expected) { var table = TaxTables.GetForState(StateOrProvince.CA, year: 2017) as California.TaxTable2017; var result = table.Calculate(grossWages, frequency, status, allowances, deductions); Assert.AreEqual(expected, result); }
public void Mississippi_2017_Checks_And_Balances(decimal grossWages, PayrollFrequency freq, FilingStatus filingStatus, int personalAllowances, decimal expected) { var table = TaxTables.GetForState(StateOrProvince.MS, year: 2017) as Mississippi.TaxTable2017; var result = table.Calculate(grossWages, freq, filingStatus, personalAllowances); Assert.AreEqual(expected, result); }
public void Missouri_2017_Checks_And_Balances(PayrollFrequency frequency, Decimal grossWages, FilingStatus filingStatus, decimal federalWithholding, int allowances) { var table = TaxTables.GetForState(StateOrProvince.MO, year: 2017) as Missouri.TaxTable2017; Assert.Throws <ArgumentOutOfRangeException>(() => table.Calculate(grossWages, frequency, filingStatus, federalWithholding, allowances)); }
public static double CalcTaxedWithdrawals(double rate, double presentValue, int yearsWithdrawing, TaxStatus taxType, FilingStatus status, double principle) { //Console.WriteLine(rate+ " rate "+presentValue+" PV "+CalcTaxes(CalcWithdrawalAmount(rate, presentValue, yearsWithdrawing), taxType, status, principle)); double withdrawal = CalcWithdrawalAmount(rate, presentValue, yearsWithdrawing); double taxes = CalcTaxes(withdrawal, taxType, status, principle); return(withdrawal - taxes); }
public void NegativeValues_Lousiana_2017_Checks_And_Balances(decimal grossWages, PayrollFrequency freq, FilingStatus filingStatus, int personalExemptions, int dependents) { var table = TaxTables.GetForState(StateOrProvince.LA, year: 2017) as Louisiana.TaxTable; Assert.Throws <ArgumentOutOfRangeException>(() => table.Calculate(grossWages, freq, filingStatus, personalExemptions, dependents)); }
/// <summary> /// Returns California state withholding when given a non-negative value for Gross Wages, Personal Allowances and Deductions. /// </summary> /// <param name="grossWages"></param> /// <param name="frequency"></param> /// <param name="filingStatus"></param> /// <param name="personalAllowances"></param> /// <param name="deductions"></param> /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception> /// <returns></returns> public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus, int personalAllowances, int deductions) { if (grossWages < Decimal.Zero) { throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number"); } if (personalAllowances < Decimal.Zero) { throw new ArgumentOutOfRangeException($"{nameof(personalAllowances)} cannot be a negative number"); } if (deductions < Decimal.Zero) { throw new ArgumentOutOfRangeException($"{nameof(deductions)} cannot be a negative number"); } var taxableWages = frequency.CalculateAnnualized(grossWages); var withholdingFilingStatus = CheckFilingStatus(filingStatus, personalAllowances); if (!CheckIncome(withholdingFilingStatus, taxableWages, personalAllowances)) { return(0); } taxableWages -= GetDeduction(deductions); taxableWages -= GetStandardDeduction(withholdingFilingStatus); if (taxableWages <= 0) { return(0); } var taxRate = GetTaxWithholding(filingStatus, taxableWages); taxableWages = taxRate.TaxBase + ((taxableWages - taxRate.StartingAmount) * taxRate.TaxRate); var taxWithheld = taxableWages - GetPersonalAllowance(personalAllowances); return(frequency.CalculateDeannualized(Math.Max(0, taxWithheld))); }
public void Maine_2017_Checks_And_Balances(decimal grossWages, PayrollFrequency freq, FilingStatus status, int withholdingAllowances) { var table = TaxTables.GetForState(StateOrProvince.ME, year: 2017) as Maine.TaxTable; Assert.Throws <ArgumentOutOfRangeException>(() => table.Calculate(grossWages, freq, status, withholdingAllowances)); }
/// <summary> /// Returns Idaho State Withholding when given a non-negative value for gross wages and personal allowances. /// </summary> /// <param name="grossWages"></param> /// <param name="frequency"></param> /// <param name="filingStatus"></param> /// <param name="personalAllowances"></param> /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception> /// <returns></returns> public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus = FilingStatus.Single, int personalAllowances = 1) { if (grossWages < Decimal.Zero) { throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number"); } if (personalAllowances < Decimal.Zero) { throw new ArgumentOutOfRangeException($"{nameof(personalAllowances)} cannot be a negative number"); } var taxableWages = frequency.CalculateAnnualized(grossWages); taxableWages -= GetPersonalAllowance(personalAllowances); if (taxableWages <= 0) { return(0); } var selected_row = GetTaxWithholding(filingStatus, taxableWages); var taxWithheld = Math.Round(selected_row.TaxBase + ((taxableWages - selected_row.StartingAmount) * selected_row.TaxRate), MidpointRounding.AwayFromZero); return(Math.Round(frequency.CalculateDeannualized(taxWithheld), MidpointRounding.AwayFromZero)); }
public double[] CalculateReturns(int age, int retireAge, int deathAge, double mean, double stdDeviation, double amount, double lumpSum, TaxStatus taxType, FilingStatus status, double income, List <Riders> Riders) { double[] MedianAverageWithdrawal = new double[4000]; for (int i = 0; i < 4000; i++) { double temp = lumpSum;//sets temp to equal lumpsum, if deferred this is 0 double returns = 0; double taxableAmount = 0; double principle = lumpSum; double withdrawalAmount = 0; for (int j = age; j < deathAge; j++) { Random rand = new Random(); double rate = mean + stdDeviation * (rand.NextDouble() * (6) - 3);//random number between -3 and 3, then multiplied by std deviation if (j == retireAge) { double assetAtRetire = temp; } if (j < retireAge) { principle += amount; returns = (temp + amount) * Math.Pow(1 + rate, 1); //total returns taxableAmount = returns - temp; //interest made of of returns temp = returns; //-Convert.ToDouble(IncomeTaxCalculator.CapitalGainsTaxFor(status, (decimal)taxableAmount, (decimal)income));//capitol gains tax subtracted from interest made } else { withdrawalAmount += CalcWithdrawal(mean, temp, deathAge - j + 1, taxType, status, principle / (deathAge - retireAge)); temp -= CalcWithdrawal(mean, temp, deathAge - j + 1, taxType, status, principle / (deathAge - retireAge)); temp = temp * Math.Pow(1 + rate, 1); } } withdrawalAmount = withdrawalAmount / (deathAge - retireAge); //calculates average withdrawal MedianAverageWithdrawal[i] = withdrawalAmount; //stores the average withdrawal for this trial } return(MedianAverageWithdrawal); }
public void Maine_2017_Checks_And_Balances(decimal grossWages, PayrollFrequency freq, FilingStatus status, int withholdingAllowances, decimal expected) { var table = TaxTables.GetForState(StateOrProvince.ME, year: 2017) as Maine.TaxTable; var result = table.Calculate(grossWages, freq, status, withholdingAllowances); Assert.AreEqual(expected, result); }
public TaxComputationWorksheetSection GetSection(FilingStatus status) => mSections[status];
public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus, int personalExemptions = 0, int dependents = 0) { if (grossWages < Decimal.Zero) { throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number"); } if (personalExemptions < Decimal.Zero) { throw new ArgumentOutOfRangeException($"{nameof(personalExemptions)} cannot be a negative number"); } var TaxableWages = frequency.CalculateAnnualized(grossWages); var rate = GetRate(filingStatus, personalExemptions); var deductions = GetDeductions(rate, personalExemptions, dependents); var withholding = Math.Max(0, GetWithholding(rate, TaxableWages, deductions)); return(frequency.CalculateDeannualized(withholding)); }
/// <summary> /// Returns Utah State Withholding when given a non-negative value for gross wages and exemptions. /// </summary> /// <param name="grossWages"></param> /// <param name="frequency"></param> /// <param name="filingStatus"></param> /// <param name="exemptions"></param> /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception> /// <returns></returns> public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus, int exemptions = 0) { if (grossWages < Decimal.Zero) { throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number"); } if (exemptions < Decimal.Zero) { throw new ArgumentOutOfRangeException($"{nameof(exemptions)} cannot be a negative number"); } var annualized_wages = frequency.CalculateAnnualized(grossWages); var taxedWages = annualized_wages * TaxRateA; var allowances = GetAllowances(filingStatus, exemptions); annualized_wages -= GetStandardDeduction(filingStatus); annualized_wages = annualized_wages * TaxRateB; var deduction = allowances - annualized_wages; var taxWithheld = taxedWages - deduction; return(frequency.CalculateDeannualized(Math.Max(taxWithheld, 0))); }
public double[] CalculateReturns(int age, int retireAge, int deathAge, double mean, double stdDeviation, double amount, TaxStatus taxType, FilingStatus status, double income, List <Riders> Riders) { double withdrawalPercentageFee = 0; /*surrender fee:*/ //fee for withdrawing early if (age + 7 < retireAge) { withdrawalPercentageFee = 0.07; } else if (age + 6 < retireAge) { withdrawalPercentageFee = 0.06; } else if (age + 5 < retireAge) { withdrawalPercentageFee = 0.05; } else if (age + 4 < retireAge) { withdrawalPercentageFee = 0.04; } else if (age + 3 < retireAge) { withdrawalPercentageFee = 0.03; } else if (age + 2 < retireAge) { withdrawalPercentageFee = 0.02; } else if (age + 1 < retireAge) { withdrawalPercentageFee = 0.01; } /*surender fee:*/ double amountWithFees = amount; if (Riders.Contains(Models.Riders.DeathBenefit))//death benefit rider, only increases fee { amountWithFees -= amountWithFees * .005; } double[] MedianAverageWithdrawal = new double[4000]; for (int i = 0; i < 4000; i++) { // double[] account = new double[deathAge-retireAge]; int count = 0; //index of the array that withdrawal data is being input into double temp = 0; //current amount in the annuity double principle = 0; //untaxable part of account double withdrawalAmount = 0; for (int j = age; j < deathAge; j++) { Random rand = new Random(); double rate = mean + stdDeviation * (rand.NextDouble() * (6) - 3);//random number from -3 to 3, 3 standard deviations is enough //if rate is less than 1 if (rate < .01)//fixed indexed has upper and lower bounds for rate { rate = .01; } else if (rate > .06) { rate = .06; } if (j == retireAge) { double assetAtRetire = temp; } if (j < retireAge)//depositing only , no withdrawing { temp = (temp + amountWithFees) * Math.Pow(1 + rate, 1); principle += amountWithFees; //adds to amount invested } if (j >= retireAge) //stop depositing and start withdrawing when retirement starts { double withdrawal = CalcWithdrawal(mean, temp, deathAge - j + 1, taxType, status, principle / (deathAge - retireAge)); //withdrawal amoutn with taxes and loan payment calc withdrawal = withdrawal - withdrawal * withdrawalPercentageFee; // subtract withdrawal early fee // account[count] = withdrawal; withdrawalAmount += withdrawal; temp -= withdrawal; temp = temp * Math.Pow(1 + rate, 1); //interest count++; //increment array counter } } withdrawalAmount = withdrawalAmount / (deathAge - retireAge); //calculates average withdrawal MedianAverageWithdrawal[i] = withdrawalAmount; //stores the average withdrawal for this trial } // trials.Add(MedianAverageWithdrawal);//adds an array of the averages to the end of the lsit, will be taken out later and used return(MedianAverageWithdrawal); }
public static decimal TotalIncomeTaxFor(FilingStatus status, decimal income, decimal basicAdjustment) => FederalTaxFor(status, income, basicAdjustment) + VaStateTaxFor(status, income);
public void Lousiana_2017_Checks_And_Balances(decimal grossWages, PayrollFrequency freq, FilingStatus filingStatus, int personalExemptions, int dependents, decimal expected) { var table = TaxTables.GetForState(StateOrProvince.LA, year: 2017) as Louisiana.TaxTable; var result = table.Calculate(grossWages, freq, filingStatus, personalExemptions, dependents); Assert.AreEqual(expected, result); }
public static decimal FederalTaxFor(FilingStatus status, decimal income, decimal basicAdjustment) => CalculateGraduatedTaxFor(status, "Federal", income, basicAdjustment);
public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus = FilingStatus.Single, int personalAllowances = 1) { var taxableWages = frequency.CalculateAnnualized(grossWages); taxableWages -= GetPersonalAllowance(personalAllowances); var selected_row = GetTaxWithholding(filingStatus, taxableWages); var taxWithheld = Math.Round(selected_row.TaxBase + ((taxableWages - selected_row.StartingAmount) * selected_row.TaxRate), MidpointRounding.AwayFromZero); return(Math.Round(frequency.CalculateDeannualized(taxWithheld), MidpointRounding.AwayFromZero)); }
public static decimal VaStateTaxFor(FilingStatus status, decimal income) => CalculateGraduatedTaxFor(status, "VA State", income, 0.00M);
public void Missouri_2017_Checks_And_Balances(PayrollFrequency frequency, Decimal grossWages, FilingStatus filingStatus, decimal federalWithholding, int allowances, Decimal expected) { var table = TaxTables.GetForState(StateOrProvince.MO, year: 2017) as Missouri.TaxTable2017; var result = table.Calculate(grossWages, frequency, filingStatus, federalWithholding, allowances); Assert.AreEqual(expected, result); }
private static decimal CalculateGraduatedTaxFor(FilingStatus status, string jurisdiction, decimal income, decimal basicAdjustment) { // Get jurisdiction data (decimal lowerBound, decimal upperBound)[] brackets;
public void Hawaii_2017_Checks_And_Balances(decimal grossWages, PayrollFrequency freq, FilingStatus filingStatus, int allowances, decimal expected) { var table = TaxTables.GetForState(StateOrProvince.HI, year: 2017) as Hawaii.TaxTable; var result = table.Calculate(grossWages, freq, allowances, filingStatus); Assert.AreEqual(expected, result); }
public void Checks_And_Balances(decimal grossWages, PayrollFrequency freq, FilingStatus status, int personalAllowances) { var table = TaxTables.GetForState(StateOrProvince.NJ, year: 2017) as NewJersey.TaxTable; Assert.Throws <ArgumentOutOfRangeException>(() => table.Calculate(grossWages, freq, status, personalAllowances)); }
public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus, decimal exemption) { if (grossWages < Decimal.Zero) { throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number"); } if (exemption < Decimal.Zero) { throw new ArgumentOutOfRangeException($"{nameof(exemption)} cannot be a negative number"); } var taxableWages = frequency.CalculateAnnualized(grossWages); taxableWages -= GetStandardDeduction(filingStatus); taxableWages -= exemption; var withheldWages = FindWithholding(taxableWages); return(frequency.CalculateDeannualized(Math.Max(0, withheldWages)).Round(decimals: 0)); }
/// <summary> /// Returns Minnestoa State Withholding when given a non-negative value for Gross Wages and Allowances. /// </summary> /// <param name="grossWages"></param> /// <param name="frequency"></param> /// <param name="filingStatus"></param> /// <param name="allowances"></param> /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception> /// <returns></returns> public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus, int allowances = 0) { if (grossWages < Decimal.Zero) { throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number"); } if (allowances < Decimal.Zero) { throw new ArgumentOutOfRangeException($"{nameof(allowances)} cannot be a negative number"); } var taxableWages = frequency.CalculateAnnualized(grossWages); taxableWages -= GetAllowance(allowances); if (taxableWages <= 0) { return(0); } var selectedRow = GetTaxableWithholding(filingStatus, taxableWages); var taxWithheld = selectedRow.TaxBase + ((taxableWages - selectedRow.StartingAmount) * selectedRow.TaxRate); return(frequency.CalculateDeannualized(Math.Max(0, taxWithheld))); }
public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, decimal federalWithholding, FilingStatus filingStatus = FilingStatus.Single, int dependentAllowances = 0) { var taxableWages = frequency.CalculateAnnualized(grossWages); var annualWages = taxableWages; taxableWages -= frequency.CalculateAnnualized(federalWithholding); taxableWages -= GetStandardDeduction(filingStatus, annualWages); taxableWages -= GetPersonalAllowance(filingStatus); taxableWages -= GetDependentAllowance(annualWages, dependentAllowances); var taxWithheld = GetTaxWithholding(filingStatus, taxableWages); return(frequency.CalculateDeannualized(taxWithheld)); }
public double CalcWithdrawal(double rate, double presentValue, int yearsWithdrawing, TaxStatus taxType, FilingStatus status, double principle) { return(TaxHelper.CalcTaxedWithdrawals(rate, presentValue, yearsWithdrawing, taxType, status, principle)); }
public void NegativeValue_Mississippi_2017_Checks_And_Balances(decimal grossWages, PayrollFrequency freq, FilingStatus filingStatus, int personalAllowances, decimal expected) { var table = TaxTables.GetForState(StateOrProvince.MS, year: 2017) as Mississippi.TaxTable2017; Assert.Throws <ArgumentOutOfRangeException>(() => table.Calculate(grossWages, freq, filingStatus, personalAllowances)); }
internal virtual Decimal GetExemptionAllowance(FilingStatus filingStatus, int exemptionAllowances = 1) { return(ExemptionAllowance * exemptionAllowances); }