From ee39926333de4c0ff88369ca6d8090baebe569fe Mon Sep 17 00:00:00 2001 From: Sampo Tawast <5328394+sirtawast@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:31:11 +0200 Subject: [PATCH] fix: issues with 2nd instalment not showing up in frontpage (#3661) --- .../applications/api/v1/application_views.py | 22 ++++++++++++++++++- .../handler/src/components/header/Header.tsx | 8 +++---- .../header/TemporaryAhjoModeSwitch.tsx | 4 +--- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/backend/benefit/applications/api/v1/application_views.py b/backend/benefit/applications/api/v1/application_views.py index 869906b151..84ebf39cf8 100755 --- a/backend/benefit/applications/api/v1/application_views.py +++ b/backend/benefit/applications/api/v1/application_views.py @@ -71,6 +71,7 @@ generate_application_summary_file, get_context_for_summary_context, ) +from calculator.enums import InstalmentStatus from common.permissions import BFIsApplicant, BFIsHandler, TermsOfServiceAccepted from messages.automatic_messages import send_application_reopened_message from messages.models import MessageType @@ -300,6 +301,18 @@ def post_attachment(self, request, *args, **kwargs): return Response(serializer.data, status=status.HTTP_201_CREATED) + def _get_application_pks_with_instalments(self) -> List[int]: + return Application.objects.filter( + status=ApplicationStatus.ACCEPTED, + calculation__instalments__due_date__gte=timezone.now().date(), + calculation__instalments__instalment_number=2, + calculation__instalments__status__in=[ + InstalmentStatus.ACCEPTED, + InstalmentStatus.ERROR_IN_TALPA, + InstalmentStatus.WAITING, + ], + ) + def _get_simplified_queryset(self, request, context) -> QuerySet: qs = self.filter_queryset(self.get_queryset()) fields = set(context.get("fields", [])) @@ -324,7 +337,14 @@ def _get_simplified_queryset(self, request, context) -> QuerySet: user = self.request.user if hasattr(user, "is_handler") and user.is_handler(): should_filter_archived = request.query_params.get("filter_archived") == "1" - qs = qs.filter(archived=should_filter_archived) + if should_filter_archived: + qs = qs.filter(archived=should_filter_archived) + else: + # Applications with second instalment are considered archived but should be included in main views + qs = qs.filter( + Q(archived=should_filter_archived) + | Q(pk__in=self._get_application_pks_with_instalments()) + ) ahjo_cases = request.query_params.get("ahjo_case") == "1" if ahjo_cases: diff --git a/frontend/benefit/handler/src/components/header/Header.tsx b/frontend/benefit/handler/src/components/header/Header.tsx index 5e2be71da6..688ff9b2d1 100644 --- a/frontend/benefit/handler/src/components/header/Header.tsx +++ b/frontend/benefit/handler/src/components/header/Header.tsx @@ -39,11 +39,9 @@ const Header: React.FC = () => {
  • - {process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT !== 'production' ? ( -
  • - -
  • - ) : null} +
  • + +
  • ); diff --git a/frontend/benefit/handler/src/components/header/TemporaryAhjoModeSwitch.tsx b/frontend/benefit/handler/src/components/header/TemporaryAhjoModeSwitch.tsx index 3f6cab116c..e849ca8cc6 100644 --- a/frontend/benefit/handler/src/components/header/TemporaryAhjoModeSwitch.tsx +++ b/frontend/benefit/handler/src/components/header/TemporaryAhjoModeSwitch.tsx @@ -14,9 +14,7 @@ const toggleNewAhjoMode = (isNewMode: boolean): void => { 'Haluatko palata vanhaan koontipohjaiseen käyttöliittymään?' ) : // eslint-disable-next-line no-alert - window.confirm( - 'Haluatko kokeilla uutta Ahjo-integraation käyttöliittymää? Vain testiympäristöihin, älä käytä tuotannossa!' - ); + window.confirm('Ota Ahjo-integraation käyttöliittymä käyttöön?'); if (!confirm) return; if (!isNewMode) { setLocalStorageItem('newAhjoMode', '1');