Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Overdue column in invoices list #1900

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/components/customers/CustomerInvoicesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FC, useRef } from 'react'
import { generatePath, useNavigate } from 'react-router-dom'
import styled from 'styled-components'

import { InfiniteScroll, Status, Table, Tooltip, Typography } from '~/components/designSystem'
import { Chip, InfiniteScroll, Status, Table, Tooltip, Typography } from '~/components/designSystem'
import { addToast, hasDefinedGQLError } from '~/core/apolloClient'
import { invoiceStatusMapping, paymentStatusMapping } from '~/core/constants/statusInvoiceMapping'
import { intlFormatNumber } from '~/core/formats/intlFormatNumber'
Expand Down Expand Up @@ -236,7 +236,7 @@ export const CustomerInvoicesList: FC<CustomerInvoicesListProps> = ({
key: 'paymentStatus',
minWidth: 120,
title: translate('text_63b5d225b075850e0fe489f4'),
content: ({ status, paymentStatus, paymentOverdue, paymentDisputeLostAt }) => {
content: ({ status, paymentStatus, paymentDisputeLostAt }) => {
if (status !== InvoiceStatusTypeEnum.Finalized) {
return null
}
Expand All @@ -254,7 +254,6 @@ export const CustomerInvoicesList: FC<CustomerInvoicesListProps> = ({
{...paymentStatusMapping({
status,
paymentStatus,
paymentOverdue,
})}
endIcon={!!paymentDisputeLostAt ? 'warning-unfilled' : undefined}
/>
Expand All @@ -263,6 +262,16 @@ export const CustomerInvoicesList: FC<CustomerInvoicesListProps> = ({
},
}
: null,
context === 'finalized'
? {
key: 'paymentOverdue',
title: translate('text_666c5b12fea4aa1e1b26bf55'),
content: ({ paymentOverdue }) =>
paymentOverdue && (
<Chip error={true} label={translate('text_666c5b12fea4aa1e1b26bf55')} />
),
}
: null,
{
key: 'issuingDate',
minWidth: 104,
Expand Down
12 changes: 10 additions & 2 deletions src/components/invoices/InvoicesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useEffect, useRef } from 'react'
import { generatePath, useNavigate, useSearchParams } from 'react-router-dom'

import {
Chip,
InfiniteScroll,
QuickFilters,
Status,
Expand Down Expand Up @@ -305,7 +306,7 @@ const InvoicesList = ({
key: 'paymentStatus',
title: translate('text_6419c64eace749372fc72b40'),
minWidth: 80,
content: ({ status, paymentStatus, paymentOverdue, paymentDisputeLostAt }) => {
content: ({ status, paymentStatus, paymentDisputeLostAt }) => {
if (status !== InvoiceStatusTypeEnum.Finalized) {
return null
}
Expand All @@ -323,14 +324,21 @@ const InvoicesList = ({
{...paymentStatusMapping({
status,
paymentStatus,
paymentOverdue,
})}
endIcon={!!paymentDisputeLostAt ? 'warning-unfilled' : undefined}
/>
</Tooltip>
)
},
},
{
key: 'paymentOverdue',
title: translate('text_666c5b12fea4aa1e1b26bf55'),
content: ({ paymentOverdue }) =>
paymentOverdue && (
<Chip error={true} label={translate('text_666c5b12fea4aa1e1b26bf55')} />
),
},
{
key: 'customer.name',
title: translate('text_65201c5a175a4b0238abf29a'),
Expand Down
6 changes: 0 additions & 6 deletions src/core/constants/statusInvoiceMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@ export const invoiceStatusMapping = ({
export const paymentStatusMapping = ({
status,
paymentStatus,
paymentOverdue,
}: {
status: InvoiceStatusTypeEnum
paymentStatus: InvoicePaymentStatusTypeEnum
paymentOverdue?: boolean
}): StatusProps => {
if (paymentOverdue) {
return { label: 'overdue', type: StatusType.danger }
}

if (status === InvoiceStatusTypeEnum.Finalized) {
switch (paymentStatus) {
case InvoicePaymentStatusTypeEnum.Pending:
Expand Down
Loading