Skip to content

Commit

Permalink
Add the toggle to service units
Browse files Browse the repository at this point in the history
  • Loading branch information
juho-kettunen-nc committed Nov 20, 2024
1 parent 151fb8e commit 1277eed
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 10 deletions.
10 changes: 0 additions & 10 deletions leasing/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,16 +659,6 @@ class Labels:
KUVA_NUP = "KuVa / Nuorisopalvelut"


def is_akv_or_kuva_service_unit_id(service_unit_id: int) -> bool:
akv_kuva_service_unit_ids = [
ServiceUnitId.AKV,
ServiceUnitId.KUVA_LIPA,
ServiceUnitId.KUVA_UPA,
ServiceUnitId.KUVA_NUP,
]
return service_unit_id in akv_kuva_service_unit_ids


class SapSalesOfficeNumber(Enum):
"""
In Finnish: SAP myyntitoimiston numero
Expand Down
5 changes: 5 additions & 0 deletions leasing/fixtures/service_unit.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"first_contract_number": null,
"default_receivable_type_rent": 1,
"default_receivable_type_collateral": 8,
"use_rent_override_receivable_type": false,
"created_at": "2021-11-22T08:00:00Z",
"modified_at": "2021-11-22T08:00:00Z"
}
Expand All @@ -35,6 +36,7 @@
"first_contract_number": 100000,
"default_receivable_type_rent": null,
"default_receivable_type_collateral": null,
"use_rent_override_receivable_type": true,
"created_at": "2023-09-04T12:00:00Z",
"modified_at": "2023-09-04T12:00:00Z"
}
Expand All @@ -55,6 +57,7 @@
"first_contract_number": 200000,
"default_receivable_type_rent": null,
"default_receivable_type_collateral": null,
"use_rent_override_receivable_type": true,
"created_at": "2023-09-04T12:00:00Z",
"modified_at": "2023-09-04T12:00:00Z"
}
Expand All @@ -75,6 +78,7 @@
"first_contract_number": 200000,
"default_receivable_type_rent": null,
"default_receivable_type_collateral": null,
"use_rent_override_receivable_type": true,
"created_at": "2023-09-04T12:00:00Z",
"modified_at": "2023-09-04T12:00:00Z"
}
Expand All @@ -95,6 +99,7 @@
"first_contract_number": 200000,
"default_receivable_type_rent": null,
"default_receivable_type_collateral": null,
"use_rent_override_receivable_type": true,
"created_at": "2023-09-04T12:00:00Z",
"modified_at": "2023-09-04T12:00:00Z"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 4.2.14 on 2024-11-20 11:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("leasing", "0080_alter_contact_options"),
]

operations = [
migrations.AddField(
model_name="serviceunit",
name="use_rent_override_receivable_type",
field=models.BooleanField(
default=False,
help_text="Use the override receivable type from rent in "
"automatic invoices, if it is present. When creating a rent, some "
"service units (such as AKV and KuVa) want to select a receivable "
"type to be used in future automatic invoices. This helps avoid "
"some technical difficulties in invoice XML generation. "
"Generation logic would otherwise be unaware of the desired "
"receivable type, if it is different from the service unit's "
"default receivable type, or the leasetype's receivable type.",
verbose_name="Use the override receivable type from rent in automatic invoices?",
),
),
]
15 changes: 15 additions & 0 deletions leasing/models/service_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ class ServiceUnit(TimeStampedSafeDeleteModel):
blank=True,
on_delete=models.PROTECT,
)
use_rent_override_receivable_type = models.BooleanField(
verbose_name=_(
"Use the override receivabletype from rent in automatic invoices?"
),
help_text=_(
"Use the override receivable type from rent in automatic invoices, if "
"it is present. When creating a rent, some service units (such as AKV "
"and KuVa) want to select a receivable type to be used in future "
"automatic invoices. This helps avoid some technical difficulties in "
"invoice XML generation. Generation logic would otherwise be unaware "
"of the desired receivable type, if it is different from the service "
"unit's default receivable type, or the leasetype's receivable type."
),
default=False,
)

recursive_get_related_skip_relations = [
"contacts",
Expand Down
1 change: 1 addition & 0 deletions leasing/serializers/service_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ class Meta:
"id",
"name",
# "description",
"use_rent_override_receivable_type",
)
1 change: 1 addition & 0 deletions leasing/viewsets/service_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ class ServiceUnitViewSet(ReadOnlyModelViewSet):
"id",
"name",
"description",
"use_rent_override_receivable_type",
)
ordering = ("name",)

0 comments on commit 1277eed

Please sign in to comment.