Skip to content

Commit

Permalink
fix: send ahjo_version_series_id in update payload (#2984)
Browse files Browse the repository at this point in the history
  • Loading branch information
rikuke authored May 13, 2024
1 parent e9b3338 commit a2136f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 10 additions & 5 deletions backend/benefit/applications/services/ahjo_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,19 @@ def prepare_update_application_payload(
) -> dict:
"""Prepare the payload that is sent to Ahjo when an application is updated, \
in this case it only contains a Records dict"""
if not pdf_summary.ahjo_version_series_id:
raise ValueError("Attachment must have an ahjo_version_series_id for update.")
return {
"records": [
_prepare_record(
_prepare_record_title(application, AhjoRecordType.APPLICATION),
AhjoRecordType.APPLICATION,
pdf_summary.created_at.isoformat("T", "seconds"),
[_prepare_record_document_dict(pdf_summary)],
application.calculation.handler,
record_title=_prepare_record_title(
application, AhjoRecordType.APPLICATION
),
record_type=AhjoRecordType.APPLICATION,
acquired=pdf_summary.created_at.isoformat("T", "seconds"),
documents=[_prepare_record_document_dict(pdf_summary)],
handler=application.calculation.handler,
ahjo_version_series_id=pdf_summary.ahjo_version_series_id,
)
]
}
Expand Down
5 changes: 4 additions & 1 deletion backend/benefit/applications/tests/test_ahjo_payload.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import uuid

from django.core.files.base import ContentFile
from django.urls import reverse

Expand Down Expand Up @@ -201,6 +203,7 @@ def test_prepare_update_application_payload(decided_application):
attachment_file=fake_file,
content_type="application/pdf",
attachment_type=AttachmentType.PDF_SUMMARY,
ahjo_version_series_id=str(uuid.uuid4()),
)

want = {
Expand All @@ -213,7 +216,7 @@ def test_prepare_update_application_payload(decided_application):
"SecurityReasons": ["JulkL (621/1999) 24.1 § 25 k"],
"Language": "fi",
"PersonalData": "Sisältää erityisiä henkilötietoja",
"MannerOfReceipt": "sähköinen asiointi",
"VersionSeriesId": str(fake_summary.ahjo_version_series_id),
"Documents": [_prepare_record_document_dict(fake_summary)],
"Agents": [
{
Expand Down

0 comments on commit a2136f1

Please sign in to comment.