french_tax_system 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile +0 -1
- data/Gemfile.lock +1 -22
- data/lib/french_tax_system.rb +157 -1
- data/lib/french_tax_system/version.rb +1 -1
- data/lib/lmnp_formulas.rb +9 -0
- data/lib/nue_formulas.rb +24 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 011b928965029163173e68112ae51080948046dbe3d403bb4fa1a2748ad1ecc8
|
4
|
+
data.tar.gz: 77a452106b4936fb835999bcd715b56829b2c0c3fcbcc50f7991543ded67799f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33cd93886945b241a613c41d6b744be37a950c1677e3cb1a4bd800a140747abb22cdad38b9ff69a76712a82afef05b3513ab692edf1748b11c5f8ca15f35a2b3
|
7
|
+
data.tar.gz: 29ae86383f5c6d7a19d6a671f62a71d8fdb919b17aea7406c68af5b7268e01b2ae0f742e4c0f0c84de425b22c18f34348377f2fd751765fdcc5776e9fe2ae666
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,20 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
french_tax_system (0.1.
|
4
|
+
french_tax_system (0.1.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.4.2)
|
10
9
|
diff-lcs (1.4.4)
|
11
|
-
parallel (1.20.1)
|
12
|
-
parser (3.0.1.1)
|
13
|
-
ast (~> 2.4.1)
|
14
|
-
rainbow (3.0.0)
|
15
10
|
rake (13.0.3)
|
16
|
-
regexp_parser (2.1.1)
|
17
|
-
rexml (3.2.5)
|
18
11
|
rspec (3.10.0)
|
19
12
|
rspec-core (~> 3.10.0)
|
20
13
|
rspec-expectations (~> 3.10.0)
|
@@ -28,19 +21,6 @@ GEM
|
|
28
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
22
|
rspec-support (~> 3.10.0)
|
30
23
|
rspec-support (3.10.2)
|
31
|
-
rubocop (1.16.0)
|
32
|
-
parallel (~> 1.10)
|
33
|
-
parser (>= 3.0.0.0)
|
34
|
-
rainbow (>= 2.2.2, < 4.0)
|
35
|
-
regexp_parser (>= 1.8, < 3.0)
|
36
|
-
rexml
|
37
|
-
rubocop-ast (>= 1.7.0, < 2.0)
|
38
|
-
ruby-progressbar (~> 1.7)
|
39
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
40
|
-
rubocop-ast (1.7.0)
|
41
|
-
parser (>= 3.0.1.1)
|
42
|
-
ruby-progressbar (1.11.0)
|
43
|
-
unicode-display_width (2.0.0)
|
44
24
|
|
45
25
|
PLATFORMS
|
46
26
|
x86_64-linux
|
@@ -49,7 +29,6 @@ DEPENDENCIES
|
|
49
29
|
french_tax_system!
|
50
30
|
rake (~> 13.0)
|
51
31
|
rspec (~> 3.0)
|
52
|
-
rubocop (~> 1.7)
|
53
32
|
|
54
33
|
BUNDLED WITH
|
55
34
|
2.2.19
|
data/lib/french_tax_system.rb
CHANGED
@@ -4,5 +4,161 @@ require_relative "french_tax_system/version"
|
|
4
4
|
|
5
5
|
module FrenchTaxSystem
|
6
6
|
class Error < StandardError; end
|
7
|
-
|
7
|
+
|
8
|
+
# Constants
|
9
|
+
INCOME_TAXES_SCALE = {
|
10
|
+
year2021: [
|
11
|
+
{ family_quotient_amount: { start_scale: 0, end_scale: 10_084 }, tax: 0 },
|
12
|
+
{ family_quotient_amount: { start_scale: 10_085, end_scale: 25_710 }, tax: 0.11 },
|
13
|
+
{ family_quotient_amount: { start_scale: 25_711, end_scale: 73_516 }, tax: 0.3 },
|
14
|
+
{ family_quotient_amount: { start_scale: 73_517, end_scale: 158_122 }, tax: 0.41 },
|
15
|
+
{ family_quotient_amount: { start_scale: 158_123, end_scale: Float::INFINITY }, tax: 0.45 }
|
16
|
+
]
|
17
|
+
}.freeze
|
18
|
+
|
19
|
+
FISCAL_NB_PARTS_FOR_MARRIED_COUPLE = 2
|
20
|
+
FISCAL_NB_PARTS_FOR_SINGLE_PERSON = 1
|
21
|
+
|
22
|
+
FAMILY_QUOTIENT_CAPPING_AMOUNT = {
|
23
|
+
## Per half fiscal parts for children
|
24
|
+
year2021: 1570
|
25
|
+
}.freeze
|
26
|
+
|
27
|
+
REVENUES_STANDARD_ALLOWANCE = 0.1
|
28
|
+
|
29
|
+
REAL_REGIMEN_DEDUCTIBLE_EXPENSES_FOR_YEAR_TWO = %w[house_landlord_charges_amount_per_year
|
30
|
+
house_property_management_amount_per_year house_insurance_gli_amount_per_year house_insurance_pno_amount_per_year house_property_tax_amount_per_year credit_loan_cumulative_interests_paid_for_year_two credit_loan_insurance_amount_per_year].freeze
|
31
|
+
|
32
|
+
# Methods
|
33
|
+
## Main method
|
34
|
+
def test
|
35
|
+
"test me"
|
36
|
+
end
|
37
|
+
|
38
|
+
def calc_income_tax_amount_per_year_with_property_income_of(net_taxable_property_income_amount)
|
39
|
+
global_net_taxable_income_amount = calc_global_net_taxable_amount_with_property_income_of(net_taxable_property_income_amount)
|
40
|
+
|
41
|
+
fiscal_nb_parts = calc_fiscal_nb_parts
|
42
|
+
|
43
|
+
family_quotient_amount = calc_family_quotient_amount(global_net_taxable_income_amount, fiscal_nb_parts)
|
44
|
+
current_year = Date.today.year
|
45
|
+
|
46
|
+
aggregated_tax_amount = calc_aggregated_tax_amount(family_quotient_amount, current_year)
|
47
|
+
|
48
|
+
(aggregated_tax_amount * fiscal_nb_parts).floor
|
49
|
+
end
|
50
|
+
|
51
|
+
def calc_not_capped_income_tax_amount_per_year_with_property_income_of(net_taxable_property_income_amount)
|
52
|
+
global_net_taxable_income_amount = calc_global_net_taxable_amount_with_property_income_of(net_taxable_property_income_amount)
|
53
|
+
|
54
|
+
fiscal_nb_parts = calc_fiscal_nb_parts
|
55
|
+
|
56
|
+
family_quotient_amount = calc_family_quotient_amount(global_net_taxable_income_amount, fiscal_nb_parts)
|
57
|
+
current_year = Date.today.year
|
58
|
+
|
59
|
+
aggregated_tax_amount = calc_aggregated_tax_amount(family_quotient_amount, current_year)
|
60
|
+
|
61
|
+
(aggregated_tax_amount * fiscal_nb_parts).floor
|
62
|
+
end
|
63
|
+
|
64
|
+
def calc_capped_income_tax_amount_per_year_with_property_income_of(net_taxable_property_income_amount)
|
65
|
+
global_net_taxable_income_amount = calc_global_net_taxable_amount_with_property_income_of(net_taxable_property_income_amount)
|
66
|
+
|
67
|
+
fiscal_nb_parts = case fiscal_marital_status
|
68
|
+
when "Célibataire" then 1
|
69
|
+
when "Marié / Pacsé" then 2
|
70
|
+
end
|
71
|
+
|
72
|
+
family_quotient_amount = calc_family_quotient_amount(global_net_taxable_income_amount, fiscal_nb_parts)
|
73
|
+
current_year = Date.today.year
|
74
|
+
|
75
|
+
aggregated_tax_amount = calc_aggregated_tax_amount(family_quotient_amount, current_year)
|
76
|
+
|
77
|
+
(aggregated_tax_amount * fiscal_nb_parts).floor
|
78
|
+
end
|
79
|
+
|
80
|
+
def calc_net_taxable_property_income_amount
|
81
|
+
case fiscal_status
|
82
|
+
when "Vide"
|
83
|
+
NueFormulas.calc_net_taxable_property_income_amount(self)
|
84
|
+
when "LMNP"
|
85
|
+
LmnpFormulas.calc_net_taxable_property_income_amount(self)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def calc_income_taxes_scale_with_property_income_of(net_taxable_property_income_amount)
|
90
|
+
global_net_taxable_income_amount = calc_global_net_taxable_amount_with_property_income_of(net_taxable_property_income_amount)
|
91
|
+
|
92
|
+
fiscal_nb_parts = calc_fiscal_nb_parts
|
93
|
+
|
94
|
+
family_quotient_amount = calc_family_quotient_amount(global_net_taxable_income_amount, fiscal_nb_parts)
|
95
|
+
current_year = Date.today.year
|
96
|
+
|
97
|
+
income_taxes_scale = INCOME_TAXES_SCALE["year#{current_year}".to_sym]
|
98
|
+
|
99
|
+
income_taxes_scale.find { |scale| family_quotient_amount <= scale[:family_quotient_amount][:end_scale] }
|
100
|
+
end
|
101
|
+
|
102
|
+
def calc_global_net_taxable_amount_with_property_income_of(net_taxable_property_income_amount)
|
103
|
+
((fiscal_revenues_p1 + fiscal_revenues_p2) * (1 - REVENUES_STANDARD_ALLOWANCE)) + net_taxable_property_income_amount
|
104
|
+
end
|
105
|
+
|
106
|
+
def calc_fiscal_nb_parts
|
107
|
+
case fiscal_marital_status
|
108
|
+
when "Marié / Pacsé"
|
109
|
+
FISCAL_NB_PARTS_FOR_MARRIED_COUPLE + calc_fiscal_nb_parts_incurred_from_children
|
110
|
+
when "Célibataire"
|
111
|
+
FISCAL_NB_PARTS_FOR_SINGLE_PERSON + calc_fiscal_nb_parts_incurred_from_children
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def calc_fiscal_nb_parts_incurred_from_children
|
116
|
+
# Detail of calculation method in GitHub wiki: https://github.com/Mth0158/mini-keyz/wiki/French-tax-system
|
117
|
+
total_nb_children = fiscal_nb_dependent_children + fiscal_nb_alternate_custody_children
|
118
|
+
|
119
|
+
if total_nb_children <= 2
|
120
|
+
0.5 * fiscal_nb_dependent_children + 0.25 * fiscal_nb_alternate_custody_children
|
121
|
+
|
122
|
+
elsif total_nb_children >= 3
|
123
|
+
|
124
|
+
if fiscal_nb_dependent_children == 0
|
125
|
+
0.5 + (fiscal_nb_alternate_custody_children - 2) * 0.5
|
126
|
+
|
127
|
+
elsif fiscal_nb_dependent_children == 1
|
128
|
+
if fiscal_nb_alternate_custody_children == 2
|
129
|
+
1.25
|
130
|
+
elsif fiscal_nb_alternate_custody_children >= 3
|
131
|
+
1.25 + (fiscal_nb_alternate_custody_children - 2) * 0.5
|
132
|
+
end
|
133
|
+
|
134
|
+
elsif fiscal_nb_dependent_children == 2
|
135
|
+
1 + fiscal_nb_alternate_custody_children * 0.5
|
136
|
+
|
137
|
+
elsif fiscal_nb_dependent_children >= 3
|
138
|
+
2 + fiscal_nb_alternate_custody_children * 0.5
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def calc_family_quotient_amount(global_net_taxable_income_amount, fiscal_nb_parts)
|
144
|
+
global_net_taxable_income_amount / fiscal_nb_parts
|
145
|
+
end
|
146
|
+
|
147
|
+
def calc_family_quotient_capped_amount(_e)
|
148
|
+
"ee"
|
149
|
+
end
|
150
|
+
|
151
|
+
def calc_aggregated_tax_amount(family_quotient_amount, current_year)
|
152
|
+
income_taxes_scale = INCOME_TAXES_SCALE["year#{current_year}".to_sym]
|
153
|
+
|
154
|
+
income_taxes_scale.map do |scale|
|
155
|
+
if family_quotient_amount < scale[:family_quotient_amount][:start_scale]
|
156
|
+
0
|
157
|
+
elsif family_quotient_amount >= scale[:family_quotient_amount][:start_scale] && family_quotient_amount < scale[:family_quotient_amount][:end_scale]
|
158
|
+
(family_quotient_amount - scale[:family_quotient_amount][:start_scale]) * scale[:tax]
|
159
|
+
elsif family_quotient_amount >= scale[:family_quotient_amount][:end_scale]
|
160
|
+
(scale[:family_quotient_amount][:end_scale] - scale[:family_quotient_amount][:start_scale]) * scale[:tax]
|
161
|
+
end
|
162
|
+
end.sum
|
163
|
+
end
|
8
164
|
end
|
data/lib/nue_formulas.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FrenchTaxSystem
|
4
|
+
class NueFormulas
|
5
|
+
PROPERTY_INCOME_STANDARD_ALLOWANCE = 0.3
|
6
|
+
|
7
|
+
# def self.calc_income_tax_amount_for_year_two(args = {})
|
8
|
+
# net_taxable_property_income_amount = calc_net_taxable_property_income_amount_for_year_two(args)
|
9
|
+
# IncomeTaxesBaseFormulas.calc_income_tax_amount_per_year(args, net_taxable_property_income_amount)
|
10
|
+
# end
|
11
|
+
|
12
|
+
def self.calc_net_taxable_property_income_amount_for_year_two(simulation_instance)
|
13
|
+
case simulation_instance.fiscal_regimen
|
14
|
+
when "Réel"
|
15
|
+
deductible_expenses = IncomeTaxesFormulas::REAL_REGIMEN_DEDUCTIBLE_EXPENSES_FOR_YEAR_TWO.map do |expense|
|
16
|
+
simulation_instance.send(expense) || 0
|
17
|
+
end.sum
|
18
|
+
simulation_instance.house_rent_amount_per_year - deductible_expenses
|
19
|
+
when "Forfait"
|
20
|
+
simulation_instance.house_rent_amount_per_year * (1 - PROPERTY_INCOME_STANDARD_ALLOWANCE)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: french_tax_system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathieu EUSTACHY
|
@@ -48,6 +48,8 @@ files:
|
|
48
48
|
- french_tax_system.gemspec
|
49
49
|
- lib/french_tax_system.rb
|
50
50
|
- lib/french_tax_system/version.rb
|
51
|
+
- lib/lmnp_formulas.rb
|
52
|
+
- lib/nue_formulas.rb
|
51
53
|
homepage: https://github.com/Mth0158/french_tax_system
|
52
54
|
licenses:
|
53
55
|
- MIT
|