diff --git a/backend/benefit/applications/services/ahjo_payload.py b/backend/benefit/applications/services/ahjo_payload.py index f913ff96dc..5190113f59 100644 --- a/backend/benefit/applications/services/ahjo_payload.py +++ b/backend/benefit/applications/services/ahjo_payload.py @@ -1,6 +1,5 @@ -import uuid from datetime import datetime -from typing import List, Union +from typing import List from django.conf import settings from django.urls import reverse @@ -15,10 +14,12 @@ def _prepare_top_level_dict(application: Application, case_records: List[dict]) """Prepare the dictionary that is sent to Ahjo""" application_date = application.created_at.isoformat() application_year = application.created_at.year + # TODO: what value to use if application is submitted via paper? + manner_of_receipt = "sähköinen asiointi" title = f"Avustuksen myöntäminen, työllisyyspalvelut, \ työnantajan Helsinki-lisä vuonna {application.created_at.year}, \ työnantaja {application.company_name}" - + handler = application.calculation.handler case_dict = { "Title": title, "Acquired": application_date, @@ -36,6 +37,7 @@ def _prepare_top_level_dict(application: Application, case_records: List[dict]) {"Subject": "työllisyydenhoito"}, ], "PersonalData": "Sisältää erityisiä henkilötietoja", + "MannerOfReceipt": manner_of_receipt, "Reference": application.application_number, "Records": case_records, "Agents": [ @@ -48,7 +50,12 @@ def _prepare_top_level_dict(application: Application, case_records: List[dict]) "AddressStreet": application.company.street_address, "AddressPostalCode": application.company.postcode, "AddressCity": application.company.city, - } + }, + { + "Role": "draftsman", + "Name": f"{handler.last_name}, {handler.first_name}", + "ID": handler.ad_username, + }, ], } return case_dict @@ -72,7 +79,6 @@ def _prepare_record( record_title: str, record_type: str, acquired: datetime, - reference: Union[int, uuid.UUID], documents: List[dict], handler: User, publicity_class: str = "Salassa pidettävä", @@ -87,7 +93,6 @@ def _prepare_record( "SecurityReasons": ["JulkL (621/1999) 24.1 § 25 k"], "Language": "fi", "PersonalData": "Sisältää erityisiä henkilötietoja", - "Reference": str(reference), "Documents": documents, "Agents": [ { @@ -110,7 +115,6 @@ def _prepare_case_records( "Hakemus", "hakemus", application.created_at.isoformat(), - application.application_number, [_prepare_record_document_dict(pdf_summary)], handler, ) @@ -124,7 +128,6 @@ def _prepare_case_records( "Hakemuksen Liite", "liite", attachment.created_at.isoformat(), - attachment.id, [_prepare_record_document_dict(attachment)], handler, ) diff --git a/backend/benefit/applications/tests/conftest.py b/backend/benefit/applications/tests/conftest.py index a8c9a233d6..751c6b3afd 100755 --- a/backend/benefit/applications/tests/conftest.py +++ b/backend/benefit/applications/tests/conftest.py @@ -264,7 +264,6 @@ def ahjo_payload_record(decided_application): record_title = "Hakemus" record_type = "hakemus" acquired = application.created_at.isoformat() - reference = str(application.application_number) documents = [] agent = application.calculation.handler publicity_class = "Salassa pidettävä" @@ -277,7 +276,6 @@ def ahjo_payload_record(decided_application): "SecurityReasons": ["JulkL (621/1999) 24.1 § 25 k"], "Language": "fi", "PersonalData": "Sisältää erityisiä henkilötietoja", - "Reference": reference, "Documents": documents, "Agents": [ { @@ -295,6 +293,7 @@ def ahjo_open_case_top_level_dict(decided_application): title = f"Avustuksen myöntäminen, työllisyyspalvelut, \ työnantajan Helsinki-lisä vuonna {application.created_at.year}, \ työnantaja {application.company_name}" + handler = application.calculation.handler return { "Title": title, @@ -313,6 +312,7 @@ def ahjo_open_case_top_level_dict(decided_application): {"Subject": "työllisyydenhoito"}, ], "PersonalData": "Sisältää erityisiä henkilötietoja", + "MannerOfReceipt": "sähköinen asiointi", "Reference": application.application_number, "Records": [], "Agents": [ @@ -325,7 +325,12 @@ def ahjo_open_case_top_level_dict(decided_application): "AddressStreet": application.company.street_address, "AddressPostalCode": application.company.postcode, "AddressCity": application.company.city, - } + }, + { + "Role": "draftsman", + "Name": f"{handler.last_name}, {handler.first_name}", + "ID": handler.ad_username, + }, ], } diff --git a/backend/benefit/applications/tests/test_ahjo_payload.py b/backend/benefit/applications/tests/test_ahjo_payload.py index a946bbd332..78eeaae2da 100644 --- a/backend/benefit/applications/tests/test_ahjo_payload.py +++ b/backend/benefit/applications/tests/test_ahjo_payload.py @@ -19,7 +19,6 @@ def test_prepare_record(decided_application, ahjo_payload_record): ahjo_payload_record["Title"], ahjo_payload_record["Type"], application.created_at.isoformat(), - application.application_number, [], application.calculation.handler, ) @@ -73,7 +72,6 @@ def test_prepare_case_records(decided_application, settings): "SecurityReasons": ["JulkL (621/1999) 24.1 § 25 k"], "Language": "fi", "PersonalData": "Sisältää erityisiä henkilötietoja", - "Reference": str(application.application_number), "Documents": [_prepare_record_document_dict(fake_summary)], "Agents": [ { @@ -92,7 +90,6 @@ def test_prepare_case_records(decided_application, settings): "Hakemuksen Liite", "liite", attachment.created_at.isoformat(), - attachment.id, [_prepare_record_document_dict(attachment)], handler, )