From 9e7dfb907e6a69031a9a5bfa98e6f1b61ed7ed4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilia=20M=C3=A4kel=C3=A4?= Date: Wed, 5 Jun 2024 15:24:50 +0300 Subject: [PATCH] fix: nonfunctional alteration submission and misc. oversights in date overlap detection (#3068) * fix: nonfunctional alteration submission * fix: disregard cancelled alterations in overlap check * fix: check for recovery date range in overlap check if set * fix: don't consider cancelled alterations in overlap check --- .../api/v1/serializers/application_alteration.py | 11 +++++++++-- .../alterationHandling/useAlterationHandlingForm.ts | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/benefit/applications/api/v1/serializers/application_alteration.py b/backend/benefit/applications/api/v1/serializers/application_alteration.py index 5bb54022cc..a28a7a3e45 100644 --- a/backend/benefit/applications/api/v1/serializers/application_alteration.py +++ b/backend/benefit/applications/api/v1/serializers/application_alteration.py @@ -191,6 +191,7 @@ def _validate_date_range_overlaps(self, self_id, application, start_date, end_da if ( alteration.recovery_start_date is None or alteration.recovery_end_date is None + or alteration.state == ApplicationAlterationState.CANCELLED ): continue @@ -255,9 +256,15 @@ def validate(self, data): application, alteration_start_date, alteration_end_date ) - if alteration_end_date is not None: + if ( + alteration_end_date is not None + and merged_data["state"] != ApplicationAlterationState.CANCELLED + ): errors += self._validate_date_range_overlaps( - self_id, application, alteration_start_date, alteration_end_date + self_id, + application, + merged_data["recovery_start_date"] or alteration_start_date, + merged_data["recovery_end_date"] or alteration_end_date, ) if len(errors) > 0: diff --git a/frontend/benefit/handler/src/components/alterationHandling/useAlterationHandlingForm.ts b/frontend/benefit/handler/src/components/alterationHandling/useAlterationHandlingForm.ts index 5d25b19394..7d8ebbd0ca 100644 --- a/frontend/benefit/handler/src/components/alterationHandling/useAlterationHandlingForm.ts +++ b/frontend/benefit/handler/src/components/alterationHandling/useAlterationHandlingForm.ts @@ -105,7 +105,7 @@ const useAlterationHandling = ({ isSubmitting: updateStatus === 'loading', t, formik, - handleAlteration: () => void formik.submitForm, + handleAlteration: () => void formik.submitForm(), validateForm, }; };