• Stars
    star
    337
  • Rank 125,272 (Top 3 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 9 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ruby library to calculate the income tax for any country

Income Tax Estimation

Build Status

Given a country and either the gross or net income, this library can estimate the personal income tax. These are very rough estimates, mostly ignoring any potential tax deductions.

It has the following goals:

  • Zero external dependencies.
  • Compatible with the money gem.
  • Full test coverage.

Usage

require 'income_tax'

# €4k per month before taxes in Estonia, which has a fixed 20% tax rate
tax_info = IncomeTax.new("Estonia", "4k/mo")
tax_info.gross_income # => 48000
tax_info.net_income   # => 38400
tax_info.taxes        # => 9600
tax_info.rate         # => "20%"
tax_info.to_f         # => 0.2
tax_info.to_r         # => (1/5)

# Making €4k after taxes
tax_info = IncomeTax.new("Estonia", "4k/mo", :net)
tax_info.gross_income # => 60000
tax_info.net_income   # => 48000

# Using the money gem (will automatically convert to appropriate currency)
require "money"
tax_info = IncomeTax.new("Estonia", Money.new(100_000, "USD"))
tax_info.gross_income # => 89000 (depending on exchange rate)

Unless handed in as money object, values are assumed to be in the local currency, with the notable exception of Zimbabwe, for which USD is used.

Supported Locations

Countries

This gem uses a very broad definition of countries, whereby the following are counted as separate entities:

  • UN member states.
  • Overseas territories, outermost regions and colonies.
  • Some autonomous regions enjoying partial sovereignty, esp. if they have full autonomy over tax regime and collection (like Hong Kong).
  • States with limited but widespread recognition (like Taiwan, Kosovo, Palestine).

Things not considered separate countries:

  • Sovereign entities without any actual territory (The Holy See, Sovereign Military Order of Malta).
  • States with very limited recognition (like Northern Cyprus, South Ossetia).
  • Scotland, Wales, England and Northern Ireland (they are collectively treated as one country).
  • Unclaimed or heavily disputed territories.
  • Antarctica.

These decisions and differentiations are made to best model international income taxes and are not meant to convey any political opinion.

Of course, suggestions and patches are always welcome.

There is also a full list of countries.

Country Divisions

United States

  • Federal only: By default, only federal taxes are calculated.
  • State taxes: Passing in the state option with either the full name of the state or the two letter abbreviation will also take state taxes into account.
  • Washington, D.C.: Use the state option as if it was a state, which by the way it should be.
  • Guam, Puerto Rico, and other territories: Treat them like separate countries.
IncomeTax.new("US", "100k")
IncomeTax.new("US", "100k", state: "California")

IncomeTax.new("Guam", "100k")

Canada

  • Federal only: By default, only federal taxes are calculated.
  • Territorial taxes: Passing in the territory option with either the full name of the territory or the two letter abbreviation will also take territorial taxes into account.
IncomeTax.new("CA", "100k")
IncomeTax.new("CA", "100k", territory: "British Columbia")

Switzerland

You can use the canton option with either the full canton name or the two letter abbreviation. If not passed in, it will default to ZH (Zurich).

IncomeTax.new("CH", "100k", canton: "Bern")

Tanzania

You can set the location option to Mainland (default) or Zanzibar.

IncomeTax.new("TZ", "16m", location: "Zanzibar")

Other Options

  • married: Whether or not the tax payer is married. Respected by the French, German, Irish, Maltese, Nepali, Nicaraguan, Swiss and U.S. American tax model.
  • children: Number of children the tax payer has to provide for. Respected by the French, Maltese and Swiss tax model.
  • joint_statement: If married, whether or not both spouses file a joint statement. Respected by the U.S. American tax model.
  • head_of_household: Whether or not the tax payer is the head of the household. Respected by the U.S. American tax model.
  • self_employed: Whether the tax payer is employed or freelancing. Respected by the Costa Rican and Nicaraguan tax model.
  • age or birthday: To determine age depended taxes. Respected by the Australian, Bangladeshi and Barbadian tax model.
  • gender: male or female, respected by the Bangladeshi tax model.
  • disabled: Whether or not the tax payer has a physical or psychological disability, respected by the Bangladeshi tax model.
  • wounded_freedom_fighter: Whether or not the tax payer is a war-wounded freedom fighter, respected by the Bangladeshi tax model.
  • presumptive: Whether or not presumptive taxes are paid. Respected by the Tanzanian tax model. This value has a smart default.
  • tax_year: Year this income tax is due for. Supported by all tax models but tax rates might be incomplete for past or future tax years (will fall back on previous year if data is missing).

Limitations

General limitations:

  • It only calculates personal income tax (ie, the tax the employee has to pay).
  • Religious taxes (like church taxes in Germany or Khums in Iran) are currently not taken into account.
  • Tax deductions are largely not taken into account.
  • Double taxation is not taken into account.
  • Rules around multiple tax regimes based on citizenship are not taken into account.
  • No differentiation between domestic and foreign income.
  • It only has limited support for taxes changing over time. Wherever possible, rates for the current or even upcoming year have been used.

Specific examples of what is not taken into account:

  • French citizens (or in some cases, any new citizens) living in overseas territories often have to pay French income tax for the first five years.
  • French citizens living or working in Monaco have to pay French income tax instead.
  • Employees in the West Bank have a high likelihood of paying Israeli income tax instead of Palestinian income tax.
  • For people living in Puerto Rico and Guam, there is a chance that they may have to pay US federal income tax instead.
  • Mali has a choose your own tax adventure, and livestock is acceptable currency when paying taxes.

These lists are very much incomplete.

Suggestions and patches on addressing any of these are, of course, more than welcome.

More Repositories

1

almost-sinatra

Sinatra refactored, only six lines now. More popular than a pair of socks.
Ruby
519
star
2

rbenv-update

update rbenv and plugins
Shell
213
star
3

async-rack

Makes middleware that ships with Rack bullet-proof for async responses.
Ruby
113
star
4

big_band

Making Sinatra swing.
Ruby
69
star
5

sinatra-reloader

Advanced code reloader for Sinatra
Ruby
68
star
6

rbenv-use

rbenv use rbx
Shell
67
star
7

yard-sinatra

Display sinatra routes in yard documentation.
Ruby
67
star
8

hansi

Your Hipster ANSI color library.
Ruby
65
star
9

coder

Handle encodings, no matter the Ruby version, Operating System and installed libraries
Ruby
64
star
10

Reak

Smalltalk on Rubinius
Ruby
57
star
11

sinatra-advanced-routes

Make Sinatra routes first class objects (extracted from BigBand).
Ruby
38
star
12

almost-rack-protection

Ruby
29
star
13

atom-sonic

Sonic Pi Atom integration
CoffeeScript
27
star
14

presentations

Ruby
26
star
15

rbenv-whatis

Shell
24
star
16

unpatched

Yet another WTF library!
Ruby
23
star
17

sinatra-namespace

Adds namespaces to Sinatra, allows namespaces to have local helpers.
Ruby
22
star
18

nii

Modern internationalization and localization solution for Ruby
Ruby
22
star
19

bithug

Yet Another Open Source GitHub Clone
Ruby
20
star
20

haml-more

Adds more functionality to Haml and Sass (part of BigBand).
Ruby
19
star
21

chainable

never use alias_method_chain, again
Ruby
18
star
22

convinius

Convenience library for Rubinius-only projects.
Ruby
17
star
23

sinatra-compass

Better Compass integration for Sinatra (extracted from BigBand).
Ruby
17
star
24

hpi

Ruby
16
star
25

almost-rack

Rack in three lines of code
Ruby
15
star
26

sinatra2

15
star
27

mixico

mixin hijinks — enable and disable mixins
Ruby
14
star
28

dotfiles

my dotfiles
JavaScript
14
star
29

gemerator

Like NewGem, but way simpler, leaves no traces, extremely minimal boiler plate. Automatically handles extensions for Rack, Yard, Sinatra, etc correctly.
Ruby
14
star
30

tool

Ruby
14
star
31

brirb

IRB in your browser, via WebSockets.
Ruby
14
star
32

sinatra-config-file

Load Sinatra settings from a yaml file.
Ruby
13
star
33

papers

papers for hpi
Shell
13
star
34

travis-encrypt

proof of concept in browser encryption of travis settings
HTML
13
star
35

hadoop-scripting

Scripting Languages on Hadoop: Jaql vs. Pig Latin (MapReduce stuff)
Java
12
star
36

sinatra-sugar

Some extensions to the sinatra default behavior (usefull for other Sintatra extensions, extracted from BigBand).
Ruby
12
star
37

sinatra-coffeescript-example

Ruby
11
star
38

teresa

Ruby
11
star
39

otnetstring

Ruby
11
star
40

rack-async-stream

Ever tried streaming with Thin? Didn't work? Use this middleware.
Ruby
10
star
41

gem_tools

Ruby
9
star
42

sinatra-template

base template for classic sinatra apps
Ruby
9
star
43

rack-graph

Generate a tree displaying all your Rack middleware
Ruby
9
star
44

refine

Start using refine, today. Be ready for Ruby 2.0!
Ruby
9
star
45

sinatra-more-server

Add more servers to Sinatra::Base#run! (part of BigBand).
Ruby
9
star
46

monkey-lib

Making ruby extension frameworks pluggable (extracted from BigBand).
Ruby
8
star
47

gerippe

Monk skeleton with compass and rspec.
JavaScript
7
star
48

sinatra-test-helper

Test helper for Sinatra (extracted from BigBand).
Ruby
7
star
49

astro-data

Pre-calculated lunar and solar cycles.
7
star
50

rkh.im

click here to add a description
JavaScript
7
star
51

sinatra.fy

Sinatra in Fancy
Fancy
7
star
52

ruby_installer

Depraced, I switched to rvm.
7
star
53

twp

TWP3 in Ruby
Ruby
7
star
54

json-csrf

Ruby
6
star
55

ruby-xlib

Some base libraries for writing a windowmanager in ruby.
C
6
star
56

wonko-web-server

experimental preforking rack handler. and by experimental I mean: no tests.
Ruby
6
star
57

serv

simple, threaded rack handler (webserver)
Ruby
6
star
58

sinatra-web-inspector

DEPRECATED
Ruby
5
star
59

proposals

contact me if you want me to give a talk somewhere
Ruby
5
star
60

donewunder

Ruby
5
star
61

priest

Priest is a more advanced command line tool for your monk projects.
Ruby
5
star
62

slaml

C
4
star
63

mw_api

Fast ruby client library for using MediaWiki's API.
Ruby
4
star
64

stored_hash

Synchronize a hash with a yaml file.
Ruby
4
star
65

circleci-ios

iOS app for Circle CI
Objective-C
3
star
66

prefix

Ruby
3
star
67

github-moderator

Allows someone who is not an owner to add users to a Github team.
Ruby
3
star
68

sinatra-extension

Mixin to ease Sinatra extension development (part of BigBand).
Ruby
3
star
69

dart

Dash on Rubinius
Ruby
3
star
70

cool-app

Ruby
3
star
71

deferrable

Callback indirection for JavaScript
JavaScript
3
star
72

redcar-align

Auto-align a text section in Redcar (Ctrl+Q)
Ruby
3
star
73

minimal-redjs

js + ruby
Ruby
2
star
74

socialshareprivacy

this is just a mirror
JavaScript
2
star
75

reloader-shootout

RSoC 2010: Ruby Reloader Benchmarks
Ruby
2
star
76

bundler_test

Ruby
2
star
77

maglev-experiments

Ruby
2
star
78

responsive

Responsive CSS breakpoints that respect a user's font size settings, and uses layers (no more !important).
SCSS
2
star
79

es-lab

Unofficial git mirror of the es-lab svn repo.
JavaScript
2
star
80

sinatra-decompile

Recreate string patterns from Sinatra routes
Ruby
2
star
81

playground

Ruby
1
star
82

travis-test-staging

Test repo on travis-staging
Ruby
1
star
83

test

1
star
84

travis-encrypt-file-example

1
star
85

maxcube.rb

Ruby
1
star
86

travis-surveillance

Veille sur un projet.
Ruby
1
star
87

travis-osx-test

1
star
88

reset

Yet another CSS/Sass reset.
SCSS
1
star
89

play

1
star