Skip to content

Commit

Permalink
feat: show benefit amount in batch app listing (#2706)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast authored Jan 9, 2024
1 parent fe0995f commit 63bc823
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
6 changes: 6 additions & 0 deletions backend/benefit/applications/api/v1/serializers/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
)
from applications.enums import ApplicationBatchStatus, ApplicationStatus
from applications.models import Application, ApplicationBatch, Company, Employee
from calculator.api.v1.serializers import CalculationSerializer
from users.api.v1.serializers import UserSerializer


Expand Down Expand Up @@ -179,6 +180,10 @@ class Meta:
class BatchApplicationSerializer(ReadOnlySerializer):
company = BatchCompanySerializer(read_only=True)
employee = BatchEmployeeSerializer(read_only=True)
calculation = CalculationSerializer(
read_only=True,
allow_null=True,
)

handled_at = serializers.SerializerMethodField(
"get_handled_at",
Expand All @@ -199,4 +204,5 @@ class Meta:
"application_number",
"handled_at",
"employee",
"calculation",
]
1 change: 1 addition & 0 deletions frontend/benefit/handler/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"dataReceived": "Ladattu",
"status": "Käsittelyn tulos",
"statusArchive": "Käsittelyn tulos",
"benefitAmount": "Tuen määrä",
"statuses": {
"cancelled": "Peruutettu",
"accepted": "Puolettu",
Expand Down
1 change: 1 addition & 0 deletions frontend/benefit/handler/public/locales/fi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"dataReceived": "Ladattu",
"status": "Käsittelyn tulos",
"statusArchive": "Käsittelyn tulos",
"benefitAmount": "Tuen määrä",
"statuses": {
"cancelled": "Peruutettu",
"accepted": "Puolettu",
Expand Down
1 change: 1 addition & 0 deletions frontend/benefit/handler/public/locales/sv/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"dataReceived": "Ladattu",
"status": "Käsittelyn tulos",
"statusArchive": "Käsittelyn tulos",
"benefitAmount": "Tuen määrä",
"statuses": {
"cancelled": "Peruutettu",
"accepted": "Puolettu",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
convertToUIDateAndTimeFormat,
sortFinnishDate,
} from 'shared/utils/date.utils';
import { formatFloatToCurrency } from 'shared/utils/string.utils';
import styled from 'styled-components';

import { $Empty } from '../applicationList/ApplicationList.sc';
Expand Down Expand Up @@ -118,6 +119,13 @@ const BatchApplicationList: React.FC<BatchProps> = ({ batch }: BatchProps) => {
isSortable: true,
customSortCompareFunction: sortFinnishDate,
},
{
headerName: t('common:applications.list.columns.benefitAmount'),
key: 'total_amount',
isSortable: true,
transform: ({ benefitAmount: amount }: { benefitAmount: number | 0 }) =>
formatFloatToCurrency(amount, 'EUR', 'fi-FI', 0),
},
{
transform: ({ id: appId }: { id: string }) =>
IS_WAITING_FOR_AHJO ? (
Expand Down Expand Up @@ -209,10 +217,6 @@ const BatchApplicationList: React.FC<BatchProps> = ({ batch }: BatchProps) => {
<dt>{t('common:batches.list.columns.createdAt')}</dt>
<dd>{convertToUIDateAndTimeFormat(created_at)}</dd>
</div>
<div>
<dt>{t('common:batches.list.columns.createdAt')}</dt>
<dd>{convertToUIDateAndTimeFormat(created_at)}</dd>
</div>
{[
BATCH_STATUSES.SENT_TO_TALPA,
BATCH_STATUSES.DECIDED_ACCEPTED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,23 @@ const useBatchProposal = (filterByStatus: BATCH_STATUSES[]): BatchListProps => {
id,
status,
company,
company_name,
application_number,
employee,
handled_at,
calculation,
} = app;

const benefitAmount = calculation?.calculated_benefit_amount || 0;

return {
id,
company_name: company?.name || '',
application_number,
employee_name:
getFullName(employee?.first_name, employee?.last_name) || '-',
status,
benefitAmount,
handled_at: convertToUIDateFormat(handled_at),
company_name: company?.name || company_name,
business_id: company?.business_id,
};
}
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 @@ -74,6 +74,8 @@ export type ApplicationInBatch = {
employee_name: string;
handled_at: string;
business_id: string;
calculation?: CalculationData;
benefitAmount: number | string;
};

interface ApplicationAllowedAction {
Expand Down

0 comments on commit 63bc823

Please sign in to comment.