Skip to content

Commit

Permalink
feat: query for rejected_by_talpa batches and show talpa_status icon …
Browse files Browse the repository at this point in the history
…for each app (#2743)

* feat: query for rejected_by_talpa batvhess and show talpa_status icons for apps

* refactor: rename function based on sonarcloud input
  • Loading branch information
sirtawast authored Jan 25, 2024
1 parent ef8b737 commit cef39d5
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 18 deletions.
1 change: 1 addition & 0 deletions backend/benefit/applications/api/v1/serializers/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,5 @@ class Meta:
"handled_at",
"employee",
"calculation",
"talpa_status",
]
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,13 @@ class ApplicationBatchStatusValidator(StatusTransitionValidator):
),
ApplicationBatchStatus.DECIDED_ACCEPTED: (
ApplicationBatchStatus.SENT_TO_TALPA,
ApplicationBatchStatus.REJECTED_BY_TALPA,
),
ApplicationBatchStatus.RETURNED: (ApplicationBatchStatus.DRAFT,),
ApplicationBatchStatus.DECIDED_REJECTED: (),
ApplicationBatchStatus.REJECTED_BY_TALPA: (
ApplicationBatchStatus.SENT_TO_TALPA,
),
ApplicationBatchStatus.SENT_TO_TALPA: (ApplicationBatchStatus.COMPLETED,),
ApplicationBatchStatus.COMPLETED: (),
}
3 changes: 2 additions & 1 deletion frontend/benefit/handler/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,8 @@
"accepted": "Myönteiset",
"rejected": "Kielteiset",
"inPayment": "Maksussa",
"waitingForPayment": "Menossa maksuun"
"waitingForPayment": "Menossa maksuun",
"issueInTalpa": "Yksi tai useampi virhe"
},
"handler": "Käsittelijä"
},
Expand Down
3 changes: 2 additions & 1 deletion frontend/benefit/handler/public/locales/fi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,8 @@
"accepted": "Myönteiset",
"rejected": "Kielteiset",
"inPayment": "Maksussa",
"waitingForPayment": "Menossa maksuun"
"waitingForPayment": "Menossa maksuun",
"issueInTalpa": "Yksi tai useampi virhe"
},
"handler": "Käsittelijä"
},
Expand Down
3 changes: 2 additions & 1 deletion frontend/benefit/handler/public/locales/sv/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,8 @@
"accepted": "Myönteiset",
"rejected": "Kielteiset",
"inPayment": "Maksussa",
"waitingForPayment": "Menossa maksuun"
"waitingForPayment": "Menossa maksuun",
"issueInTalpa": "Yksi tai useampi virhe"
},
"handler": "Käsittelijä"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { ROUTES } from 'benefit/handler/constants';
import useRemoveAppFromBatch from 'benefit/handler/hooks/useRemoveAppFromBatch';
import {
BatchTableColumns,
BatchTableTransforms,
} from 'benefit/handler/types/batchList';
import {
BATCH_STATUSES,
PROPOSALS_FOR_DECISION,
TALPA_STATUSES,
} from 'benefit-shared/constants';
import {
ApplicationInBatch,
BatchProposal,
} from 'benefit-shared/types/application';
import {
Button,
IconAlertCircle,
IconAngleDown,
IconAngleUp,
IconArrowUndo,
IconCheck,
IconCheckCircle,
IconCheckCircleFill,
IconClock,
Expand Down Expand Up @@ -159,6 +166,25 @@ const BatchApplicationList: React.FC<BatchProps> = ({ batch }: BatchProps) => {
) : null,
});
}
if (status === BATCH_STATUSES.REJECTED_BY_TALPA) {
cols.push({
headerName: '',
key: 'talpa_status',
transform: ({ talpa_status }: BatchTableTransforms) => (
<>
{talpa_status === TALPA_STATUSES.NOT_SENT_TO_TALPA && (
<IconClock color="var(--color-metro)" />
)}
{talpa_status === TALPA_STATUSES.REJECTED_BY_TALPA && (
<IconAlertCircle color="var(--color-alert-dark)" />
)}
{talpa_status === TALPA_STATUSES.SUCCESFULLY_SENT_TO_TALPA && (
<IconCheck color="var(--color-tram)" />
)}
</>
),
});
}

