Module: FrenchTaxSystem::NueFormulas

Extended by:
NueFormulas
Included in:
NueFormulas
Defined in:
lib/nue_formulas.rb

Constant Summary collapse

PROPERTY_INCOME_STANDARD_ALLOWANCE =

Constants

0.3
CAPPED_NEGATIVE_NET_TAXABLE_INCOME_AMOUNT =
10_700

Instance Method Summary collapse

Instance Method Details

#calc_deductible_expenses_regimen_net_taxable_property_income_amount(simulation, postponed_negative_taxable_property_income_from_previous_fiscal_year, investment_fiscal_year) ⇒ Hash

Calculate net taxable property income for ‘Reel’ fiscal_regimen

Returns:

  • (Hash)

    a hash made of the net taxable property income (euros) and other values



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/nue_formulas.rb', line 79

def calc_deductible_expenses_regimen_net_taxable_property_income_amount(simulation, postponed_negative_taxable_property_income_from_previous_fiscal_year, investment_fiscal_year)
  # Calculate deductible expenses from this fiscal year
  deductible_expenses = calc_deductible_expenses_sum(simulation, investment_fiscal_year)

  # Calculate gross taxable property income amount depending on fiscal year and with postponed negative taxable property income from previous fiscal year
  gross_taxable_property_income_amount = calc_gross_taxable_property_income_amount(simulation, deductible_expenses, postponed_negative_taxable_property_income_from_previous_fiscal_year)

  if gross_taxable_property_income_amount >= 0
    # Return a hash with corresponding values
    {
      net_taxable_property_income_amount: gross_taxable_property_income_amount,
      negative_taxable_property_income?: false,
      negative_taxable_property_income_amount_to_postpone: 0
    }
  elsif gross_taxable_property_income_amount.negative?
    # Cap negativity of net taxable amount and postpone negative taxable if remaining
    calc_net_taxable_property_income_repartition(simulation, gross_taxable_property_income_amount)
  end
end

#calc_deductible_expenses_sum(simulation, investment_fiscal_year) ⇒ Float

Calculate the sum of deductible expenses for this fiscal year

Returns:

  • (Float)

    the sum of deductible expenses for this fiscal year (euros)



125
126
127
128
129
130
131
132
133
134
135
# File 'lib/nue_formulas.rb', line 125

def calc_deductible_expenses_sum(simulation, investment_fiscal_year)
  if investment_fiscal_year == 1
    FrenchTaxSystem::REAL_REGIMEN_DEDUCTIBLE_EXPENSES[:fiscal_year1].map do |expense|
      simulation.key?(expense.to_sym) ? simulation[expense.to_sym] : 0
    end.sum
  elsif investment_fiscal_year >= 2
    FrenchTaxSystem::REAL_REGIMEN_DEDUCTIBLE_EXPENSES[:fiscal_year2].map do |expense|
      simulation.key?(expense.to_sym) ? simulation[expense.to_sym] : 0
    end.sum
  end
end

#calc_flat_rate_regimen_net_taxable_property_income_amount(simulation) ⇒ Hash

Calculate net taxable property income for ‘Forfait’ fiscal_regimen

Returns:

  • (Hash)

    a hash made of the net taxable property income (euros) and other values



51
52
53
54
55
56
57
58
# File 'lib/nue_formulas.rb', line 51

def calc_flat_rate_regimen_net_taxable_property_income_amount(simulation)
  net_taxable_property_income_amount = simulation[:house_rent_amount_per_year] * (1 - PROPERTY_INCOME_STANDARD_ALLOWANCE)
  {
    net_taxable_property_income_amount: net_taxable_property_income_amount,
    negative_taxable_property_income?: false,
    negative_taxable_property_income_amount_to_postpone: 0
  }
end

#calc_gross_taxable_property_income_amount(simulation, deductible_expenses, postponed_negative_taxable_property_income_from_previous_fiscal_year) ⇒ Float

Calculate the gross taxable property income amount

Returns:

  • (Float)

    the gross taxable property income amount



107
108
109
# File 'lib/nue_formulas.rb', line 107

def calc_gross_taxable_property_income_amount(simulation, deductible_expenses, postponed_negative_taxable_property_income_from_previous_fiscal_year)
  simulation[:house_rent_amount_per_year] - deductible_expenses - postponed_negative_taxable_property_income_from_previous_fiscal_year
end

#calc_net_taxable_property_income_amount(simulation, postponed_negative_taxable_property_income_from_previous_fiscal_year, investment_fiscal_year) ⇒ Hash

Methods Calculate the net taxable income generated from the property investment

Returns:

  • (Hash)

    fiscal_year* the corresponding year * as requested in @params



32
33
34
35
36
37
38
39
40
# File 'lib/nue_formulas.rb', line 32

def calc_net_taxable_property_income_amount(simulation, postponed_negative_taxable_property_income_from_previous_fiscal_year, investment_fiscal_year)
  # Calculate net taxable property income amount thks to fiscal regimen
  case simulation[:fiscal_regimen]
  when "Forfait"
    calc_flat_rate_regimen_net_taxable_property_income_amount(simulation)
  when "Réel"
    calc_deductible_expenses_regimen_net_taxable_property_income_amount(simulation, postponed_negative_taxable_property_income_from_previous_fiscal_year, investment_fiscal_year)
  end
end

#calc_net_taxable_property_income_repartition(simulation, gross_taxable_property_income_amount) ⇒ Hash

Calculate and cap if necessary the negative taxable income and postpone negative taxable if remaining

Returns:

  • (Hash)

    a hash made of the net taxable property income (euros) and other values



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/nue_formulas.rb', line 148

def calc_net_taxable_property_income_repartition(simulation, gross_taxable_property_income_amount)
  property_income_minus_loan_interet_cost = calc_property_income_minus_loan_interet_cost(simulation)

  # If property_income_minus_loan_interet_cost is positive, we deduct all expenses from this fiscal year gross_taxable_property_income_amount and report what's left to next fiscal years
  if property_income_minus_loan_interet_cost.positive? && gross_taxable_property_income_amount.abs <= CAPPED_NEGATIVE_NET_TAXABLE_INCOME_AMOUNT
    {
      net_taxable_property_income_amount: gross_taxable_property_income_amount,
      negative_taxable_property_income?: true,
      negative_taxable_property_income_amount_to_postpone: 0
    }
  elsif property_income_minus_loan_interet_cost.positive? && gross_taxable_property_income_amount.abs > CAPPED_NEGATIVE_NET_TAXABLE_INCOME_AMOUNT
    {
      net_taxable_property_income_amount: - CAPPED_NEGATIVE_NET_TAXABLE_INCOME_AMOUNT,
      negative_taxable_property_income?: true,
      negative_taxable_property_income_amount_to_postpone: (gross_taxable_property_income_amount + CAPPED_NEGATIVE_NET_TAXABLE_INCOME_AMOUNT).abs
    }
  # If property_income_minus_loan_interet_cost is negative, we deduct all expenses EXCEPT credit interest costs from this fiscal year gross_taxable_property_income_amount and report what's left + credit interest cost to next fiscal years
  elsif property_income_minus_loan_interet_cost.negative? && gross_taxable_property_income_amount.abs <= CAPPED_NEGATIVE_NET_TAXABLE_INCOME_AMOUNT
    {
      net_taxable_property_income_amount: gross_taxable_property_income_amount + simulation[:credit_loan_cumulative_interests_paid_for_year_two],
      negative_taxable_property_income?: true,
      negative_taxable_property_income_amount_to_postpone: simulation[:credit_loan_cumulative_interests_paid_for_year_two]
    }
  elsif property_income_minus_loan_interet_cost.negative? && gross_taxable_property_income_amount.abs > CAPPED_NEGATIVE_NET_TAXABLE_INCOME_AMOUNT && (gross_taxable_property_income_amount.abs - simulation[:credit_loan_cumulative_interests_paid_for_year_two]) > CAPPED_NEGATIVE_NET_TAXABLE_INCOME_AMOUNT
    {
      net_taxable_property_income_amount: - CAPPED_NEGATIVE_NET_TAXABLE_INCOME_AMOUNT,
      negative_taxable_property_income?: true,
      negative_taxable_property_income_amount_to_postpone: (gross_taxable_property_income_amount + CAPPED_NEGATIVE_NET_TAXABLE_INCOME_AMOUNT).abs
    }
  elsif property_income_minus_loan_interet_cost.negative? && gross_taxable_property_income_amount.abs > CAPPED_NEGATIVE_NET_TAXABLE_INCOME_AMOUNT && (gross_taxable_property_income_amount.abs - simulation[:credit_loan_cumulative_interests_paid_for_year_two]) <= CAPPED_NEGATIVE_NET_TAXABLE_INCOME_AMOUNT
    {
      net_taxable_property_income_amount: gross_taxable_property_income_amount + simulation[:credit_loan_cumulative_interests_paid_for_year_two],
      negative_taxable_property_income?: true,
      negative_taxable_property_income_amount_to_postpone: simulation[:credit_loan_cumulative_interests_paid_for_year_two]
    }
  end
end

#calc_property_income_minus_loan_interet_cost(simulation) ⇒ Float

Calculate the property income amount minus loan interest cost

Returns:

  • (Float)

    the property income amount minus loan interest cost that is used to determine negative net taxable income repartition



193
194
195
# File 'lib/nue_formulas.rb', line 193

def calc_property_income_minus_loan_interet_cost(simulation)
  simulation[:house_rent_amount_per_year] - simulation[:credit_loan_cumulative_interests_paid_for_year_two]
end