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, }; };