const proposalForDecisionHeader = (): JSX.Element => {
if (proposalForDecision === PROPOSALS_FOR_DECISION.ACCEPTED) {
Expand Down Expand Up @@ -236,21 +262,27 @@ const BatchApplicationList: React.FC<BatchProps> = ({ batch }: BatchProps) => {
{[
BATCH_STATUSES.SENT_TO_TALPA,
BATCH_STATUSES.DECIDED_ACCEPTED,
BATCH_STATUSES.REJECTED_BY_TALPA,
].includes(status) && (
<div>
<dt>{t('common:batches.list.columns.status')}</dt>
<dd>
{status === BATCH_STATUSES.SENT_TO_TALPA ? (
{status === BATCH_STATUSES.DECIDED_ACCEPTED && (
<IconClock color="var(--color-info)" />
)}
{status === BATCH_STATUSES.SENT_TO_TALPA && (
<IconCheckCircle color="var(--color-tram)" />
) : (
<IconClock color="var(--color-metro)" />
)}
{status === BATCH_STATUSES.REJECTED_BY_TALPA && (
<IconAlertCircle color="var(--color-alert-dark)" />
)}
<$BatchStatusValue>
{status === BATCH_STATUSES.SENT_TO_TALPA
? t('common:batches.list.columns.statuses.inPayment')
: t(
'common:batches.list.columns.statuses.waitingForPayment'
)}
{status === BATCH_STATUSES.DECIDED_ACCEPTED &&
t('common:batches.list.columns.statuses.waitingForPayment')}
{status === BATCH_STATUSES.REJECTED_BY_TALPA &&
t('common:batches.list.columns.statuses.issueInTalpa')}
{status === BATCH_STATUSES.SENT_TO_TALPA &&
t('common:batches.list.columns.statuses.inPayment')}
</$BatchStatusValue>
</dd>
</div>
Expand Down Expand Up @@ -303,6 +335,7 @@ const BatchApplicationList: React.FC<BatchProps> = ({ batch }: BatchProps) => {
{[
BATCH_STATUSES.DECIDED_ACCEPTED,
BATCH_STATUSES.SENT_TO_TALPA,
BATCH_STATUSES.REJECTED_BY_TALPA,
].includes(status) && (
<BatchFooterCompletion
batch={batch}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ const BatchFooterCompletion: React.FC<BatchProps> = ({
} = useDownloadP2PFile();

const { mutate: changeBatchStatus } = useBatchStatus(setBatchCloseAnimation);
const [isModalBatchToCompletion, setModalBatchToCompletion] =
const [isModalBatchToCompletion, setIsModalBatchToCompletion] =
React.useState(false);
const [isModalBatchToInspection, setModalBatchToInspection] =
const [isModalBatchToInspection, setIsModalBatchToInspection] =
React.useState(false);

const handleModalClose = (): void => {
setModalBatchToCompletion(false);
setModalBatchToInspection(false);
setIsModalBatchToCompletion(false);
setIsModalBatchToInspection(false);
};

const handleBatchStatusChange = (status: BATCH_STATUSES): void => {
Expand Down Expand Up @@ -251,7 +251,7 @@ const BatchFooterCompletion: React.FC<BatchProps> = ({
iconLeft={<IconArrowUndo />}
isLoading={isDownloadingAttachments}
disabled={isDownloadingAttachments}
onClick={() => setModalBatchToInspection(true)}
onClick={() => setIsModalBatchToInspection(true)}
>
{t('common:batches.actions.returnToInspection')}
</Button>
Expand All @@ -262,7 +262,7 @@ const BatchFooterCompletion: React.FC<BatchProps> = ({
theme="coat"
variant="primary"
disabled={isDownloadingAttachments}
onClick={() => setModalBatchToCompletion(true)}
onClick={() => setIsModalBatchToCompletion(true)}
>
{t('common:batches.actions.markToArchive')}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ const translationsBase = 'common:applications.list';

const useBatchProposal = (filterByStatus: BATCH_STATUSES[]): BatchListProps => {
const { t } = useTranslation();
const orderBy = filterByStatus.filter(
const orderBy = filterByStatus.some(
(status: BATCH_STATUSES) =>
status === BATCH_STATUSES.DECIDED_ACCEPTED ||
status === BATCH_STATUSES.SENT_TO_TALPA
)
? '-modified_at'
: undefined;

const query = useBatchQuery(filterByStatus, orderBy);

let batches: BatchProposal[] = [];
Expand All @@ -42,13 +43,15 @@ const useBatchProposal = (filterByStatus: BATCH_STATUSES[]): BatchListProps => {
application_number,
employee,
handled_at,
talpa_status,
calculation,
} = app;

const benefitAmount = calculation?.calculated_benefit_amount || 0;

return {
id,
talpa_status,
company_name: company?.name || '',
application_number,
employee_name:
Expand Down
1 change: 1 addition & 0 deletions frontend/benefit/handler/src/pages/batches/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const BatchIndex: NextPage = () => {
status={[
BATCH_STATUSES.DECIDED_ACCEPTED,
BATCH_STATUSES.SENT_TO_TALPA,
BATCH_STATUSES.REJECTED_BY_TALPA,
]}
/>
</Tabs.TabPanel>
Expand Down
3 changes: 3 additions & 0 deletions frontend/benefit/handler/src/types/batchList.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { TALPA_STATUSES } from 'benefit-shared/constants';

type BatchTableTransforms = {
id?: string;
company_name?: string;
talpa_status?: TALPA_STATUSES;
};

type BatchTableColumns = {
Expand Down
7 changes: 7 additions & 0 deletions frontend/benefit/shared/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ export enum APPLICATION_STATUSES {
HANDLING = 'handling',
}

export enum TALPA_STATUSES {
NOT_SENT_TO_TALPA = 'not_sent_to_talpa',
REJECTED_BY_TALPA = 'rejected_by_talpa',
SUCCESFULLY_SENT_TO_TALPA = 'succesfully_sent_to_talpa',
}

export enum APPLICATION_ORIGINS {
APPLICANT = 'applicant',
HANDLER = 'handler',
Expand All @@ -162,6 +168,7 @@ export enum BATCH_STATUSES {
AHJO_REPORT_CREATED = 'exported_ahjo_report',
DECIDED_ACCEPTED = 'accepted',
DECIDED_REJECTED = 'rejected',
REJECTED_BY_TALPA = 'rejected_by_talpa',
SENT_TO_TALPA = 'sent_to_talpa',
COMPLETED = 'completed',
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/benefit/shared/src/types/application.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CALCULATION_ROW_TYPES,
PAY_SUBSIDY_GRANTED,
PROPOSALS_FOR_DECISION,
TALPA_STATUSES,
} from 'benefit-shared/constants';
import { Language } from 'shared/i18n/i18n';
import { BenefitAttachment } from 'shared/types/attachment';
Expand Down Expand Up @@ -76,6 +77,7 @@ export type ApplicationInBatch = {
business_id: string;
calculation?: CalculationData;
benefitAmount: number | string;
talpa_status: TALPA_STATUSES;
};

interface ApplicationAllowedAction {
Expand Down

0 comments on commit cef39d5

Please sign in to comment.