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

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

View File

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

View File

@@ -14,6 +14,7 @@ const Schema = Yup.object().shape({
.label(formatMessage({ id: 'payment_account_' })),
payment_number: Yup.string()
.max(DATATYPES_LENGTH.STRING)
.nullable()
.label(formatMessage({ id: 'payment_no_' })),
reference: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
description: Yup.string().max(DATATYPES_LENGTH.TEXT),

View File

@@ -162,7 +162,6 @@ function PaymentMadeFormHeader({
label={<T id={'payment_no'} />}
inline={true}
className={('form-group--payment_number', Classes.FILL)}
labelInfo={<FieldRequiredHint />}
intent={
errors.payment_number && touched.payment_number && Intent.DANGER
}

View File

@@ -1,5 +1,5 @@
import React, { useState, useEffect, useMemo, useCallback } from 'react';
import { Button } from '@blueprintjs/core';
import { Button } from '@blueprintjs/core';
import { FormattedMessage as T, useIntl } from 'react-intl';
import moment from 'moment';
import { sumBy } from 'lodash';
@@ -26,7 +26,7 @@ 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);
};
@@ -40,15 +40,17 @@ export default function PaymentMadeItemsTableEditor({
onUpdateData,
data,
errors,
noResultsMessage
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]);
@@ -80,7 +82,7 @@ export default function PaymentMadeItemsTableEditor({
},
{
Header: formatMessage({ id: 'bill_number' }),
accessor: (row) => `#${row?.bill_number}`,
accessor: (row) => `#${row?.bill_number || ''}`,
Cell: CellRenderer(EmptyDiv, 'bill_number'),
disableSortBy: true,
className: 'bill_number',
@@ -116,7 +118,7 @@ export default function PaymentMadeItemsTableEditor({
};
const rowClassNames = useCallback(
(row) => ({ 'row--total': localData.length === row.index + 1 }),
(row) => ({ 'row--total': localData.length === row.index + 1 }),
[localData],
);
@@ -129,7 +131,7 @@ export default function PaymentMadeItemsTableEditor({
columnId,
value,
);
newRows.splice(-1,1); // removes the total row.
newRows.splice(-1, 1); // removes the total row.
setLocalData(newRows);
onUpdateData && onUpdateData(newRows);
@@ -138,10 +140,12 @@ export default function PaymentMadeItemsTableEditor({
);
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}

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',
},