diff --git a/backend/benefit/calculator/api/v1/views.py b/backend/benefit/calculator/api/v1/views.py index 5cb19129aa..2810d83b1f 100644 --- a/backend/benefit/calculator/api/v1/views.py +++ b/backend/benefit/calculator/api/v1/views.py @@ -5,7 +5,7 @@ from rest_framework.response import Response from rest_framework.views import APIView -from applications.enums import ApplicationTalpaStatus +from applications.enums import ApplicationBatchStatus, ApplicationTalpaStatus from calculator.api.v1.serializers import ( InstalmentSerializer, PreviousBenefitSerializer, @@ -69,14 +69,19 @@ def patch(self, request, instalment_id): application.talpa_status = ( ApplicationTalpaStatus.SUCCESSFULLY_SENT_TO_TALPA ) + application.batch.status = ApplicationBatchStatus.SENT_TO_TALPA else: application.talpa_status = ( ApplicationTalpaStatus.PARTIALLY_SENT_TO_TALPA ) + application.batch.status = ( + ApplicationBatchStatus.PARTIALLY_SENT_TO_TALPA + ) instalment.amount_paid = instalment.amount_after_recoveries application.archived = True instalment.save() application.save() + application.batch.save() return Response(serializer.data, status=status.HTTP_200_OK) if instalment.instalment_number == 2: first_instalment = instalment.calculation.instalments.get( diff --git a/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx b/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx index a0a933f4b6..5ccb649dcf 100644 --- a/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx +++ b/frontend/benefit/handler/src/components/applicationList/HandlerIndex.tsx @@ -49,6 +49,17 @@ export const isInPayment = ( application?.batch?.status ); +export const isPendingInstalment = ( + application: ApplicationListItemData | Application +): boolean => + [APPLICATION_STATUSES.ACCEPTED].includes(application.status) && + !isString(application.batch) && + [ + BATCH_STATUSES.DECIDED_ACCEPTED, + BATCH_STATUSES.REJECTED_BY_TALPA, + BATCH_STATUSES.PARTIALLY_SENT_TO_TALPA, + ].includes(application?.batch?.status); + const HandlerIndex: React.FC = ({ layoutBackgroundColor, list = [], @@ -292,7 +303,7 @@ const HandlerIndex: React.FC = ({ app.secondInstalment && isInPayment(app) + (app) => app.secondInstalment && isPendingInstalment(app) )} heading={t(`${translationBase}.instalments`)} /> diff --git a/frontend/benefit/shared/src/constants.ts b/frontend/benefit/shared/src/constants.ts index 4a64136299..aa4ebbd0fe 100644 --- a/frontend/benefit/shared/src/constants.ts +++ b/frontend/benefit/shared/src/constants.ts @@ -171,6 +171,7 @@ export enum BATCH_STATUSES { DECIDED_ACCEPTED = 'accepted', DECIDED_REJECTED = 'rejected', REJECTED_BY_TALPA = 'rejected_by_talpa', + PARTIALLY_SENT_TO_TALPA = 'partially_sent_to_talpa', SENT_TO_TALPA = 'sent_to_talpa', COMPLETED = 'completed', }