Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hl 1140 ahjo title #2879

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions backend/benefit/applications/services/ahjo_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,28 @@
MANNER_OF_RECEIPT = "sähköinen asiointi"


def _prepare_top_level_dict(application: Application, case_records: List[dict]) -> dict:
def _prepare_case_title(application: Application) -> str:
full_title = f"Avustukset työnantajille, työllisyyspalvelut, \
Helsinki-lisä, {application.company_name}, \
hakemus {application.application_number}"
return full_title


def _prepare_top_level_dict(
application: Application, case_records: List[dict], case_title: str
) -> dict:
"""Prepare the dictionary that is sent to Ahjo"""
application_date = application.created_at.isoformat("T", "seconds")
message_title = f"Avustukset työnantajille, Työllisyyspalvelut, \
Työnantajan Helsinki-lisä, Työnantaja {application.company_name} {application.company.business_id},\
hakemusnumero {application.application_number}"

handler = application.calculation.handler
case_dict = {
"Title": message_title,
"Title": case_title,
"Acquired": application_date,
"ClassificationCode": "02 05 01 00",
"ClassificationTitle": "Kunnan myöntämät avustukset",
"Language": "fi",
"PublicityClass": "Julkinen",
"InternalTitle": message_title,
"InternalTitle": case_title,
"Subjects": [
{"Subject": "Helsinki-lisät", "Scheme": "hki-yhpa"},
{"Subject": "kunnan myöntämät avustukset", "Scheme": "hki-yhpa"},
Expand Down Expand Up @@ -164,7 +170,8 @@ def prepare_open_case_payload(
) -> dict:
"Prepare the complete dictionary payload that is sent to Ahjo"
case_records = _prepare_case_records(application, pdf_summary)
payload = _prepare_top_level_dict(application, case_records)
case_title = _prepare_case_title(application)
payload = _prepare_top_level_dict(application, case_records, case_title)
return payload


Expand Down
8 changes: 3 additions & 5 deletions backend/benefit/applications/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,17 @@ def ahjo_payload_record_for_attachment_update(
@pytest.fixture()
def ahjo_open_case_top_level_dict(decided_application):
application = decided_application
message_title = f"Avustukset työnantajille, Työllisyyspalvelut, \
Työnantajan Helsinki-lisä, Työnantaja {application.company_name} {application.company.business_id},\
hakemusnumero {application.application_number}"

handler = application.calculation.handler

return {
"Title": message_title,
"Title": "message title",
"Acquired": application.created_at.isoformat(),
"ClassificationCode": "02 05 01 00",
"ClassificationTitle": "Kunnan myöntämät avustukset",
"Language": "fi",
"PublicityClass": "Julkinen",
"InternalTitle": message_title,
"InternalTitle": "message title",
"Subjects": [
{"Subject": "Helsinki-lisät", "Scheme": "hki-yhpa"},
{"Subject": "kunnan myöntämät avustukset", "Scheme": "hki-yhpa"},
Expand Down
12 changes: 11 additions & 1 deletion backend/benefit/applications/tests/test_ahjo_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@
from applications.models import Attachment
from applications.services.ahjo_payload import (
_prepare_case_records,
_prepare_case_title,
_prepare_record,
_prepare_record_document_dict,
_prepare_top_level_dict,
)
from common.utils import hash_file


def test_prepare_case_title(decided_application):
application = decided_application
wanted_title = f"Avustukset työnantajille, työllisyyspalvelut, \
Helsinki-lisä, {application.company_name}, \
hakemus {application.application_number}"
got = _prepare_case_title(application)
assert wanted_title == got


def test_prepare_application_record(
decided_application, ahjo_payload_record_for_application
):
Expand Down Expand Up @@ -142,6 +152,6 @@ def test_prepare_case_records(decided_application, settings):
def test_prepare_top_level_dict(decided_application, ahjo_open_case_top_level_dict):
application = decided_application

got = _prepare_top_level_dict(application, [])
got = _prepare_top_level_dict(application, [], "message title")

assert ahjo_open_case_top_level_dict == got
Loading