The country whose law is modelled here has a very simple tax and benefit system.
- It has a flat rate tax whose rates increase every year.
- On the first of December, 2015, it introduced a basic income for all its citizens of age who have no income.
- On the first of December, 2016, it removed the income condition, providing all its adult citizens with a basic income.
These elements are described in different folders. All the modelling happens within the openfisca_test
folder.
- The rates are in the
parameters
folder. - The formulas are in the
variables
folder. - This country package comes also with reforms in the
reforms
folder. This is optional: your country may exist without defining any reform.- In this country, there is a reform project aiming to modify the social security taxation, deleting the first bracket, raising the intermediary ones and adding a new bracket with a higher tax rate of
40 %
for people earning more than40000
. This reform project would apply starting from2017-01-01
.
- In this country, there is a reform project aiming to modify the social security taxation, deleting the first bracket, raising the intermediary ones and adding a new bracket with a higher tax rate of
The files that are outside from the openfisca_test
folder are used to set up the development environment.
Country packages are python distributions. To distribute your package via pip
, follow the steps given by the Python Packaging Authority.
This package requires Python 3.9. More recent versions should work, but are not tested.
All platforms that can execute Python are supported, which includes GNU/Linux, macOS and Microsoft Windows.
In order to limit dependencies conflicts, we recommend using a virtual environment with venv.
- A venv is a project specific environment created to suit the needs of the project you are working on.
To create a virtual environment, launch a terminal on your computer, cd
into your directory and follow these instructions:
python3 -m venv .venv # create a new virtual environment in the “.venv” folder, which will contain all dependencies
source .venv/bin/activate # activate the venv
You can now operate in the venv you just created.
You can deactivate that venv at any time with deactivate
.
🎉 You are now ready to install this OpenFisca Country Package!
Two install procedures are available. Pick procedure A or B below depending on how you plan to use this Country Package.
Follow this installation if you wish to:
- run calculations on a large population;
- create tax & benefits simulations;
- write an extension to this legislation (e.g. city specific tax & benefits);
- serve your Country Package with the OpenFisca Web API.
For more advanced uses, head to the Advanced Installation.
Inside your venv, check the prerequisites:
python --version # should print "Python 3.9.xx".
pip --version # should print at least 9.0.
# if not, run "pip install --upgrade pip"
Install the Country Package:
pip install openfisca-test
pip
is dependent on its maintainers publishing said package.
🎉 This OpenFisca Country Package is now installed and ready!
- To learn how to use OpenFisca, follow our tutorials.
- To serve this Country Package, serve the OpenFisca Web API.
Depending on what you want to do with OpenFisca, you may want to install yet other packages in your venv:
- To install extensions or write on top of this Country Package, head to the Extensions documentation.
- To plot simulation results, try matplotlib.
- To manage data, check out pandas.
Follow this tutorial if you wish to:
- create or change this Country Package's legislation;
- contribute to the source code.
First, make sure Git is installed on your machine.
Set your working directory to the location where you want this OpenFisca Country Package cloned.
Inside your venv, check the prerequisites:
python --version # should print "Python 3.9.xx".
Clone this Country Package on your machine:
git clone git://github.com/Ndpnt/openfisca-test.git.git
cd openfisca-test.git
pip install --upgrade pip build twine
pip install --editable .[dev] --upgrade
You can make sure that everything is working by running the provided tests with make test
.
🎉 This OpenFisca Country Package is now installed and ready!
- To write new legislation, read the Coding the legislation section to know how to write legislation.
- To contribute to the code, read our Contribution Guidebook.
If you are considering building a web application, you can use the packaged OpenFisca Web API with your Country Package.
To serve the Openfisca Web API locally, run:
openfisca serve --port 5000 --country-package openfisca_test
Or use the quick-start Make command:
make serve-local
To read more about the openfisca serve
command, check out its documentation.
You can make sure that your instance of the API is working by requesting:
curl "http://localhost:5000/spec"
This endpoint returns the Open API specification of your API.
🎉 This OpenFisca Country Package is now served by the OpenFisca Web API! To learn more, go to the OpenFisca Web API documentation.
You can test your new Web API by sending it example JSON data located in the situation_examples
folder.
curl -X POST -H "Content-Type: application/json" \
-d @./openfisca_test/situation_examples/couple.json \
http://localhost:5000/calculate