Skip to content

Commit

Permalink
Merge pull request #2160 from turbo124/remove_reversal_option
Browse files Browse the repository at this point in the history
Remove invoice reversal option
  • Loading branch information
beganovich authored Nov 4, 2024
2 parents 415d002 + 017bc1d commit 5699015
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 48 deletions.
50 changes: 25 additions & 25 deletions src/pages/invoices/common/hooks/useCustomBulkActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
MdMarkEmailRead,
MdPaid,
MdPrint,
MdRefresh,
// MdRefresh,
} from 'react-icons/md';
import { usePrintPdf } from './usePrintPdf';
import { useDownloadPdfs } from './useDownloadPdfs';
Expand All @@ -32,7 +32,7 @@ import { toast } from '$app/common/helpers/toast/toast';
import { InvoiceStatus } from '$app/common/enums/invoice-status';
import collect from 'collect.js';
import { isInvoiceAutoBillable } from '../../edit/components/Actions';
import { useReverseInvoice } from './useReverseInvoice';
// import { useReverseInvoice } from './useReverseInvoice';
import { useDocumentsBulk } from '$app/common/queries/documents';
import { Dispatch, SetStateAction } from 'react';
import { useHasPermission } from '$app/common/hooks/permissions/useHasPermission';
Expand All @@ -52,7 +52,7 @@ export const useCustomBulkActions = () => {

const bulk = useBulk();

const reverseInvoice = useReverseInvoice();
// const reverseInvoice = useReverseInvoice();

const getDocumentsIds = (invoices: Invoice[]) => {
return invoices.flatMap(({ documents }) => documents.map(({ id }) => id));
Expand Down Expand Up @@ -106,15 +106,15 @@ export const useCustomBulkActions = () => {
);
};

const showReverseOption = (invoices: Invoice[]) => {
return !invoices.some(
({ status_id, is_deleted, archived_at }) =>
(status_id !== InvoiceStatus.Paid &&
status_id !== InvoiceStatus.Partial) ||
is_deleted ||
archived_at
);
};
// const showReverseOption = (invoices: Invoice[]) => {
// return !invoices.some(
// ({ status_id, is_deleted, archived_at }) =>
// (status_id !== InvoiceStatus.Paid &&
// status_id !== InvoiceStatus.Partial) ||
// is_deleted ||
// archived_at
// );
// };

const handleDownloadDocuments = (
selectedInvoices: Invoice[],
Expand Down Expand Up @@ -223,19 +223,19 @@ export const useCustomBulkActions = () => {
{t('documents')}
</DropdownElement>
),
({ selectedResources, setSelected }) =>
showReverseOption(selectedResources) &&
hasPermission('create_credit') && (
<DropdownElement
onClick={() => {
reverseInvoice(selectedResources[0]);
setSelected([]);
}}
icon={<Icon element={MdRefresh} />}
>
{t('reverse')}
</DropdownElement>
),
// ({ selectedResources, setSelected }) =>
// showReverseOption(selectedResources) &&
// hasPermission('create_credit') && (
// <DropdownElement
// onClick={() => {
// reverseInvoice(selectedResources[0]);
// setSelected([]);
// }}
// icon={<Icon element={MdRefresh} />}
// >
// {t('reverse')}
// </DropdownElement>
// ),
({ selectedIds, selectedResources, setSelected }) =>
showCancelOption(selectedResources) && (
<DropdownElement
Expand Down
46 changes: 23 additions & 23 deletions src/pages/invoices/edit/components/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
MdPaid,
MdPictureAsPdf,
MdPrint,
MdRefresh,
// MdRefresh,
MdRestore,
MdSchedule,
} from 'react-icons/md';
Expand All @@ -46,7 +46,7 @@ import { EntityState } from '$app/common/enums/entity-state';
import dayjs from 'dayjs';
import { useEntityPageIdentifier } from '$app/common/hooks/useEntityPageIdentifier';
import { useBulk } from '$app/common/queries/invoices';
import { useReverseInvoice } from '../../common/hooks/useReverseInvoice';
// import { useReverseInvoice } from '../../common/hooks/useReverseInvoice';
import { EmailInvoiceAction } from '../../common/components/EmailInvoiceAction';
import {
useAdmin,
Expand Down Expand Up @@ -98,7 +98,7 @@ export function useActions(params?: Params) {
const bulk = useBulk();
const navigate = useNavigate();
const hasPermission = useHasPermission();
const reverseInvoice = useReverseInvoice();
// const reverseInvoice = useReverseInvoice();
const downloadPdf = useDownloadPdf({ resource: 'invoice' });
const downloadEInvoice = useDownloadEInvoice({ resource: 'invoice' });
const printPdf = usePrintPdf({ entity: 'invoice' });
Expand Down Expand Up @@ -360,26 +360,26 @@ export function useActions(params?: Params) {
</EntityActionElement>
),

(invoice: Invoice) =>
(invoice.status_id === InvoiceStatus.Paid ||
invoice.status_id === InvoiceStatus.Partial) &&
!invoice.is_deleted &&
!invoice.archived_at &&
hasPermission('create_credit') && (
<EntityActionElement
{...(!dropdown && {
key: 'reverse',
})}
entity="invoice"
actionKey="reverse"
isCommonActionSection={!dropdown}
tooltipText={t('reverse')}
onClick={() => reverseInvoice(invoice)}
icon={MdRefresh}
>
{t('reverse')}
</EntityActionElement>
),
// (invoice: Invoice) =>
// (invoice.status_id === InvoiceStatus.Paid ||
// invoice.status_id === InvoiceStatus.Partial) &&
// !invoice.is_deleted &&
// !invoice.archived_at &&
// hasPermission('create_credit') && (
// <EntityActionElement
// {...(!dropdown && {
// key: 'reverse',
// })}
// entity="invoice"
// actionKey="reverse"
// isCommonActionSection={!dropdown}
// tooltipText={t('reverse')}
// onClick={() => reverseInvoice(invoice)}
// icon={MdRefresh}
// >
// {t('reverse')}
// </EntityActionElement>
// ),
(invoice: Invoice) => (
<DropdownElement
onClick={() => {
Expand Down

0 comments on commit 5699015

Please sign in to comment.