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

feat: ensure ahjo_status is saved during request #3380

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion backend/benefit/applications/services/ahjo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.urls import reverse

from applications.enums import AhjoRequestType, AhjoStatus as AhjoStatusEnum
from applications.models import AhjoSetting, Application
from applications.models import AhjoSetting, AhjoStatus, Application
from applications.services.ahjo_authentication import AhjoToken, InvalidTokenException

LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -235,6 +235,13 @@ def send_request_to_ahjo(
timeout=self._timeout,
data=data,
)

if hasattr(self._request, "result_status") and self._request.result_status:
AhjoStatus.objects.create(
application=self._request.application,
status=self._request.result_status,
)

response.raise_for_status()

if response.ok:
Expand Down
12 changes: 1 addition & 11 deletions backend/benefit/applications/services/ahjo_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,6 @@ def send_open_case_request_to_ahjo(
data = prepare_open_case_payload(application, pdf_summary)

result, response_text = ahjo_client.send_request_to_ahjo(data)
if result:
create_status_for_application(
application, AhjoStatusEnum.REQUEST_TO_OPEN_CASE_SENT
)
return result, response_text


Expand All @@ -504,8 +500,7 @@ def delete_application_in_ahjo(
ahjo_client = AhjoApiClient(ahjo_token, ahjo_request)

result, response_text = ahjo_client.send_request_to_ahjo(None)
if result:
create_status_for_application(application, ahjo_request.result_status)

return result, response_text


Expand All @@ -532,8 +527,6 @@ def update_application_summary_record_in_ahjo(

result, response_text = ahjo_client.send_request_to_ahjo(data)

if result:
create_status_for_application(application, AhjoStatusEnum.UPDATE_REQUEST_SENT)
return result, response_text


Expand All @@ -554,8 +547,6 @@ def send_new_attachment_records_to_ahjo(

result, response_text = ahjo_client.send_request_to_ahjo(data)

if result:
create_status_for_application(application, ahjo_request.result_status)
return result, response_text


Expand Down Expand Up @@ -584,7 +575,6 @@ def send_decision_proposal_to_ahjo(
secret_xml=secret_xml,
)
response, response_text = ahjo_client.send_request_to_ahjo(data)
create_status_for_application(application, AhjoStatusEnum.DECISION_PROPOSAL_SENT)
return response, response_text


Expand Down
Loading