Skip to content

Commit

Permalink
fix: missing batch status
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast committed Dec 18, 2024
1 parent 56c2b5f commit b3b0b94
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion backend/benefit/calculator/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApplicationListProps> = ({
layoutBackgroundColor,
list = [],
Expand Down Expand Up @@ -292,7 +303,7 @@ const HandlerIndex: React.FC<ApplicationListProps> = ({
<ApplicationListForInstalments
isLoading={isLoading}
list={list.filter(
(app) => app.secondInstalment && isInPayment(app)
(app) => app.secondInstalment && isPendingInstalment(app)
)}
heading={t(`${translationBase}.instalments`)}
/>
Expand Down
1 change: 1 addition & 0 deletions frontend/benefit/shared/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
Expand Down

0 comments on commit b3b0b94

Please sign in to comment.