Skip to content

Commit

Permalink
rent model: add start_price_index
Browse files Browse the repository at this point in the history
  • Loading branch information
NC-jsAhonen committed Nov 22, 2024
1 parent 59c8998 commit 580681b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
20 changes: 20 additions & 0 deletions leasing/migrations/0082_rent_start_price_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.16 on 2024-11-21 11:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("leasing", "0081_rent_old_dwellings_in_housing_companies_price_index"),
]

operations = [
migrations.AddField(
model_name="rent",
name="start_price_index",
field=models.DecimalField(
decimal_places=1, max_digits=8, null=True, verbose_name="Index number"
),
),
]
16 changes: 16 additions & 0 deletions leasing/models/rent.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ class Rent(TimeStampedSafeDeleteModel):
null=True,
)

# In Finnish: Tasotarkistusindeksi vuokran alkaessa
start_price_index = models.DecimalField(
verbose_name=_("Index number"),
decimal_places=1,
max_digits=8,
null=True,
)

recursive_get_related_skip_relations = ["lease"]

class Meta:
Expand Down Expand Up @@ -822,6 +830,14 @@ def is_active_on_period(self, date_range_start, date_range_end):

return False

def set_start_price_index(self):
if self.old_dwellings_in_housing_companies_price_index:
start_index_number_yearly = IndexNumberYearly.objects.get(
index=self.old_dwellings_in_housing_companies_price_index,
year=self.start_date.year - 1,
)
self.start_price_index = start_index_number_yearly.number


class RentDueDate(TimeStampedSafeDeleteModel):
"""
Expand Down

0 comments on commit 580681b

Please sign in to comment.