Fix :Sells and purchases transactions numbers to optional.

This commit is contained in:
elforjani3
2020-11-22 12:00:01 +02:00
parent f73ed19e77
commit 29d5f7d74b
9 changed files with 37 additions and 30 deletions

View File

@@ -114,7 +114,7 @@ function EstimatesDataTable({
{
id: 'estimate_number',
Header: formatMessage({ id: 'estimate_number' }),
accessor: (row) => `#${row.estimate_number}`,
accessor: (row) => (row.estimate_number ? `#${row.estimate_number}` : null),
width: 140,
className: 'estimate_number',
},

View File

@@ -112,7 +112,7 @@ function InvoicesDataTable({
{
id: 'invoice_no',
Header: formatMessage({ id: 'invoice_no__' }),
accessor: (row) => `#${row.invoice_no}`,
accessor: (row) => (row.invoice_no ? `#${row.invoice_no}` : null),
width: 140,
className: 'invoice_no',
},

View File

@@ -26,12 +26,12 @@ const CellRenderer = (content, type) => (props) => {
const TotalCellRederer = (content, type) => (props) => {
if (props.data.length === props.row.index + 1) {
return <Money amount={props.cell.row.original[type]} currency={'USD'} />
return <Money amount={props.cell.row.original[type]} currency={'USD'} />;
}
return content(props);
};
export default function PaymentReceiveItemsTableEditor ({
export default function PaymentReceiveItemsTableEditor({
onClickClearAllLines,
onUpdateData,
data,
@@ -39,12 +39,14 @@ export default function PaymentReceiveItemsTableEditor ({
noResultsMessage,
}) {
const transformedData = useMemo(() => {
const rows = [ ...data ];
const rows = [...data];
const totalRow = {
due_amount: sumBy(data, 'due_amount'),
payment_amount: sumBy(data, 'payment_amount'),
};
if (rows.length > 0) { rows.push(totalRow) }
if (rows.length > 0) {
rows.push(totalRow);
}
return rows;
}, [data]);
@@ -81,7 +83,7 @@ export default function PaymentReceiveItemsTableEditor ({
Header: formatMessage({ id: 'invocie_number' }),
accessor: (row) => {
const invNumber = row?.invoice_no || row?.id;
return `#INV-${invNumber}`;
return `#INV-${invNumber || ''}`;
},
Cell: CellRenderer(EmptyDiv, 'invoice_no'),
disableSortBy: true,
@@ -121,7 +123,7 @@ export default function PaymentReceiveItemsTableEditor ({
};
const rowClassNames = useCallback(
(row) => ({ 'row--total': localData.length === row.index + 1 }),
(row) => ({ 'row--total': localData.length === row.index + 1 }),
[localData],
);
@@ -144,10 +146,12 @@ export default function PaymentReceiveItemsTableEditor ({
);
return (
<div className={classNames(
CLASSES.DATATABLE_EDITOR,
CLASSES.DATATABLE_EDITOR_ITEMS_ENTRIES,
)}>
<div
className={classNames(
CLASSES.DATATABLE_EDITOR,
CLASSES.DATATABLE_EDITOR_ITEMS_ENTRIES,
)}
>
<DataTable
columns={columns}
data={localData}
@@ -170,5 +174,4 @@ export default function PaymentReceiveItemsTableEditor ({
</div>
</div>
);
}
}

View File

@@ -111,7 +111,7 @@ function ReceiptsDataTable({
{
id: 'receipt_number',
Header: formatMessage({ id: 'receipt_number' }),
accessor: (row) => `#${row.receipt_number}`,
accessor: (row) => (row.receipt_number ? `#${row.receipt_number}` : null),
width: 140,
className: 'receipt_number',
},