Skip to content

Instantly share code, notes, and snippets.

@miguelff
Last active March 11, 2024 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguelff/e11ae90cc3025a27ddecb775fb2e0b9d to your computer and use it in GitHub Desktop.
Save miguelff/e11ae90cc3025a27ddecb775fb2e0b9d to your computer and use it in GitHub Desktop.
Taxes in asturias
Gross: 420000, Net: 220831 (18402 / mo), Tax: 199168 - 47.42 percent goes to taxes
Gross: 245200, Net: 135179 (11264 / mo), Tax: 110020 - 44.87 percent goes to taxes
Gross: 180000, Net: 103231 (8602 / mo), Tax: 76768 - 42.65 percent goes to taxes
Gross: 157700, Net: 92131 (7677 / mo), Tax: 65568 - 41.58 percent goes to taxes
Gross: 113950, Net: 70256 (5854 / mo), Tax: 43693 - 38.34 percent goes to taxes
Gross: 92075, Net: 59318 (4943 / mo), Tax: 32756 - 35.58 percent goes to taxes
Gross: 70200, Net: 47391 (3949 / mo), Tax: 22808 - 32.49 percent goes to taxes
Taxes in bizkaia
Gross: 420000, Net: 228562 (19046 / mo), Tax: 191438 - 45.58 percent goes to taxes
Gross: 245200, Net: 139414 (11617 / mo), Tax: 105786 - 43.14 percent goes to taxes
Gross: 180000, Net: 106162 (8846 / mo), Tax: 73838 - 41.02 percent goes to taxes
Gross: 157700, Net: 94353 (7862 / mo), Tax: 63346 - 40.17 percent goes to taxes
Gross: 113950, Net: 71075 (5922 / mo), Tax: 42874 - 37.63 percent goes to taxes
Gross: 92075, Net: 59260 (4938 / mo), Tax: 32814 - 35.64 percent goes to taxes
Gross: 70200, Net: 47229 (3935 / mo), Tax: 22971 - 32.72 percent goes to taxes
taxes = {
asturias: {
12_450 => 20,
17_707 => 24,
33_007 => 28,
53_407 => 37,
70_000 => 43,
90_000 => 45,
175_000 => 50,
1_000_000_000_000 => 51
},
bizkaia: {
15_550 => 23,
31_100 => 28,
46_650 => 35,
66_640 => 40,
92_310 => 45,
123_070 => 46,
179_460 => 47,
1_000_000_000_000 => 49
}
}
def tax(amount, brackets)
sum = 0
previous = 0
brackets.each do | bracket, percent |
last = amount < bracket
base = (last ? amount : bracket) - previous
sum += base * percent / 100.0
break if last
previous = bracket
end
sum
end
taxes.each do | place, brackets |
puts "Taxes in #{place}"
%w(420000 245200 180000 157700 113950 92075 70200).map(&:to_f).map do | salary |
tax = tax(salary, brackets)
net = salary - tax
net_12 = net / 12.0
tax_100 = tax / salary * 100
printf("Gross: %d, Net: %d (%d / mo), Tax: %d - %.2f percent goes to taxes\n", salary, net, net_12, tax, tax_100)
end
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment