Module: FrenchTaxSystem::LmnpFormulas

Extended by:
LmnpFormulas
Included in:
LmnpFormulas
Defined in:
lib/lmnp_formulas.rb

Constant Summary collapse

PROPERTY_INCOME_STANDARD_ALLOWANCE =

Constants

0.5
AVERAGE_AMORTIZATION_PROPERTY_DURATION =
33.00
AVERAGE_AMORTIZATION_FIRST_WORKS_DURATION =
20.00

Instance Method Summary collapse

Instance Method Details

#calc_amortization(expense, amortization_duration) ⇒ Float

Calculate the amortization for this fiscal year

Returns:

  • (Float)

    the amortization for this fiscal year (euros)



152
153
154
# File 'lib/lmnp_formulas.rb', line 152

def calc_amortization(expense, amortization_duration)
  expense / amortization_duration
end

#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



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/lmnp_formulas.rb', line 82

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 amortization for average property
  amortization_property = calc_amortization(simulation[:house_price_bought_amount], AVERAGE_AMORTIZATION_PROPERTY_DURATION)

  # Calculate amortization for first works
  amortization_first_works = calc_amortization(simulation[:house_first_works_amount], AVERAGE_AMORTIZATION_FIRST_WORKS_DURATION)

  # 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, amortization_property, amortization_first_works, 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)



134
135
136
137
138
139
140
141
142
143
144
# File 'lib/lmnp_formulas.rb', line 134

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



53
54
55
56
57
58
59
60
# File 'lib/lmnp_formulas.rb', line 53

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, amortization_property, amortization_first_works, 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



116
117
118
# File 'lib/lmnp_formulas.rb', line 116

def calc_gross_taxable_property_income_amount(simulation, deductible_expenses, amortization_property, amortization_first_works, postponed_negative_taxable_property_income_from_previous_fiscal_year)
  simulation[:house_rent_amount_per_year] - deductible_expenses - amortization_property - amortization_first_works - 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



34
35
36
37
38
39
40
41
42
# File 'lib/lmnp_formulas.rb', line 34

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



167
168
169
170
171
172
173
174
# File 'lib/lmnp_formulas.rb', line 167

def calc_net_taxable_property_income_repartition(_simulation, gross_taxable_property_income_amount)
  # gross_taxable_property_income_amount is necessarily negative because of conditional execution of this method
  {
    net_taxable_property_income_amount: 0,
    negative_taxable_property_income?: true,
    negative_taxable_property_income_amount_to_postpone: gross_taxable_property_income_amount.abs
  }
end