Skip to content

Commit

Permalink
feat: update open case payload to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
rikuke committed Jan 9, 2024
1 parent 96224fd commit 5c6359c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
19 changes: 11 additions & 8 deletions backend/benefit/applications/services/ahjo_payload.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand All @@ -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": [
Expand All @@ -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
Expand All @@ -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ä",
Expand All @@ -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": [
{
Expand All @@ -110,7 +115,6 @@ def _prepare_case_records(
"Hakemus",
"hakemus",
application.created_at.isoformat(),
application.application_number,
[_prepare_record_document_dict(pdf_summary)],
handler,
)
Expand All @@ -124,7 +128,6 @@ def _prepare_case_records(
"Hakemuksen Liite",
"liite",
attachment.created_at.isoformat(),
attachment.id,
[_prepare_record_document_dict(attachment)],
handler,
)
Expand Down
11 changes: 8 additions & 3 deletions backend/benefit/applications/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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ä"
Expand All @@ -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": [
{
Expand All @@ -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,
Expand All @@ -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": [
Expand All @@ -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,
},
],
}

Expand Down
3 changes: 0 additions & 3 deletions backend/benefit/applications/tests/test_ahjo_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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": [
{
Expand All @@ -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,
)
Expand Down

0 comments on commit 5c6359c

Please sign in to comment.