Skip to content

Commit

Permalink
fix: move MannerOfReceipt into the record dict (#2775)
Browse files Browse the repository at this point in the history
  • Loading branch information
rikuke authored Jan 29, 2024
1 parent 9d667f3 commit 156ee20
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
29 changes: 17 additions & 12 deletions backend/benefit/applications/services/ahjo_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from common.utils import hash_file
from users.models import User

MANNER_OF_RECEIPT = "sähköinen asiointi"


def _prepare_top_level_dict(application: Application, case_records: List[dict]) -> 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}"
Expand All @@ -37,7 +37,6 @@ 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 Down Expand Up @@ -85,24 +84,30 @@ def _prepare_record(
):
"""Prepare a single record dict for Ahjo."""

return {
record_dict = {
"Title": record_title,
"Type": record_type,
"Acquired": acquired,
"PublicityClass": publicity_class,
"SecurityReasons": ["JulkL (621/1999) 24.1 § 25 k"],
"Language": "fi",
"PersonalData": "Sisältää erityisiä henkilötietoja",
"Documents": documents,
"Agents": [
{
"Role": "mainCreator",
"Name": f"{handler.last_name}, {handler.first_name}",
"ID": handler.ad_username,
}
],
}

if record_title == "Hakemus":
record_dict["MannerOfReceipt"] = MANNER_OF_RECEIPT

record_dict["Documents"] = documents
record_dict["Agents"] = [
{
"Role": "mainCreator",
"Name": f"{handler.last_name}, {handler.first_name}",
"ID": handler.ad_username,
}
]

return record_dict


def _prepare_case_records(
application: Application, pdf_summary: Attachment
Expand Down
2 changes: 1 addition & 1 deletion backend/benefit/applications/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def ahjo_payload_record(decided_application):
"SecurityReasons": ["JulkL (621/1999) 24.1 § 25 k"],
"Language": "fi",
"PersonalData": "Sisältää erityisiä henkilötietoja",
"MannerOfReceipt": "sähköinen asiointi",
"Documents": documents,
"Agents": [
{
Expand Down Expand Up @@ -312,7 +313,6 @@ 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 Down
1 change: 1 addition & 0 deletions backend/benefit/applications/tests/test_ahjo_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def test_prepare_case_records(decided_application, settings):
"SecurityReasons": ["JulkL (621/1999) 24.1 § 25 k"],
"Language": "fi",
"PersonalData": "Sisältää erityisiä henkilötietoja",
"MannerOfReceipt": "sähköinen asiointi",
"Documents": [_prepare_record_document_dict(fake_summary)],
"Agents": [
{
Expand Down

0 comments on commit 156ee20

Please sign in to comment.