Skip to content

Commit

Permalink
Add depreciation multiplier to ApartmentMaximumPriceBreakdownModal
Browse files Browse the repository at this point in the history
  • Loading branch information
indigane committed Aug 27, 2024
1 parent 533f9ec commit 1c4cb46
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/hitas/calculations/max_prices/rules_pre_2011.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ def calculate_construction_price_index_max_price(
message="Cannot create max price calculation for an apartment without a first sale purchase price.",
)

depreciation_multiplier_for_apartment = depreciation_multiplier(
months_between_dates(apartment.completion_date, calculation_date)
)
housing_company_index_adjusted_acquisition_price = (
apartment.completion_date_realized_housing_company_acquisition_price
* apartment.calculation_date_cpi
* depreciation_multiplier(months_between_dates(apartment.completion_date, calculation_date))
* depreciation_multiplier_for_apartment
) / apartment.completion_date_cpi

hc_improvements_result = calculate_housing_company_improvements_pre_2011_construction_price_index(
Expand Down Expand Up @@ -168,6 +171,7 @@ def calculate_construction_price_index_max_price(
completion_date_index=apartment.completion_date_cpi,
calculation_date=calculation_date,
calculation_date_index=apartment.calculation_date_cpi,
depreciation_multiplier=depreciation_multiplier_for_apartment,
),
)

Expand Down
1 change: 1 addition & 0 deletions backend/hitas/calculations/max_prices/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class CalculationVarsConstructionPriceIndexBefore2011(CommonCalculationVars):
additional_work_during_construction: Decimal
index_adjusted_additional_work_during_construction: Decimal
apartment_improvements: MaxPriceImprovements
depreciation_multiplier: Decimal

@dataclass
class CalculationVarsMarketPriceIndexBefore2011(CommonCalculationVars):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ def test__api__apartment_max_price__market_price_index__pre_2011(api_client: Hit
"completion_date_index": 244.9,
"calculation_date": "2022-09-07",
"calculation_date_index": 364.4,
"depreciation_multiplier": 0.93,
},
"maximum_price": 181294.97,
"valid_until": "2022-12-07",
Expand Down Expand Up @@ -968,6 +969,7 @@ def test__api__apartment_max_price__construction_price_index__pre_2011(api_clien
"completion_date_index": 296.10,
"calculation_date": "2022-11-21",
"calculation_date_index": 364.6,
"depreciation_multiplier": 0.99,
},
"maximum_price": 235432.37,
"valid_until": "2023-02-21",
Expand Down Expand Up @@ -1112,6 +1114,7 @@ def test__api__apartment_max_price__construction_price_index__pre_2011(api_clien
"completion_date_index": 1337.0,
"calculation_date": "2022-11-21",
"calculation_date_index": 364.6,
"depreciation_multiplier": 0.99,
},
"maximum_price": 66203.58,
"valid_until": "2023-02-21",
Expand Down Expand Up @@ -1195,6 +1198,7 @@ def test__api__apartment_max_price__pre_2011__no_improvements(api_client: HitasA
"completion_date_index": 100.0,
"calculation_date": "2003-06-01",
"calculation_date_index": 200.0,
"depreciation_multiplier": 1.0,
},
"maximum_price": 200000.0,
"valid_until": "2003-09-01",
Expand Down
7 changes: 7 additions & 0 deletions backend/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1820,6 +1820,7 @@ paths:
completion_date_index: 244.9
calculation_date: "2022-09-07"
calculation_date_index: 364.4
depreciation_multiplier: 0.98
maximum_price: 180749.97
valid_until: "2022-12-07"
maximum: false
Expand Down Expand Up @@ -6781,6 +6782,12 @@ components:
type: number
minimum: 0
example: 146.4
depreciation_multiplier:
description: Depreciation multiplier for the apartment
type: number
minimum: 0
maximum: 1
example: 0.9

ApartmentMaximumPriceImprovements2011Onwards:
description: Improvement information used in the calculation
Expand Down
1 change: 1 addition & 0 deletions frontend/src/common/schemas/apartment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ const IndexCalculationConstructionPriceIndexBefore2011Schema = IndexCalculationS
interest_during_construction: number(),
interest_during_construction_percentage: number(),
housing_company_acquisition_price: number(),
depreciation_multiplier: number(),
housing_company_assets: number(),
apartment_share_of_housing_company_assets: number(),
additional_work_during_construction: number(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ const ConstructionPricePre2011Breakdown = ({
label="Yhtiön tarkistettu hankinta-arvo"
value={calculation.calculation_variables.housing_company_acquisition_price}
/>
<BreakdownValue
label="Poistokerroin"
value={calculation.calculation_variables.depreciation_multiplier}
unit=""
/>
<BreakdownValue
label="+ Kiinteistön parannukset"
value={calculation.calculation_variables.housing_company_improvements.summary.value_for_apartment}
Expand Down

0 comments on commit 1c4cb46

Please sign in to comment.