mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
60
client/src/components/CurrencySelectList.js
Normal file
60
client/src/components/CurrencySelectList.js
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import React, { useCallback, useState, useEffect, useMemo } from 'react';
|
||||||
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
|
import { ListSelect } from 'components';
|
||||||
|
import { MenuItem } from '@blueprintjs/core';
|
||||||
|
|
||||||
|
export default function CurrencySelectList({
|
||||||
|
currenciesList,
|
||||||
|
selectedCurrencyCode,
|
||||||
|
defaultSelectText = <T id={'select_currency_code'} />,
|
||||||
|
onCurrencySelected,
|
||||||
|
...restProps
|
||||||
|
}) {
|
||||||
|
const [selectedCurrency, setSelectedCurrency] = useState(null);
|
||||||
|
|
||||||
|
// Filters currencies list.
|
||||||
|
const filterCurrencies = (query, currency, _index, exactMatch) => {
|
||||||
|
const normalizedTitle = currency.currency_code.toLowerCase();
|
||||||
|
const normalizedQuery = query.toLowerCase();
|
||||||
|
|
||||||
|
if (exactMatch) {
|
||||||
|
return normalizedTitle === normalizedQuery;
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
`${currency.currency_code} ${normalizedTitle}`.indexOf(
|
||||||
|
normalizedQuery,
|
||||||
|
) >= 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onCurrencySelect = useCallback((currency) => {
|
||||||
|
setSelectedCurrency({ ...currency });
|
||||||
|
onCurrencySelected && onCurrencySelected(currency);
|
||||||
|
});
|
||||||
|
|
||||||
|
const currencyCodeRenderer = useCallback((CurrencyCode, { handleClick }) => {
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
|
key={CurrencyCode.id}
|
||||||
|
text={CurrencyCode.currency_code}
|
||||||
|
onClick={handleClick}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ListSelect
|
||||||
|
items={currenciesList}
|
||||||
|
selectedItemProp={'currency_code'}
|
||||||
|
selectedItem={selectedCurrencyCode}
|
||||||
|
labelProp={'currency_code'}
|
||||||
|
defaultText={defaultSelectText}
|
||||||
|
onItemSelect={onCurrencySelect}
|
||||||
|
itemPredicate={filterCurrencies}
|
||||||
|
itemRenderer={currencyCodeRenderer}
|
||||||
|
popoverProps={{ minimal: true }}
|
||||||
|
{...restProps}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -31,6 +31,8 @@ import Col from './Grid/Col';
|
|||||||
import CloudLoadingIndicator from './CloudLoadingIndicator';
|
import CloudLoadingIndicator from './CloudLoadingIndicator';
|
||||||
import MoneyExchangeRate from './MoneyExchangeRate';
|
import MoneyExchangeRate from './MoneyExchangeRate';
|
||||||
import ContactSelecetList from './ContactSelecetList';
|
import ContactSelecetList from './ContactSelecetList';
|
||||||
|
import CurrencySelectList from './CurrencySelectList'
|
||||||
|
|
||||||
|
|
||||||
const Hint = FieldHint;
|
const Hint = FieldHint;
|
||||||
|
|
||||||
@@ -69,4 +71,5 @@ export {
|
|||||||
CloudLoadingIndicator,
|
CloudLoadingIndicator,
|
||||||
MoneyExchangeRate,
|
MoneyExchangeRate,
|
||||||
ContactSelecetList ,
|
ContactSelecetList ,
|
||||||
|
CurrencySelectList
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ import { compose } from 'utils';
|
|||||||
const CurrencyFormDialogContent = lazy(() =>
|
const CurrencyFormDialogContent = lazy(() =>
|
||||||
import('./CurencyFormDialogContent'),
|
import('./CurencyFormDialogContent'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Currency form dialog.
|
||||||
|
*/
|
||||||
function CurrencyFormDialog({
|
function CurrencyFormDialog({
|
||||||
dialogName,
|
dialogName,
|
||||||
payload = { action: '', id: null },
|
payload = { action: '', id: null },
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
// import { connect } from 'react-redux';
|
|
||||||
// import { compose } from 'utils';
|
|
||||||
|
|
||||||
// import withDialogActions from 'containers/Dialog/withDialogActions';
|
|
||||||
// import withDialogRedux from 'components/DialogReduxConnect';
|
|
||||||
// import withExchangeRateDetail from 'containers/ExchangeRates/withExchangeRateDetail';
|
|
||||||
// import withExchangeRatesActions from 'containers/ExchangeRates/withExchangeRatesActions';
|
|
||||||
// import withExchangeRates from 'containers/ExchangeRates/withExchangeRates';
|
|
||||||
// import withCurrencies from 'containers/Currencies/withCurrencies';
|
|
||||||
|
|
||||||
// const mapStateToProps = (state, props) => ({
|
|
||||||
// dialogName: 'exchangeRate-form',
|
|
||||||
// exchangeRateId:
|
|
||||||
// props.payload.action === 'edit' && props.payload.id
|
|
||||||
// ? props.payload.id
|
|
||||||
// : null,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const withExchangeRateDialog = connect(mapStateToProps);
|
|
||||||
|
|
||||||
// export default compose(
|
|
||||||
// withDialogRedux(null, 'exchangeRate-form'),
|
|
||||||
// withExchangeRateDialog,
|
|
||||||
// withCurrencies(({ currenciesList }) => ({
|
|
||||||
// currenciesList,
|
|
||||||
// })),
|
|
||||||
// withExchangeRatesActions,
|
|
||||||
// withExchangeRateDetail,
|
|
||||||
// withExchangeRates(({ exchangeRatesList }) => ({
|
|
||||||
// exchangeRatesList,
|
|
||||||
// })),
|
|
||||||
// withDialogActions,
|
|
||||||
// );
|
|
||||||
@@ -23,6 +23,7 @@ import {
|
|||||||
ListSelect,
|
ListSelect,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
FieldRequiredHint,
|
FieldRequiredHint,
|
||||||
|
CurrencySelectList,
|
||||||
} from 'components';
|
} from 'components';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import withExchangeRateDetail from 'containers/ExchangeRates/withExchangeRateDetail';
|
import withExchangeRateDetail from 'containers/ExchangeRates/withExchangeRateDetail';
|
||||||
@@ -173,33 +174,6 @@ function ExchangeRateFormDialogContent({
|
|||||||
},
|
},
|
||||||
[setFieldValue, selectedItems],
|
[setFieldValue, selectedItems],
|
||||||
);
|
);
|
||||||
|
|
||||||
const filterCurrencyCode = (query, currency, _index, exactMatch) => {
|
|
||||||
const normalizedTitle = currency.currency_code.toLowerCase();
|
|
||||||
const normalizedQuery = query.toLowerCase();
|
|
||||||
|
|
||||||
if (exactMatch) {
|
|
||||||
return normalizedTitle === normalizedQuery;
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
`${currency.currency_code} ${normalizedTitle}`.indexOf(
|
|
||||||
normalizedQuery,
|
|
||||||
) >= 0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const currencyCodeRenderer = useCallback((CurrencyCode, { handleClick }) => {
|
|
||||||
return (
|
|
||||||
<MenuItem
|
|
||||||
className={'exchangeRate-menu'}
|
|
||||||
key={CurrencyCode.id}
|
|
||||||
text={CurrencyCode.currency_code}
|
|
||||||
onClick={handleClick}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DialogContent isLoading={fetchCurrencies.isFetching}>
|
<DialogContent isLoading={fetchCurrencies.isFetching}>
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
@@ -232,17 +206,10 @@ function ExchangeRateFormDialogContent({
|
|||||||
<ErrorMessage name="currency_code" {...{ errors, touched }} />
|
<ErrorMessage name="currency_code" {...{ errors, touched }} />
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ListSelect
|
<CurrencySelectList
|
||||||
items={currenciesList}
|
currenciesList={currenciesList}
|
||||||
noResults={<MenuItem disabled={true} text="No results." />}
|
selectedCurrencyCode={values.currency_code}
|
||||||
itemRenderer={currencyCodeRenderer}
|
onCurrencySelected={onItemsSelect('currency_code')}
|
||||||
itemPredicate={filterCurrencyCode}
|
|
||||||
popoverProps={{ minimal: true }}
|
|
||||||
onItemSelect={onItemsSelect('currency_code')}
|
|
||||||
selectedItem={values.currency_code}
|
|
||||||
selectedItemProp={'currency_code'}
|
|
||||||
defaultText={<T id={'select_currency_code'} />}
|
|
||||||
labelProp={'currency_code'}
|
|
||||||
disabled={action === 'edit'}
|
disabled={action === 'edit'}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
@@ -14,7 +14,7 @@ import moment from 'moment';
|
|||||||
import { momentFormatter, compose, tansformDateValue } from 'utils';
|
import { momentFormatter, compose, tansformDateValue } from 'utils';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import {
|
import {
|
||||||
ListSelect,
|
CurrencySelectList,
|
||||||
ContactSelecetList,
|
ContactSelecetList,
|
||||||
ErrorMessage,
|
ErrorMessage,
|
||||||
AccountsSelectList,
|
AccountsSelectList,
|
||||||
@@ -42,28 +42,6 @@ function ExpenseFormHeader({
|
|||||||
[setFieldValue],
|
[setFieldValue],
|
||||||
);
|
);
|
||||||
|
|
||||||
const currencyCodeRenderer = useCallback((item, { handleClick }) => {
|
|
||||||
return (
|
|
||||||
<MenuItem key={item.id} text={item.currency_code} onClick={handleClick} />
|
|
||||||
);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Filters Currency code.
|
|
||||||
const filterCurrencyCode = (query, currency, _index, exactMatch) => {
|
|
||||||
const normalizedTitle = currency.currency_code.toLowerCase();
|
|
||||||
const normalizedQuery = query.toLowerCase();
|
|
||||||
|
|
||||||
if (exactMatch) {
|
|
||||||
return normalizedTitle === normalizedQuery;
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
`${currency.currency_code} ${normalizedTitle}`.indexOf(
|
|
||||||
normalizedQuery,
|
|
||||||
) >= 0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Handles change account.
|
// Handles change account.
|
||||||
const onChangeAccount = useCallback(
|
const onChangeAccount = useCallback(
|
||||||
(account) => {
|
(account) => {
|
||||||
@@ -91,17 +69,6 @@ function ExpenseFormHeader({
|
|||||||
[accountsList],
|
[accountsList],
|
||||||
);
|
);
|
||||||
|
|
||||||
const CustomerRenderer = useCallback(
|
|
||||||
(cutomer, { handleClick }) => (
|
|
||||||
<MenuItem
|
|
||||||
key={cutomer.id}
|
|
||||||
text={cutomer.display_name}
|
|
||||||
onClick={handleClick}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
// handle change customer
|
// handle change customer
|
||||||
const onChangeCustomer = useCallback(
|
const onChangeCustomer = useCallback(
|
||||||
(filedName) => {
|
(filedName) => {
|
||||||
@@ -205,17 +172,10 @@ function ExpenseFormHeader({
|
|||||||
<ErrorMessage name="currency_code" {...{ errors, touched }} />
|
<ErrorMessage name="currency_code" {...{ errors, touched }} />
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ListSelect
|
<CurrencySelectList
|
||||||
items={currenciesList}
|
currenciesList={currenciesList}
|
||||||
noResults={<MenuItem disabled={true} text="No results." />}
|
selectedCurrencyCode={values.currency_code}
|
||||||
itemRenderer={currencyCodeRenderer}
|
onCurrencySelected={onItemsSelect('currency_code')}
|
||||||
itemPredicate={filterCurrencyCode}
|
|
||||||
popoverProps={{ minimal: true }}
|
|
||||||
onItemSelect={onItemsSelect('currency_code')}
|
|
||||||
selectedItem={values.currency_code}
|
|
||||||
selectedItemProp={'currency_code'}
|
|
||||||
defaultText={<T id={'select_currency'} />}
|
|
||||||
labelProp={'currency_code'}
|
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</Col>
|
</Col>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import moment from 'moment';
|
|||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
import { pick } from 'lodash';
|
import { pick, sumBy } from 'lodash';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
|
|
||||||
import BillFormHeader from './BillFormHeader';
|
import BillFormHeader from './BillFormHeader';
|
||||||
@@ -215,11 +215,25 @@ function BillForm({
|
|||||||
...initialValues,
|
...initialValues,
|
||||||
},
|
},
|
||||||
onSubmit: (values, { setSubmitting, setErrors, resetForm }) => {
|
onSubmit: (values, { setSubmitting, setErrors, resetForm }) => {
|
||||||
setSubmitting(true);
|
const entries = values.entries.filter(
|
||||||
|
(item) => item.item_id && item.quantity,
|
||||||
|
);
|
||||||
|
const totalQuantity = sumBy(entries, (entry) => parseInt(entry.quantity));
|
||||||
|
|
||||||
|
if (totalQuantity === 0) {
|
||||||
|
AppToaster.show({
|
||||||
|
message: formatMessage({
|
||||||
|
id: 'quantity_cannot_be_zero_or_empty',
|
||||||
|
}),
|
||||||
|
intent: Intent.DANGER,
|
||||||
|
});
|
||||||
|
setSubmitting(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const form = {
|
const form = {
|
||||||
...values,
|
...values,
|
||||||
entries: values.entries.filter((item) => item.item_id && item.quantity),
|
entries,
|
||||||
};
|
};
|
||||||
const requestForm = { ...form };
|
const requestForm = { ...form };
|
||||||
if (bill && bill.id) {
|
if (bill && bill.id) {
|
||||||
@@ -311,16 +325,20 @@ function BillForm({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Clear page subtitle once unmount bill form page.
|
// Clear page subtitle once unmount bill form page.
|
||||||
useEffect(() => () => {
|
useEffect(
|
||||||
changePageSubtitle('');
|
() => () => {
|
||||||
}, [changePageSubtitle]);
|
changePageSubtitle('');
|
||||||
|
},
|
||||||
|
[changePageSubtitle],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM, CLASSES.PAGE_FORM_BILL)}>
|
<div className={classNames(CLASSES.PAGE_FORM, CLASSES.PAGE_FORM_BILL)}>
|
||||||
<form onSubmit={formik.handleSubmit}>
|
<form onSubmit={formik.handleSubmit}>
|
||||||
<BillFormHeader
|
<BillFormHeader
|
||||||
formik={formik}
|
formik={formik}
|
||||||
onBillNumberChanged={handleBillNumberChanged} />
|
onBillNumberChanged={handleBillNumberChanged}
|
||||||
|
/>
|
||||||
|
|
||||||
<EstimatesItemsTable
|
<EstimatesItemsTable
|
||||||
formik={formik}
|
formik={formik}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { useFormik } from 'formik';
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { Intent, FormGroup, TextArea } from '@blueprintjs/core';
|
import { Intent, FormGroup, TextArea } from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
import { pick } from 'lodash';
|
import { pick, sumBy } from 'lodash';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
@@ -230,6 +230,19 @@ const EstimateForm = ({
|
|||||||
const entries = values.entries.filter(
|
const entries = values.entries.filter(
|
||||||
(item) => item.item_id && item.quantity,
|
(item) => item.item_id && item.quantity,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const totalQuantity = sumBy(entries, (entry) => parseInt(entry.quantity));
|
||||||
|
|
||||||
|
if (totalQuantity === 0) {
|
||||||
|
AppToaster.show({
|
||||||
|
message: formatMessage({
|
||||||
|
id: 'quantity_cannot_be_zero_or_empty',
|
||||||
|
}),
|
||||||
|
intent: Intent.DANGER,
|
||||||
|
});
|
||||||
|
setSubmitting(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const form = {
|
const form = {
|
||||||
...values,
|
...values,
|
||||||
entries,
|
entries,
|
||||||
@@ -277,7 +290,6 @@ const EstimateForm = ({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
formik.setFieldValue('estimate_number', estimateNumber);
|
formik.setFieldValue('estimate_number', estimateNumber);
|
||||||
}, [estimateNumber]);
|
}, [estimateNumber]);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { useFormik } from 'formik';
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { Intent, FormGroup, TextArea } from '@blueprintjs/core';
|
import { Intent, FormGroup, TextArea } from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
import { pick } from 'lodash';
|
import { pick, sumBy } from 'lodash';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
|
|
||||||
@@ -97,8 +97,7 @@ function InvoiceForm({
|
|||||||
due_date: Yup.date()
|
due_date: Yup.date()
|
||||||
.required()
|
.required()
|
||||||
.label(formatMessage({ id: 'due_date_' })),
|
.label(formatMessage({ id: 'due_date_' })),
|
||||||
invoice_no: Yup.string()
|
invoice_no: Yup.string().label(formatMessage({ id: 'invoice_no_' })),
|
||||||
.label(formatMessage({ id: 'invoice_no_' })),
|
|
||||||
reference_no: Yup.string().min(1).max(255),
|
reference_no: Yup.string().min(1).max(255),
|
||||||
status: Yup.string().required(),
|
status: Yup.string().required(),
|
||||||
invoice_message: Yup.string()
|
invoice_message: Yup.string()
|
||||||
@@ -127,7 +126,7 @@ function InvoiceForm({
|
|||||||
is: (quantity, rate) => quantity || rate,
|
is: (quantity, rate) => quantity || rate,
|
||||||
then: Yup.number().required(),
|
then: Yup.number().required(),
|
||||||
}),
|
}),
|
||||||
discount: Yup.number().nullable().min(0).max(100),
|
discount: Yup.number().nullable().min(0).max(100),
|
||||||
description: Yup.string().nullable(),
|
description: Yup.string().nullable(),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
@@ -232,6 +231,18 @@ function InvoiceForm({
|
|||||||
const entries = values.entries.filter(
|
const entries = values.entries.filter(
|
||||||
(item) => item.item_id && item.quantity,
|
(item) => item.item_id && item.quantity,
|
||||||
);
|
);
|
||||||
|
const totalQuantity = sumBy(entries, (entry) => parseInt(entry.quantity));
|
||||||
|
|
||||||
|
if (totalQuantity === 0) {
|
||||||
|
AppToaster.show({
|
||||||
|
message: formatMessage({
|
||||||
|
id: 'quantity_cannot_be_zero_or_empty',
|
||||||
|
}),
|
||||||
|
intent: Intent.DANGER,
|
||||||
|
});
|
||||||
|
setSubmitting(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const form = {
|
const form = {
|
||||||
...values,
|
...values,
|
||||||
entries,
|
entries,
|
||||||
@@ -279,6 +290,7 @@ function InvoiceForm({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
formik.setFieldValue('invoice_no', invoiceNumber);
|
formik.setFieldValue('invoice_no', invoiceNumber);
|
||||||
}, [invoiceNumber]);
|
}, [invoiceNumber]);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { useFormik } from 'formik';
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { Intent, FormGroup, TextArea } from '@blueprintjs/core';
|
import { Intent, FormGroup, TextArea } from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
import { pick } from 'lodash';
|
import { pick,sumBy } from 'lodash';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
@@ -229,6 +229,19 @@ function ReceiptForm({
|
|||||||
const entries = values.entries.filter(
|
const entries = values.entries.filter(
|
||||||
(item) => item.item_id && item.quantity,
|
(item) => item.item_id && item.quantity,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const totalQuantity = sumBy(entries, (entry) => parseInt(entry.quantity));
|
||||||
|
|
||||||
|
if (totalQuantity === 0) {
|
||||||
|
AppToaster.show({
|
||||||
|
message: formatMessage({
|
||||||
|
id: 'quantity_cannot_be_zero_or_empty',
|
||||||
|
}),
|
||||||
|
intent: Intent.DANGER,
|
||||||
|
});
|
||||||
|
setSubmitting(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const form = {
|
const form = {
|
||||||
...values,
|
...values,
|
||||||
entries,
|
entries,
|
||||||
|
|||||||
@@ -789,4 +789,6 @@ export default {
|
|||||||
sale_invoice_number_is_exists: 'Sale invoice number is exists',
|
sale_invoice_number_is_exists: 'Sale invoice number is exists',
|
||||||
bill_number_exists:'Bill number exists',
|
bill_number_exists:'Bill number exists',
|
||||||
ok: 'Ok!',
|
ok: 'Ok!',
|
||||||
|
quantity_cannot_be_zero_or_empty: 'Quantity cannot be zero or empty.',
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user