Skip to content

Commit

Permalink
feat: cancelled status after ahjo delete callback (#3078)
Browse files Browse the repository at this point in the history
  • Loading branch information
rikuke committed Jun 11, 2024
1 parent 7f7f96d commit 128fae4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 6 additions & 4 deletions backend/benefit/applications/api/v1/ahjo_integration_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
AhjoRequestType,
AhjoStatus as AhjoStatusEnum,
ApplicationBatchStatus,
ApplicationStatus,
)
from applications.models import AhjoStatus, Application, ApplicationBatch, Attachment
from common.permissions import BFIsHandler, SafeListPermission
Expand Down Expand Up @@ -196,9 +197,9 @@ def handle_success_callback(
info = f"Application ahjo_case_guid and ahjo_case_id were updated by Ahjo \
with request id: {callback_data['requestId']}"
elif request_type == AhjoRequestType.DELETE_APPLICATION:
self._handle_delete_callback()
self._handle_delete_callback_success(application)
ahjo_status = AhjoStatusEnum.DELETE_REQUEST_RECEIVED
info = f"Application was marked for cancellation \
info = f"Application {application.application_number} was marked for cancellation \
in Ahjo with request id: {callback_data['requestId']}"
elif request_type == AhjoRequestType.SEND_DECISION_PROPOSAL:
self.handle_decision_proposal_success(application)
Expand Down Expand Up @@ -279,9 +280,10 @@ def _handle_open_case_success(self, application: Application, callback_data: dic
application.save()
return application

def _handle_delete_callback(self):
def _handle_delete_callback_success(self, application):
# do anything that needs to be done when Ahjo sends a delete callback
pass
application.status = ApplicationStatus.CANCELLED
application.save()

def _save_version_series_id(
self, application: Application, cb_records: list
Expand Down
4 changes: 4 additions & 0 deletions backend/benefit/applications/tests/test_ahjo_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ def test_ahjo_callback_success(
batch = decided_application.batch
assert batch.status == ApplicationBatchStatus.AWAITING_AHJO_DECISION

if request_type == AhjoRequestType.DELETE_APPLICATION:
decided_application.refresh_from_db()
assert decided_application.status == ApplicationStatus.CANCELLED

assert decided_application.ahjo_status.latest().status == ahjo_status


Expand Down

0 comments on commit 128fae4

Please sign in to comment.