Skip to content

About

Sankt Gallen Canton (Switzerland) model for OpenFisca

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

OpenFisca model for Sankt Gallen Canton (Switzerland)

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_ch_sg 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 than 40000. This reform project would apply starting from 2017-01-01.

The files that are outside from the openfisca_ch_sg folder are used to set up the development environment.

Packaging your Country Package for Distribution

Country packages are Python distributions. You can choose to distribute your package automatically via the predefined continuous deployment system on GitHub Actions, or manually.

Automatic continuous deployment on GitHub

This repository is configured with a continuous deployment system to automate the distribution of your package via uv.

Setting up continuous deployment

To activate the continuous deployment:

  1. Create an account on PyPI if you don't already have one.
  2. Generate a token in your PyPI account. This token will allow GitHub Actions to securely upload new versions of your package to PyPI.
  3. Add this token to your GitHub repository's secrets under the name PYPI_TOKEN.

Once set up, changes to the main branch will trigger an automated workflow to build and publish your package to PyPI, making it available for uv installation.

Manual distribution

If you prefer to manually manage the release and distribution of your package, follow the guidelines provided by the Python Packaging Authority.

This involves detailed steps on preparing your package, creating distribution files, and uploading them to PyPI.

Install Instructions for Users and Contributors

This package requires Python 3.11. 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.

A. Minimal Installation

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.

Install this Country Package with uv

Install the Country Package:

uv add install openfisca-ch_sg

🎉 This OpenFisca Country Package is now installed and ready!

Next Steps

Depending on what you want to do with OpenFisca, you may want to install yet other packages:

B. Advanced Installation (Git Clone)

Follow this tutorial if you wish to:

  • create or change this Country Package's legislation;
  • contribute to the source code.

Clone this Country Package with Git

First, make sure Git is installed on your machine.

Set your working directory to the location where you want this OpenFisca Country Package cloned.

Clone this Country Package on your machine:

git clone git://github.com/openfisca/openfisca-CH-SG.git
cd openfisca-CH-SG

You can make sure that everything is working by running the provided tests with make test.

Learn more about tests

🎉 This OpenFisca Country Package is now installed and ready!

Next Steps

C. Contributing

  • Read CONTRIBUTING.
  • Open a pull request to the main branch of this repository.
  • Announce your changes as described in CONTRIBUTING.

Serve this Country Package with the OpenFisca Web API

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_ch_sg

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_ch_sg/situation_examples/couple.json \
  http://localhost:5000/calculate

About

Sankt Gallen Canton (Switzerland) model for OpenFisca

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages