Tax Calculations 16/17

by bizamajig

JavaScript

// --- CONFIGURATION FOR 2016/17 ---

var incomeTaxRates = [
	0.2,
  0.4,
  0.45
];

var incomeTaxThresholds = [
	32000,
  150000
];

var personalAllowance = 11000;

var personalAllowanceLimit = 100000;

var personalAllowanceReductionRate = 0.5;

// Allowance is reduced not lost

var nationalInsuranceEmployeeRates = [
	0.00,
  0.00,
  0.12,
  0.02
];

var nationalInsuranceEmployeeThresholds = [
	112,
  155,
  827
];

var nationalInsuranceEmployerRates = [
	0.00,
  0.138
];

var nationalInsuranceEmployerThresholds = [
	156
];

var dividendTaxRates = [
	0.075,
  0.325,
  0.381
];

var dividendTaxAllowance = 5000;

var corporationTax = 0.2;

// --- EDIT BELOW THIS LINE ---

var dayRate = 400;

var daysPerYear = 200;

var yearlyRate = dayRate * daysPerYear;
// Total revenue
// Expenses amount / percentage (not inc wages)

console.log('yearly rate', yearlyRate);

var salary = 8060;
// 

var dividends = 45000;

// TODO: Does not include dividends tax allowance
// which is within the personal allowance
var result = calculateTax(salary, dividends);

console.log('tax result', result);

// TODO: Corporation tax is total contract
// amount, minus expenses, minus salary
// and NI contributions, times corporationTaxRate

var takeHome = salary + dividends - result.totalTaxPayable;

console.log('monthly take home', takeHome / 12);

var corporationTax = (yearlyRate - salary) * 0.2;

console.log('max corporation tax', corporationTax);

var maxTotalTaxes = result.totalTaxPayable + corporationTax;

console.log('max total taxes', maxTotalTaxes);

var minRemaining = yearlyRate - maxTotalTaxes - salary - dividends;

console.log('min remaining', minRemaining);

// --- FUNCTIONS ---

function calculateTax(salary, dividends) {

  var grossIncome = salary + dividends;

  var personalAllowanceAvailable = calculateAvailablePersonalAllowance(grossIncome);
  
  var taxableSalary = Math.max(0, salary - personalAllowanceAvailable);
  
  var taxableIncome = grossIncome -...