From 22925c82f7eff7a8c69186814cc66fa01da1634c Mon Sep 17 00:00:00 2001 From: indigane Date: Fri, 30 Aug 2024 13:45:40 +0300 Subject: [PATCH] Fix depreciation multiplier not showing full decimals --- backend/hitas/calculations/max_prices/rules_pre_2011.py | 2 +- backend/hitas/calculations/max_prices/types.py | 2 +- .../test_api_apartment_max_price_calc_examples.py | 8 ++++---- backend/openapi.yaml | 6 ++---- frontend/src/common/schemas/apartment.ts | 2 +- .../components/ApartmentMaximumPriceBreakdownModal.tsx | 9 ++++----- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/backend/hitas/calculations/max_prices/rules_pre_2011.py b/backend/hitas/calculations/max_prices/rules_pre_2011.py index e489f53bb..421e9c5f1 100644 --- a/backend/hitas/calculations/max_prices/rules_pre_2011.py +++ b/backend/hitas/calculations/max_prices/rules_pre_2011.py @@ -171,7 +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, + depreciation_multiplier=str(depreciation_multiplier_for_apartment), ), ) diff --git a/backend/hitas/calculations/max_prices/types.py b/backend/hitas/calculations/max_prices/types.py index 716bee524..797024f9f 100644 --- a/backend/hitas/calculations/max_prices/types.py +++ b/backend/hitas/calculations/max_prices/types.py @@ -56,7 +56,7 @@ class CalculationVarsConstructionPriceIndexBefore2011(CommonCalculationVars): additional_work_during_construction: Decimal index_adjusted_additional_work_during_construction: Decimal apartment_improvements: MaxPriceImprovements - depreciation_multiplier: Decimal + depreciation_multiplier: str @dataclass class CalculationVarsMarketPriceIndexBefore2011(CommonCalculationVars): diff --git a/backend/hitas/tests/apis/apartment_max_price/test_api_apartment_max_price_calc_examples.py b/backend/hitas/tests/apis/apartment_max_price/test_api_apartment_max_price_calc_examples.py index b6c8eb9da..6d2230492 100644 --- a/backend/hitas/tests/apis/apartment_max_price/test_api_apartment_max_price_calc_examples.py +++ b/backend/hitas/tests/apis/apartment_max_price/test_api_apartment_max_price_calc_examples.py @@ -646,7 +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, + "depreciation_multiplier": "0.9324", }, "maximum_price": 181294.97, "valid_until": "2022-12-07", @@ -969,7 +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, + "depreciation_multiplier": "0.9892", }, "maximum_price": 235432.37, "valid_until": "2023-02-21", @@ -1114,7 +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, + "depreciation_multiplier": "0.9892", }, "maximum_price": 66203.58, "valid_until": "2023-02-21", @@ -1198,7 +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, + "depreciation_multiplier": "1", }, "maximum_price": 200000.0, "valid_until": "2003-09-01", diff --git a/backend/openapi.yaml b/backend/openapi.yaml index e33c2f028..a32c77f4d 100644 --- a/backend/openapi.yaml +++ b/backend/openapi.yaml @@ -6791,10 +6791,8 @@ components: example: 146.4 depreciation_multiplier: description: Depreciation multiplier for the apartment - type: number - minimum: 0 - maximum: 1 - example: 0.9 + type: string + example: '0.9999' ApartmentMaximumPriceImprovements2011Onwards: description: Improvement information used in the calculation diff --git a/frontend/src/common/schemas/apartment.ts b/frontend/src/common/schemas/apartment.ts index 34153df95..a51c4dd27 100644 --- a/frontend/src/common/schemas/apartment.ts +++ b/frontend/src/common/schemas/apartment.ts @@ -188,7 +188,7 @@ const IndexCalculationConstructionPriceIndexBefore2011Schema = IndexCalculationS interest_during_construction: number(), interest_during_construction_percentage: number(), housing_company_acquisition_price: number(), - depreciation_multiplier: number(), + depreciation_multiplier: string(), housing_company_assets: number(), apartment_share_of_housing_company_assets: number(), additional_work_during_construction: number(), diff --git a/frontend/src/features/apartment/components/ApartmentMaximumPriceBreakdownModal.tsx b/frontend/src/features/apartment/components/ApartmentMaximumPriceBreakdownModal.tsx index d9794a666..c08c9d9a4 100644 --- a/frontend/src/features/apartment/components/ApartmentMaximumPriceBreakdownModal.tsx +++ b/frontend/src/features/apartment/components/ApartmentMaximumPriceBreakdownModal.tsx @@ -241,11 +241,10 @@ const ConstructionPricePre2011Breakdown = ({ label="Yhtiön tarkistettu hankinta-arvo" value={calculation.calculation_variables.housing_company_acquisition_price} /> - +
+ +

{calculation.calculation_variables.depreciation_multiplier?.replace(".", ",")}

+