Extensions allow you to define new variables or parameters for a tax and benefit system, while keeping their code separated from the main country package. They can only add variables and parameters to the tax and benefit system: they cannot modify or neutralise existing ones.
They are for instance used to code local benefits.
Extensions are sometimes confused with another mechanism: reforms. Read more about their respective uses.
Extensions can be manually loaded to a tax and benefit system using the load_extension method.
The architecture of an extension folder is the following:
{extension_name}/ # The folder name is by convention the name of the extension.
{extension_name}/__init__.py # Empty file.
{extension_name}/{some_formula}.py # File containing formulas
{extension_name}/{other_formula}.py
{extension_name}/parameters # Optional parameters directory.
{extension_name}/parameters/{new_tax}
{extension_name}/parameters/{new_tax}/{rate}.yaml
{extension_name}/tests/{some_formula}.yaml # Optional test files
{extension_name}/tests/{other_formula}.yaml
All python files located directly in {extension_name}/
are imported in the tax and benefit system.
The syntax of the formulas within extension python files is the same than in the general country package formulas (e.g. from openfisca_france.model.base import *
).
Variables inside an extension should not have the same name as any existing formula, nor as any formula in another extension being used.