openfisca / openfisca-core

OpenFisca core engine. See other repositories for countries-specific code & data.
https://openfisca.org
GNU Affero General Public License v3.0
168 stars 75 forks source link

Feat add rate from bracket indice method to rate tax scale like #1114

Closed PiGo86 closed 2 years ago

PiGo86 commented 2 years ago

As suggested by @benjello, this PR is intended to allow, for a given tax scale, the determination of the tax rate according to the tax bracket indice.

This feature would be useful for a fix in openfisca-france : https://github.com/openfisca/openfisca-france/pull/1831#discussion_r835448750

New features

benjello commented 2 years ago

Thank you very much @PiGo86 for this PR

May I ask you to add to new useful methods very similar to what you already did ?:

Thanks !

PiGo86 commented 2 years ago

Thank you very much @PiGo86 for this PR

May I ask you to add to new useful methods very similar to what you already did ?:

* `rate_from_tax_base`

* `threshold_from_tax_base`

Thanks !

Sure!

For threshold_from_tax_base, which threshold should be returned? The lower one or the upper one? If it is the upper one, which value has to be returned for the last bracket?

benjello commented 2 years ago

The lower one !

PiGo86 commented 2 years ago

Ok, I have just added the two new methods (rate_from_tax_base and threshold_from_tax_base).

However, I wonder if it is appropriate to add the methods rate_from_bracket_indice and rate_from_tax_base to RateTaxScaleLike class.

Indeed, I understand that these methods are not really accurate for the LinearAverageRateTaxScale class, as the returned rate seems to be false in this context.

It should be OK for threshold_from_tax_base method.

In addition, I have moved all tests for these three methods in a new test_rate_tax_scale_like test file (it seemed more logical to me). Let me know if this is not convenient.

benjello commented 2 years ago

@PiGo86 : could you move rate_from_bracket_indice and rate_from_tax_base to MarginalRateTaxScale ?

Thanks again.

PiGo86 commented 2 years ago

Ok, done! :wink:

coveralls commented 2 years ago

Coverage Status

Coverage increased (+0.01%) to 78.922% when pulling ff61a9f56a1f93f7815889a78ace3c4c8f6c2c44 on PiGo86:feat-add-rate_from_bracket_indice-method-to-RateTaxScaleLike into 30fc3db38f5ba0483d92ff39d41c5682732eb261 on openfisca:master.

benjello commented 2 years ago

Thanks @PiGo86 !