feat(sales/purchases): add tooltip cell to detail.

This commit is contained in:
elforjani13
2022-04-09 02:04:31 +02:00
parent cc457e1e43
commit 80feba6005
7 changed files with 238 additions and 101 deletions

View File

@@ -13,57 +13,81 @@ import {
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { import {
FormatNumberCell, FormatNumberCell,
TextOverviewTooltipCell,
FormattedMessage as T, FormattedMessage as T,
Choose, Choose,
Icon, Icon,
} from '../../../components'; } from '../../../components';
import { getColumnWidth } from 'utils';
import { useBillDrawerContext } from './BillDrawerProvider';
/** /**
* Retrieve bill readonly details entries table columns. * Retrieve bill readonly details entries table columns.
*/ */
export const useBillReadonlyEntriesTableColumns = () => export const useBillReadonlyEntriesTableColumns = () => {
React.useMemo( const {
bill: { entries },
} = useBillDrawerContext();
return React.useMemo(
() => [ () => [
{ {
Header: intl.get('product_and_service'), Header: intl.get('product_and_service'),
accessor: 'item.name', accessor: 'item.name',
Cell: TextOverviewTooltipCell,
width: 150, width: 150,
className: 'item', className: 'item',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
{ {
Header: intl.get('description'), Header: intl.get('description'),
accessor: 'description', accessor: 'description',
Cell: TextOverviewTooltipCell,
className: 'description', className: 'description',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
{ {
Header: intl.get('quantity'), Header: intl.get('quantity'),
accessor: 'quantity', accessor: 'quantity',
Cell: FormatNumberCell, Cell: FormatNumberCell,
width: 100, width: getColumnWidth(entries, 'quantity', {
minWidth: 60,
magicSpacing: 5,
}),
align: 'right', align: 'right',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
{ {
Header: intl.get('rate'), Header: intl.get('rate'),
accessor: 'rate', accessor: 'rate',
Cell: FormatNumberCell, Cell: FormatNumberCell,
width: 100, width: getColumnWidth(entries, 'rate', {
minWidth: 60,
magicSpacing: 5,
}),
align: 'right', align: 'right',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
{ {
Header: intl.get('amount'), Header: intl.get('amount'),
accessor: 'amount', accessor: 'amount',
Cell: FormatNumberCell, Cell: FormatNumberCell,
width: 100, width: getColumnWidth(entries, 'amount', {
minWidth: 60,
magicSpacing: 5,
}),
align: 'right', align: 'right',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
], ],
[], [],
); );
};
/** /**
* Bill details status. * Bill details status.

View File

@@ -10,56 +10,81 @@ import {
Tag, Tag,
Intent, Intent,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { getColumnWidth } from 'utils';
import { import {
Icon, Icon,
FormattedMessage as T, FormattedMessage as T,
TextOverviewTooltipCell,
FormatNumberCell, FormatNumberCell,
Choose, Choose,
} from '../../../components'; } from '../../../components';
import { useCreditNoteDetailDrawerContext } from './CreditNoteDetailDrawerProvider';
export const useCreditNoteReadOnlyEntriesColumns = () => export const useCreditNoteReadOnlyEntriesColumns = () => {
React.useMemo( // credit note details drawer context.
const {
creditNote: { entries },
} = useCreditNoteDetailDrawerContext();
return React.useMemo(
() => [ () => [
{ {
Header: intl.get('product_and_service'), Header: intl.get('product_and_service'),
accessor: 'item.name', accessor: 'item.name',
Cell: TextOverviewTooltipCell,
width: 150, width: 150,
className: 'name', className: 'name',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
{ {
Header: intl.get('description'), Header: intl.get('description'),
accessor: 'description', accessor: 'description',
Cell: TextOverviewTooltipCell,
className: 'description', className: 'description',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
{ {
Header: intl.get('quantity'), Header: intl.get('quantity'),
accessor: 'quantity', accessor: 'quantity',
Cell: FormatNumberCell, Cell: FormatNumberCell,
width: 100, width: getColumnWidth(entries, 'quantity', {
minWidth: 60,
magicSpacing: 5,
}),
align: 'right', align: 'right',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
{ {
Header: intl.get('rate'), Header: intl.get('rate'),
accessor: 'rate', accessor: 'rate',
Cell: FormatNumberCell, Cell: FormatNumberCell,
width: 100, width: getColumnWidth(entries, 'rate', {
minWidth: 60,
magicSpacing: 5,
}),
align: 'right', align: 'right',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
{ {
Header: intl.get('amount'), Header: intl.get('amount'),
accessor: 'amount', accessor: 'amount',
Cell: FormatNumberCell, Cell: FormatNumberCell,
width: 100, width: getColumnWidth(entries, 'amount', {
minWidth: 60,
magicSpacing: 5,
}),
align: 'right', align: 'right',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
], ],
[], [],
); );
};
/** /**
* Credit note more actions mneu. * Credit note more actions mneu.

View File

@@ -4,7 +4,6 @@ import styled from 'styled-components';
import { import {
Button, Button,
Popover, Popover,
Tooltip,
PopoverInteractionKind, PopoverInteractionKind,
Position, Position,
MenuItem, MenuItem,
@@ -52,7 +51,6 @@ export const useInvoiceReadonlyEntriesColumns = () => {
Cell: TextOverviewTooltipCell, Cell: TextOverviewTooltipCell,
disableSortBy: true, disableSortBy: true,
textOverview: true, textOverview: true,
width: 75,
}, },
{ {
Header: intl.get('quantity'), Header: intl.get('quantity'),

View File

@@ -3,43 +3,65 @@ import intl from 'react-intl-universal';
import moment from 'moment'; import moment from 'moment';
import { FormatNumberCell } from '../../../components'; import { FormatNumberCell } from '../../../components';
import { getColumnWidth } from 'utils';
import { usePaymentMadeDetailContext } from './PaymentMadeDetailProvider';
export const usePaymentMadeEntriesColumns = () => export const usePaymentMadeEntriesColumns = () => {
React.useMemo(() => [ // Payment made details context.
{ const {
Header: intl.get('date'), paymentMade: { entries },
accessor: (row) => moment(row.date).format('YYYY MMM DD'), } = usePaymentMadeDetailContext();
width: 100,
disableSortBy: true, return React.useMemo(
className: 'date', () => [
}, {
{ Header: intl.get('date'),
Header: intl.get('bill_number'), accessor: (row) => moment(row.date).format('YYYY MMM DD'),
accessor: 'bill_no', width: 100,
width: 150, disableSortBy: true,
disableSortBy: true, className: 'date',
className: 'bill_number', },
}, {
{ Header: intl.get('bill_number'),
Header: intl.get('bill_amount'), accessor: 'bill_no',
accessor: 'bill.amount', width: 150,
Cell: FormatNumberCell, disableSortBy: true,
align: 'right', className: 'bill_number',
}, },
{ {
Header: intl.get('due_amount'), Header: intl.get('bill_amount'),
accessor: 'bill.due_amount', accessor: 'bill.amount',
Cell: FormatNumberCell, Cell: FormatNumberCell,
width: 100, width: getColumnWidth(entries, 'bill.amount', {
disableSortBy: true, minWidth: 60,
align: 'right', magicSpacing: 5,
}, }),
{ align: 'right',
Header: intl.get('payment_amount'), },
accessor: 'payment_amount', {
Cell: FormatNumberCell, Header: intl.get('due_amount'),
width: 100, accessor: 'bill.due_amount',
disableSortBy: true, Cell: FormatNumberCell,
align: 'right', width: getColumnWidth(entries, 'bill.due_amount', {
}, minWidth: 60,
], []); magicSpacing: 5,
}),
disableSortBy: true,
align: 'right',
},
{
Header: intl.get('payment_amount'),
accessor: 'payment_amount',
Cell: FormatNumberCell,
width: getColumnWidth(entries, 'payment_amount', {
minWidth: 60,
magicSpacing: 5,
}),
disableSortBy: true,
textOverview: true,
align: 'right',
},
],
[],
);
};

View File

@@ -2,12 +2,18 @@ import React from 'react';
import intl from 'react-intl-universal'; import intl from 'react-intl-universal';
import moment from 'moment'; import moment from 'moment';
import { FormatNumberCell } from '../../../components'; import { FormatNumberCell } from '../../../components';
import { getColumnWidth } from 'utils';
import { usePaymentReceiveDetailContext } from './PaymentReceiveDetailProvider';
/** /**
* Retrieve payment entries table columns. * Retrieve payment entries table columns.
*/ */
export const usePaymentReceiveEntriesColumns = () => export const usePaymentReceiveEntriesColumns = () => {
React.useMemo( const {
paymentReceive: { entries },
} = usePaymentReceiveDetailContext();
return React.useMemo(
() => [ () => [
{ {
Header: intl.get('date'), Header: intl.get('date'),
@@ -27,24 +33,38 @@ export const usePaymentReceiveEntriesColumns = () =>
Header: intl.get('invoice_amount'), Header: intl.get('invoice_amount'),
accessor: 'invoice.balance', accessor: 'invoice.balance',
Cell: FormatNumberCell, Cell: FormatNumberCell,
width: getColumnWidth(entries, 'invoice.balance', {
minWidth: 60,
magicSpacing: 5,
}),
align: 'right', align: 'right',
textOverview: true,
}, },
{ {
Header: intl.get('amount_due'), Header: intl.get('amount_due'),
accessor: 'invoice.due_amount', accessor: 'invoice.due_amount',
Cell: FormatNumberCell, Cell: FormatNumberCell,
align: 'right', align: 'right',
width: 100, width: getColumnWidth(entries, 'invoice.due_amount', {
minWidth: 60,
magicSpacing: 5,
}),
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
{ {
Header: intl.get('payment_amount'), Header: intl.get('payment_amount'),
accessor: 'invoice.payment_amount', accessor: 'invoice.payment_amount',
Cell: FormatNumberCell, Cell: FormatNumberCell,
align: 'right', align: 'right',
width: 100, width: getColumnWidth(entries, 'invoice.payment_amount', {
minWidth: 60,
magicSpacing: 5,
}),
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
], ],
[], [],
); );
};

View File

@@ -1,44 +1,69 @@
import React from 'react'; import React from 'react';
import intl from 'react-intl-universal'; import intl from 'react-intl-universal';
import { FormatNumberCell } from '../../../components'; import { getColumnWidth } from 'utils';
import { FormatNumberCell, TextOverviewTooltipCell } from '../../../components';
export const useReceiptReadonlyEntriesTableColumns = () => React.useMemo(() => [ import { useReceiptDetailDrawerContext } from './ReceiptDetailDrawerProvider.js';
{
Header: intl.get('product_and_service'),
accessor: 'item.name',
width: 150,
className: 'name',
disableSortBy: true
},
{
Header: intl.get('description'),
accessor: 'description',
className: 'description',
disableSortBy: true
},
{
Header: intl.get('quantity'),
accessor: 'quantity',
Cell: FormatNumberCell,
width: 100,
align: 'right',
disableSortBy: true
},
{
Header: intl.get('rate'),
accessor: 'rate',
Cell: FormatNumberCell,
width: 100,
align: 'right',
disableSortBy: true
},
{
Header: intl.get('amount'),
accessor: 'amount',
Cell: FormatNumberCell,
width: 100,
align: 'right',
disableSortBy: true
},
], []);
export const useReceiptReadonlyEntriesTableColumns = () => {
// Receipt details drawer context.
const {
receipt: { entries },
} = useReceiptDetailDrawerContext();
return React.useMemo(
() => [
{
Header: intl.get('product_and_service'),
accessor: 'item.name',
Cell: TextOverviewTooltipCell,
width: 150,
className: 'name',
disableSortBy: true,
textOverview: true,
},
{
Header: intl.get('description'),
accessor: 'description',
Cell: TextOverviewTooltipCell,
className: 'description',
disableSortBy: true,
textOverview: true,
},
{
Header: intl.get('quantity'),
accessor: 'quantity',
Cell: FormatNumberCell,
width: getColumnWidth(entries, 'quantity', {
minWidth: 60,
magicSpacing: 5,
}),
align: 'right',
disableSortBy: true,
},
{
Header: intl.get('rate'),
accessor: 'rate',
Cell: FormatNumberCell,
width: getColumnWidth(entries, 'rate', {
minWidth: 60,
magicSpacing: 5,
}),
align: 'right',
disableSortBy: true,
textOverview: true,
},
{
Header: intl.get('amount'),
accessor: 'amount',
Cell: FormatNumberCell,
width: getColumnWidth(entries, 'amount', {
minWidth: 60,
magicSpacing: 5,
}),
align: 'right',
disableSortBy: true,
textOverview: true,
},
],
[],
);
};

View File

@@ -10,59 +10,82 @@ import {
Tag, Tag,
Intent, Intent,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { getColumnWidth } from 'utils';
import { import {
Icon, Icon,
FormattedMessage as T, FormattedMessage as T,
TextOverviewTooltipCell,
FormatNumberCell, FormatNumberCell,
Choose, Choose,
} from '../../../components'; } from '../../../components';
import { useVendorCreditDetailDrawerContext } from './VendorCreditDetailDrawerProvider';
/** /**
* Retrieve vendor credit readonly details entries table columns. * Retrieve vendor credit readonly details entries table columns.
*/ */
export const useVendorCreditReadonlyEntriesTableColumns = () => export const useVendorCreditReadonlyEntriesTableColumns = () => {
React.useMemo( const {
vendorCredit: { entries },
} = useVendorCreditDetailDrawerContext();
return React.useMemo(
() => [ () => [
{ {
Header: intl.get('product_and_service'), Header: intl.get('product_and_service'),
accessor: 'item.name', accessor: 'item.name',
Cell: TextOverviewTooltipCell,
width: 150, width: 150,
className: 'item', className: 'item',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
{ {
Header: intl.get('description'), Header: intl.get('description'),
accessor: 'description', accessor: 'description',
Cell: TextOverviewTooltipCell,
className: 'description', className: 'description',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
{ {
Header: intl.get('quantity'), Header: intl.get('quantity'),
accessor: 'quantity', accessor: 'quantity',
Cell: FormatNumberCell, Cell: FormatNumberCell,
width: 100, width: getColumnWidth(entries, 'quantity', {
minWidth: 60,
magicSpacing: 5,
}),
align: 'right', align: 'right',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
{ {
Header: intl.get('rate'), Header: intl.get('rate'),
accessor: 'rate', accessor: 'rate',
Cell: FormatNumberCell, Cell: FormatNumberCell,
width: 100, width: getColumnWidth(entries, 'rate', {
minWidth: 60,
magicSpacing: 5,
}),
align: 'right', align: 'right',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
{ {
Header: intl.get('amount'), Header: intl.get('amount'),
accessor: 'amount', accessor: 'amount',
Cell: FormatNumberCell, Cell: FormatNumberCell,
width: 100, width: getColumnWidth(entries, 'amount', {
minWidth: 60,
magicSpacing: 5,
}),
align: 'right', align: 'right',
disableSortBy: true, disableSortBy: true,
textOverview: true,
}, },
], ],
[], [],
); );
};
/** /**
* Vendor note more actions menu. * Vendor note more actions menu.