Skip to content

Commit

Permalink
fix: issues with 2nd instalment not showing up in frontpage (#3661)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast authored Dec 19, 2024
1 parent 95c2794 commit ee39926
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
22 changes: 21 additions & 1 deletion backend/benefit/applications/api/v1/application_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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", []))
Expand All @@ -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:
Expand Down
8 changes: 3 additions & 5 deletions frontend/benefit/handler/src/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ const Header: React.FC = () => {
<li key="header-notifier">
<HeaderNotifier />
</li>
{process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT !== 'production' ? (
<li key="ahjo-mode-switch">
<TemporaryAhjoModeSwitch />
</li>
) : null}
<li key="ahjo-mode-switch">
<TemporaryAhjoModeSwitch />
</li>
</$HeaderCustomItems>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit ee39926

Please sign in to comment.