mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 07:40:32 +00:00
Fix: PaymentReceive & ExchangeRate & itemCategories
This commit is contained in:
@@ -19,7 +19,6 @@ import withDialogRedux from 'components/DialogReduxConnect';
|
|||||||
import ErrorMessage from 'components/ErrorMessage';
|
import ErrorMessage from 'components/ErrorMessage';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
import { getDialogPayload } from 'store/dashboard/dashboard.reducer';
|
|
||||||
|
|
||||||
import withCurrency from 'containers/Currencies/withCurrency';
|
import withCurrency from 'containers/Currencies/withCurrency';
|
||||||
import withCurrenciesActions from 'containers/Currencies/withCurrenciesActions';
|
import withCurrenciesActions from 'containers/Currencies/withCurrenciesActions';
|
||||||
@@ -27,7 +26,7 @@ import withCurrenciesActions from 'containers/Currencies/withCurrenciesActions';
|
|||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
function CurrencyDialog({
|
function CurrencyDialog({
|
||||||
name,
|
dialogName,
|
||||||
payload,
|
payload,
|
||||||
isOpen,
|
isOpen,
|
||||||
|
|
||||||
@@ -66,6 +65,7 @@ function CurrencyDialog({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
values,
|
||||||
errors,
|
errors,
|
||||||
touched,
|
touched,
|
||||||
isSubmitting,
|
isSubmitting,
|
||||||
@@ -83,7 +83,7 @@ function CurrencyDialog({
|
|||||||
if (payload.action === 'edit') {
|
if (payload.action === 'edit') {
|
||||||
requestEditCurrency(currency.id, values)
|
requestEditCurrency(currency.id, values)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
closeDialog(name);
|
closeDialog(dialogName);
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: formatMessage({
|
message: formatMessage({
|
||||||
id: 'the_currency_has_been_successfully_edited',
|
id: 'the_currency_has_been_successfully_edited',
|
||||||
@@ -99,7 +99,7 @@ function CurrencyDialog({
|
|||||||
} else {
|
} else {
|
||||||
requestSubmitCurrencies(values)
|
requestSubmitCurrencies(values)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
closeDialog(name);
|
closeDialog(dialogName);
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: formatMessage({
|
message: formatMessage({
|
||||||
id: 'the_currency_has_been_successfully_created',
|
id: 'the_currency_has_been_successfully_created',
|
||||||
@@ -117,8 +117,8 @@ function CurrencyDialog({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleClose = useCallback(() => {
|
const handleClose = useCallback(() => {
|
||||||
closeDialog(name);
|
closeDialog(dialogName);
|
||||||
}, [name, closeDialog]);
|
}, [dialogName, closeDialog]);
|
||||||
|
|
||||||
const onDialogOpening = useCallback(() => {
|
const onDialogOpening = useCallback(() => {
|
||||||
fetchCurrencies.refetch();
|
fetchCurrencies.refetch();
|
||||||
@@ -126,14 +126,14 @@ function CurrencyDialog({
|
|||||||
|
|
||||||
const onDialogClosed = useCallback(() => {
|
const onDialogClosed = useCallback(() => {
|
||||||
resetForm();
|
resetForm();
|
||||||
closeDialog(name);
|
closeDialog(dialogName);
|
||||||
}, [closeDialog, name, resetForm]);
|
}, [closeDialog, dialogName, resetForm]);
|
||||||
|
|
||||||
const requiredSpan = useMemo(() => <span className={'required'}>*</span>, []);
|
const requiredSpan = useMemo(() => <span className={'required'}>*</span>, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
name={name}
|
name={dialogName}
|
||||||
title={
|
title={
|
||||||
payload.action === 'edit' ? (
|
payload.action === 'edit' ? (
|
||||||
<T id={'edit_currency'} />
|
<T id={'edit_currency'} />
|
||||||
@@ -222,7 +222,7 @@ function CurrencyDialog({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => ({
|
const mapStateToProps = (state, props) => ({
|
||||||
dialogName: 'currency-form',
|
currency: 'currency-form',
|
||||||
});
|
});
|
||||||
|
|
||||||
const withCurrencyFormDialog = connect(mapStateToProps);
|
const withCurrencyFormDialog = connect(mapStateToProps);
|
||||||
|
|||||||
@@ -3,27 +3,31 @@ import { compose } from 'utils';
|
|||||||
|
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
import withDialogRedux from 'components/DialogReduxConnect';
|
import withDialogRedux from 'components/DialogReduxConnect';
|
||||||
|
import withExchangeRateDetail from 'containers/ExchangeRates/withExchangeRateDetail';
|
||||||
import withExchangeRatesActions from 'containers/ExchangeRates/withExchangeRatesActions';
|
import withExchangeRatesActions from 'containers/ExchangeRates/withExchangeRatesActions';
|
||||||
import withExchangeRates from 'containers/ExchangeRates/withExchangeRates';
|
import withExchangeRates from 'containers/ExchangeRates/withExchangeRates';
|
||||||
import withCurrencies from 'containers/Currencies/withCurrencies';
|
import withCurrencies from 'containers/Currencies/withCurrencies';
|
||||||
|
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => ({
|
const mapStateToProps = (state, props) => ({
|
||||||
dialogName: 'exchangeRate-form',
|
dialogName: 'exchangeRate-form',
|
||||||
|
exchangeRateId:
|
||||||
|
props.payload.action === 'edit' && props.payload.id
|
||||||
|
? props.payload.id
|
||||||
|
: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const withExchangeRateDialog = connect(mapStateToProps);
|
const withExchangeRateDialog = connect(mapStateToProps);
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
withExchangeRateDialog,
|
|
||||||
withDialogRedux(null, 'exchangeRate-form'),
|
withDialogRedux(null, 'exchangeRate-form'),
|
||||||
|
withExchangeRateDialog,
|
||||||
withCurrencies(({ currenciesList }) => ({
|
withCurrencies(({ currenciesList }) => ({
|
||||||
currenciesList,
|
currenciesList,
|
||||||
})),
|
})),
|
||||||
|
withExchangeRatesActions,
|
||||||
|
withExchangeRateDetail,
|
||||||
withExchangeRates(({ exchangeRatesList }) => ({
|
withExchangeRates(({ exchangeRatesList }) => ({
|
||||||
exchangeRatesList,
|
exchangeRatesList,
|
||||||
})),
|
})),
|
||||||
withExchangeRatesActions,
|
|
||||||
withDialogActions,
|
withDialogActions,
|
||||||
);
|
);
|
||||||
@@ -15,13 +15,8 @@ import { useFormik } from 'formik';
|
|||||||
import { useQuery, queryCache } from 'react-query';
|
import { useQuery, queryCache } from 'react-query';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { momentFormatter } from 'utils';
|
import { momentFormatter, tansformDateValue } from 'utils';
|
||||||
import {
|
import { AppToaster, Dialog, ErrorMessage, ListSelect } from 'components';
|
||||||
AppToaster,
|
|
||||||
Dialog,
|
|
||||||
ErrorMessage,
|
|
||||||
ListSelect,
|
|
||||||
} from 'components';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import withExchangeRatesDialog from './ExchangeRateDialog.container';
|
import withExchangeRatesDialog from './ExchangeRateDialog.container';
|
||||||
|
|
||||||
@@ -39,12 +34,13 @@ function ExchangeRateDialog({
|
|||||||
// #withCurrencies
|
// #withCurrencies
|
||||||
currenciesList,
|
currenciesList,
|
||||||
|
|
||||||
|
//#WithExchangeRateDetail
|
||||||
|
exchangeRate,
|
||||||
|
|
||||||
// #withExchangeRatesActions
|
// #withExchangeRatesActions
|
||||||
requestSubmitExchangeRate,
|
requestSubmitExchangeRate,
|
||||||
requestFetchExchangeRates,
|
requestFetchExchangeRates,
|
||||||
requestEditExchangeRate,
|
requestEditExchangeRate,
|
||||||
requestFetchCurrencies,
|
|
||||||
editExchangeRate,
|
|
||||||
}) {
|
}) {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const [selectedItems, setSelectedItems] = useState({});
|
const [selectedItems, setSelectedItems] = useState({});
|
||||||
@@ -90,7 +86,7 @@ function ExchangeRateDialog({
|
|||||||
validationSchema,
|
validationSchema,
|
||||||
initialValues: {
|
initialValues: {
|
||||||
...(payload.action === 'edit' &&
|
...(payload.action === 'edit' &&
|
||||||
pick(editExchangeRate, Object.keys(initialValues))),
|
pick(exchangeRate, Object.keys(initialValues))),
|
||||||
},
|
},
|
||||||
onSubmit: (values, { setSubmitting, setErrors }) => {
|
onSubmit: (values, { setSubmitting, setErrors }) => {
|
||||||
if (payload.action === 'edit') {
|
if (payload.action === 'edit') {
|
||||||
@@ -154,9 +150,9 @@ function ExchangeRateDialog({
|
|||||||
}, [fetchExchangeRatesDialog]);
|
}, [fetchExchangeRatesDialog]);
|
||||||
|
|
||||||
const handleDateChange = useCallback(
|
const handleDateChange = useCallback(
|
||||||
(date) => {
|
(date_filed) => (date) => {
|
||||||
const formatted = moment(date).format('YYYY-MM-DD');
|
const formatted = moment(date).format('YYYY-MM-DD');
|
||||||
setFieldValue('date', formatted);
|
setFieldValue(date_filed, formatted);
|
||||||
},
|
},
|
||||||
[setFieldValue],
|
[setFieldValue],
|
||||||
);
|
);
|
||||||
@@ -231,10 +227,10 @@ function ExchangeRateDialog({
|
|||||||
>
|
>
|
||||||
<DateInput
|
<DateInput
|
||||||
fill={true}
|
fill={true}
|
||||||
{...momentFormatter('YYYY-MM-DD')}
|
{...momentFormatter('YYYY/MM/DD')}
|
||||||
defaultValue={new Date()}
|
value={tansformDateValue(values.date)}
|
||||||
onChange={handleDateChange}
|
onChange={handleDateChange('date')}
|
||||||
popoverProps={{ position: Position.BOTTOM }}
|
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
||||||
disabled={payload.action === 'edit'}
|
disabled={payload.action === 'edit'}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import Icon from 'components/Icon';
|
|||||||
|
|
||||||
function ItemCategoryDialog({
|
function ItemCategoryDialog({
|
||||||
dialogName,
|
dialogName,
|
||||||
payload,
|
payload = {},
|
||||||
isOpen,
|
isOpen,
|
||||||
|
|
||||||
// #withDialog
|
// #withDialog
|
||||||
@@ -67,9 +67,12 @@ function ItemCategoryDialog({
|
|||||||
const fetchList = useQuery(['items-categories-list'], () =>
|
const fetchList = useQuery(['items-categories-list'], () =>
|
||||||
requestFetchItemCategories(),
|
requestFetchItemCategories(),
|
||||||
);
|
);
|
||||||
const fetchAccounts = useQuery('accounts-list', (key) =>
|
const fetchAccounts = useQuery(
|
||||||
requestFetchAccounts(),
|
'accounts-list',
|
||||||
|
() => requestFetchAccounts(),
|
||||||
|
{ enabled: false },
|
||||||
);
|
);
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
name: Yup.string()
|
name: Yup.string()
|
||||||
.required()
|
.required()
|
||||||
@@ -84,7 +87,7 @@ function ItemCategoryDialog({
|
|||||||
inventory_account_id: Yup.number()
|
inventory_account_id: Yup.number()
|
||||||
.required()
|
.required()
|
||||||
.label(formatMessage({ id: 'inventory_account_' })),
|
.label(formatMessage({ id: 'inventory_account_' })),
|
||||||
description: Yup.string().trim(),
|
description: Yup.string().trim().nullable(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const initialValues = useMemo(
|
const initialValues = useMemo(
|
||||||
@@ -228,14 +231,14 @@ function ItemCategoryDialog({
|
|||||||
}
|
}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
{
|
{
|
||||||
'dialog--loading': fetchList.isFetching,
|
'dialog--loading': fetchList.isFetching || fetchAccounts.isFetching,
|
||||||
},
|
},
|
||||||
'dialog--category-form',
|
'dialog--category-form',
|
||||||
)}
|
)}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onClosed={onDialogClosed}
|
onClosed={onDialogClosed}
|
||||||
onOpening={onDialogOpening}
|
onOpening={onDialogOpening}
|
||||||
isLoading={fetchList.isFetching}
|
isLoading={fetchList.isFetching || fetchAccounts.isFetching}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
>
|
>
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
@@ -358,12 +361,15 @@ function ItemCategoryDialog({
|
|||||||
label={<T id={'inventory_account'} />}
|
label={<T id={'inventory_account'} />}
|
||||||
inline={true}
|
inline={true}
|
||||||
intent={
|
intent={
|
||||||
errors.inventory_account &&
|
errors.inventory_account_id &&
|
||||||
touched.inventory_account &&
|
touched.inventory_account_id &&
|
||||||
Intent.DANGER
|
Intent.DANGER
|
||||||
}
|
}
|
||||||
helperText={
|
helperText={
|
||||||
<ErrorMessage {...{ errors, touched }} name="inventory_account" />
|
<ErrorMessage
|
||||||
|
{...{ errors, touched }}
|
||||||
|
name="inventory_account_id"
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'form-group--sell-account',
|
'form-group--sell-account',
|
||||||
@@ -373,9 +379,9 @@ function ItemCategoryDialog({
|
|||||||
>
|
>
|
||||||
<AccountsSelectList
|
<AccountsSelectList
|
||||||
accounts={accountsList}
|
accounts={accountsList}
|
||||||
onAccountSelected={onItemAccountSelect('inventory_account')}
|
onAccountSelected={onItemAccountSelect('inventory_account_id')}
|
||||||
defaultSelectText={<T id={'select_account'} />}
|
defaultSelectText={<T id={'select_account'} />}
|
||||||
selectedAccountId={values.inventory_account}
|
selectedAccountId={values.inventory_account_id}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</div>
|
</div>
|
||||||
@@ -404,7 +410,8 @@ function ItemCategoryDialog({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => ({
|
const mapStateToProps = (state, props) => ({
|
||||||
itemCategoryId: props?.dialogPayload?.id || null,
|
dialogName: 'item-category-form',
|
||||||
|
itemCategoryId: props?.payload?.id || null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const withItemCategoryDialog = connect(mapStateToProps);
|
const withItemCategoryDialog = connect(mapStateToProps);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import FilterDropdown from 'components/FilterDropdown';
|
|||||||
|
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
import withResourceDetail from 'containers/Resources/withResourceDetails';
|
import withResourceDetail from 'containers/Resources/withResourceDetails';
|
||||||
|
import withExchangeRatesActions from './withExchangeRatesActions';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,6 +33,9 @@ function ExchangeRateActionsBar({
|
|||||||
// #withResourceDetail
|
// #withResourceDetail
|
||||||
resourceFields,
|
resourceFields,
|
||||||
|
|
||||||
|
//#withExchangeRatesActions
|
||||||
|
addExchangeRatesTableQueries,
|
||||||
|
|
||||||
// #ownProps
|
// #ownProps
|
||||||
selectedRows = [],
|
selectedRows = [],
|
||||||
onDeleteExchangeRate,
|
onDeleteExchangeRate,
|
||||||
@@ -46,14 +49,20 @@ function ExchangeRateActionsBar({
|
|||||||
openDialog('exchangeRate-form', {});
|
openDialog('exchangeRate-form', {});
|
||||||
};
|
};
|
||||||
|
|
||||||
const filterDropdown = FilterDropdown({
|
// const filterDropdown = FilterDropdown({
|
||||||
fields: resourceFields,
|
// initialCondition: {
|
||||||
onFilterChange: (filterConditions) => {
|
// fieldKey: '',
|
||||||
setFilterCount(filterConditions.length || 0);
|
// compatator: 'contains',
|
||||||
|
// value: '',
|
||||||
onFilterChanged && onFilterChanged(filterConditions);
|
// },
|
||||||
},
|
// fields: resourceFields,
|
||||||
});
|
// onFilterChange: (filterConditions) => {
|
||||||
|
// addExchangeRatesTableQueries({
|
||||||
|
// filter_roles: filterConditions || '',
|
||||||
|
// });
|
||||||
|
// onFilterChanged && onFilterChanged(filterConditions);
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
const hasSelectedRows = useMemo(() => selectedRows.length > 0, [
|
const hasSelectedRows = useMemo(() => selectedRows.length > 0, [
|
||||||
selectedRows,
|
selectedRows,
|
||||||
@@ -76,16 +85,18 @@ function ExchangeRateActionsBar({
|
|||||||
|
|
||||||
<Popover
|
<Popover
|
||||||
minimal={true}
|
minimal={true}
|
||||||
content={filterDropdown}
|
// content={filterDropdown}
|
||||||
interactionKind={PopoverInteractionKind.CLICK}
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
position={Position.BOTTOM_LEFT}
|
position={Position.BOTTOM_LEFT}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
className={classNames(Classes.MINIMAL, 'button--filter')}
|
className={classNames(Classes.MINIMAL, 'button--filter')}
|
||||||
text={
|
text={
|
||||||
filterCount <= 0 ?
|
filterCount <= 0 ? (
|
||||||
(<T id={'filter'} />) :
|
<T id={'filter'} />
|
||||||
(`${filterCount} ${formatMessage({ id: 'filters_applied' })}`)
|
) : (
|
||||||
|
`${filterCount} ${formatMessage({ id: 'filters_applied' })}`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
icon={<Icon icon="filter-16" iconSize={16} />}
|
icon={<Icon icon="filter-16" iconSize={16} />}
|
||||||
/>
|
/>
|
||||||
@@ -117,7 +128,7 @@ function ExchangeRateActionsBar({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => ({
|
const mapStateToProps = (state, props) => ({
|
||||||
resourceName: 'exchange_rates',
|
resourceName: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const withExchangeRateActionBar = connect(mapStateToProps);
|
const withExchangeRateActionBar = connect(mapStateToProps);
|
||||||
@@ -128,4 +139,5 @@ export default compose(
|
|||||||
withResourceDetail(({ resourceFields }) => ({
|
withResourceDetail(({ resourceFields }) => ({
|
||||||
resourceFields,
|
resourceFields,
|
||||||
})),
|
})),
|
||||||
|
withExchangeRatesActions,
|
||||||
)(ExchangeRateActionsBar);
|
)(ExchangeRateActionsBar);
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
import React, { useCallback, useMemo, useState, useEffect } from 'react';
|
import React, { useCallback, useMemo, useState, useEffect } from 'react';
|
||||||
import { Button, Popover, Menu, MenuItem, Position,Intent } from '@blueprintjs/core';
|
import {
|
||||||
|
Button,
|
||||||
|
Popover,
|
||||||
|
Menu,
|
||||||
|
MenuItem,
|
||||||
|
Position,
|
||||||
|
Intent,
|
||||||
|
} from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
import Icon from 'components/Icon';
|
import { DataTable, Money, Icon } from 'components';
|
||||||
import DataTable from 'components/DataTable';
|
|
||||||
import LoadingIndicator from 'components/LoadingIndicator';
|
import LoadingIndicator from 'components/LoadingIndicator';
|
||||||
|
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
@@ -30,10 +37,12 @@ function ExchangeRateTable({
|
|||||||
const [initialMount, setInitialMount] = useState(false);
|
const [initialMount, setInitialMount] = useState(false);
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
const handelEditExchangeRate = (exchange_rate) => () => {
|
const handelEditExchangeRate = useCallback(
|
||||||
|
(exchange_rate) => () => {
|
||||||
openDialog('exchangeRate-form', { action: 'edit', id: exchange_rate.id });
|
openDialog('exchangeRate-form', { action: 'edit', id: exchange_rate.id });
|
||||||
onEditExchangeRate(exchange_rate.id);
|
},
|
||||||
};
|
[openDialog],
|
||||||
|
);
|
||||||
|
|
||||||
const handleDeleteExchangeRate = (exchange_rate) => () => {
|
const handleDeleteExchangeRate = (exchange_rate) => () => {
|
||||||
onDeleteExchangeRate(exchange_rate);
|
onDeleteExchangeRate(exchange_rate);
|
||||||
@@ -50,17 +59,19 @@ function ExchangeRateTable({
|
|||||||
text={<T id={'delete_exchange_rate'} />}
|
text={<T id={'delete_exchange_rate'} />}
|
||||||
intent={Intent.DANGER}
|
intent={Intent.DANGER}
|
||||||
onClick={handleDeleteExchangeRate(ExchangeRate)}
|
onClick={handleDeleteExchangeRate(ExchangeRate)}
|
||||||
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
/>
|
/>
|
||||||
</Menu>
|
</Menu>
|
||||||
),
|
),
|
||||||
[handelEditExchangeRate, handleDeleteExchangeRate],
|
[handelEditExchangeRate, handleDeleteExchangeRate],
|
||||||
);
|
);
|
||||||
|
|
||||||
const columns = useMemo(() => [
|
const columns = useMemo(
|
||||||
|
() => [
|
||||||
{
|
{
|
||||||
id: 'date',
|
id: 'date',
|
||||||
Header: formatMessage({ id: 'date' }),
|
Header: formatMessage({ id: 'date' }),
|
||||||
// accessor: 'date',
|
accessor: (r) => moment(r.date).format('YYYY MMM DD'),
|
||||||
width: 150,
|
width: 150,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -73,7 +84,7 @@ function ExchangeRateTable({
|
|||||||
{
|
{
|
||||||
id: 'exchange_rate',
|
id: 'exchange_rate',
|
||||||
Header: formatMessage({ id: 'exchange_rate' }),
|
Header: formatMessage({ id: 'exchange_rate' }),
|
||||||
accessor: 'exchange_rate',
|
accessor: (r) => <Money amount={r.exchange_rate} currency={'USD'} />,
|
||||||
className: 'exchange_rate',
|
className: 'exchange_rate',
|
||||||
width: 150,
|
width: 150,
|
||||||
},
|
},
|
||||||
@@ -85,14 +96,16 @@ function ExchangeRateTable({
|
|||||||
content={actionMenuList(cell.row.original)}
|
content={actionMenuList(cell.row.original)}
|
||||||
position={Position.RIGHT_BOTTOM}
|
position={Position.RIGHT_BOTTOM}
|
||||||
>
|
>
|
||||||
<Button icon={<Icon icon='more-h-16' iconSize={16} />} />
|
<Button icon={<Icon icon="more-h-16" iconSize={16} />} />
|
||||||
</Popover>
|
</Popover>
|
||||||
),
|
),
|
||||||
className: 'actions',
|
className: 'actions',
|
||||||
width: 50,
|
width: 50,
|
||||||
disableResizing: false,
|
disableResizing: false,
|
||||||
},
|
},
|
||||||
], [actionMenuList,formatMessage]);
|
],
|
||||||
|
[actionMenuList, formatMessage],
|
||||||
|
);
|
||||||
|
|
||||||
const selectionColumn = useMemo(
|
const selectionColumn = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { getExchangeRateById } from 'store/ExchangeRate/exchange.selector';
|
||||||
|
|
||||||
|
const mapStateToProps = (state, props) => ({
|
||||||
|
exchangeRate: getExchangeRateById(state, props),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps);
|
||||||
@@ -16,11 +16,15 @@ import { compose } from 'utils';
|
|||||||
import DataTable from 'components/DataTable';
|
import DataTable from 'components/DataTable';
|
||||||
|
|
||||||
import withItemCategories from './withItemCategories';
|
import withItemCategories from './withItemCategories';
|
||||||
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
const ItemsCategoryList = ({
|
const ItemsCategoryList = ({
|
||||||
// #withItemCategories
|
// #withItemCategories
|
||||||
categoriesList,
|
categoriesList,
|
||||||
|
|
||||||
|
// #withDialogActions.
|
||||||
|
openDialog,
|
||||||
|
|
||||||
// #ownProps
|
// #ownProps
|
||||||
onFetchData,
|
onFetchData,
|
||||||
onDeleteCategory,
|
onDeleteCategory,
|
||||||
@@ -30,11 +34,12 @@ const ItemsCategoryList = ({
|
|||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
const handelEditCategory = useCallback(
|
const handelEditCategory = useCallback(
|
||||||
(category) => {
|
(category) => () => {
|
||||||
onEditCategory(category);
|
openDialog('item-category-form', { action: 'edit', id: category.id });
|
||||||
},
|
},
|
||||||
[onEditCategory],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleDeleteCategory = useCallback(
|
const handleDeleteCategory = useCallback(
|
||||||
(category) => {
|
(category) => {
|
||||||
onDeleteCategory(category);
|
onDeleteCategory(category);
|
||||||
@@ -46,13 +51,14 @@ const ItemsCategoryList = ({
|
|||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
text={formatMessage({ id: 'edit_category' })}
|
text={formatMessage({ id: 'edit_category' })}
|
||||||
onClick={() => handelEditCategory(category)}
|
onClick={handelEditCategory(category)}
|
||||||
/>
|
/>
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
text={formatMessage({ id: 'delete_category' })}
|
text={formatMessage({ id: 'delete_category' })}
|
||||||
intent={Intent.DANGER}
|
intent={Intent.DANGER}
|
||||||
onClick={() => handleDeleteCategory(category)}
|
onClick={() => handleDeleteCategory(category)}
|
||||||
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
/>
|
/>
|
||||||
</Menu>
|
</Menu>
|
||||||
),
|
),
|
||||||
@@ -77,7 +83,7 @@ const ItemsCategoryList = ({
|
|||||||
{
|
{
|
||||||
id: 'count',
|
id: 'count',
|
||||||
Header: formatMessage({ id: 'count' }),
|
Header: formatMessage({ id: 'count' }),
|
||||||
accessor: (r) => r.count || '',
|
accessor: 'count',
|
||||||
className: 'count',
|
className: 'count',
|
||||||
width: 50,
|
width: 50,
|
||||||
},
|
},
|
||||||
@@ -154,4 +160,5 @@ export default compose(
|
|||||||
withItemCategories(({ categoriesList }) => ({
|
withItemCategories(({ categoriesList }) => ({
|
||||||
categoriesList,
|
categoriesList,
|
||||||
})),
|
})),
|
||||||
|
withDialogActions,
|
||||||
)(ItemsCategoryList);
|
)(ItemsCategoryList);
|
||||||
|
|||||||
@@ -50,9 +50,11 @@ function CurrenciesList({
|
|||||||
|
|
||||||
const fetchCurrencies = useQuery('currencies-table',
|
const fetchCurrencies = useQuery('currencies-table',
|
||||||
() => requestFetchCurrencies(),
|
() => requestFetchCurrencies(),
|
||||||
{ manual: true },
|
{ enabled: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
changePreferencesPageTitle(formatMessage({ id: 'currencies' }));
|
changePreferencesPageTitle(formatMessage({ id: 'currencies' }));
|
||||||
}, [changePreferencesPageTitle, formatMessage]);
|
}, [changePreferencesPageTitle, formatMessage]);
|
||||||
@@ -147,7 +149,7 @@ function CurrenciesList({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleDataTableFetchData = useCallback(() => {
|
const handleDataTableFetchData = useCallback(() => {
|
||||||
fetchCurrencies.refetch();
|
// fetchCurrencies.refetch();
|
||||||
}, [fetchCurrencies]);
|
}, [fetchCurrencies]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -77,7 +77,11 @@ function PaymentReceiveForm({
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (paymentReceive && paymentReceive.id) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
onCustomerChange && onCustomerChange(formik.values.customer_id);
|
onCustomerChange && onCustomerChange(formik.values.customer_id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -295,7 +299,7 @@ function PaymentReceiveForm({
|
|||||||
orderingIndex([...repeatValue(defaultPaymentReceive, MIN_LINES_NUMBER)]),
|
orderingIndex([...repeatValue(defaultPaymentReceive, MIN_LINES_NUMBER)]),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
console.log(formik.errors, 'ERROR');
|
|
||||||
return (
|
return (
|
||||||
<div className={'payment_receive_form'}>
|
<div className={'payment_receive_form'}>
|
||||||
<form onSubmit={formik.handleSubmit}>
|
<form onSubmit={formik.handleSubmit}>
|
||||||
|
|||||||
@@ -81,21 +81,12 @@ function PaymentReceiveItemsTable({
|
|||||||
invoices,
|
invoices,
|
||||||
}) {
|
}) {
|
||||||
const [rows, setRows] = useState([]);
|
const [rows, setRows] = useState([]);
|
||||||
const [entrie, setEntrie] = useState([]);
|
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setRows([...dueInvoices.map((e) => ({ ...e })), ...invoices, {}]);
|
setRows([...dueInvoices.map((e) => ({ ...e })), ...invoices, {}]);
|
||||||
setEntrie([
|
}, [invoices]);
|
||||||
...dueInvoices.map((e) => {
|
|
||||||
return { id: e.id, payment_amount: e.payment_amount };
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}, [dueInvoices]);
|
|
||||||
|
|
||||||
console.log(rows, 'rows');
|
|
||||||
console.log(entrie, 'entrie');
|
|
||||||
console.log(values, 'values');
|
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
// setRows([...dueInvoices.map((e) => ({ ...e })), {}]);
|
// setRows([...dueInvoices.map((e) => ({ ...e })), {}]);
|
||||||
|
|
||||||
@@ -188,7 +179,7 @@ function PaymentReceiveItemsTable({
|
|||||||
);
|
);
|
||||||
onClickRemoveRow && onClickRemoveRow(removeIndex);
|
onClickRemoveRow && onClickRemoveRow(removeIndex);
|
||||||
},
|
},
|
||||||
[entrie, setFieldValue, onClickRemoveRow],
|
[rows, setFieldValue, onClickRemoveRow],
|
||||||
);
|
);
|
||||||
|
|
||||||
const onClickNewRow = () => {
|
const onClickNewRow = () => {
|
||||||
@@ -215,7 +206,6 @@ function PaymentReceiveItemsTable({
|
|||||||
return row;
|
return row;
|
||||||
});
|
});
|
||||||
setRows(newRows);
|
setRows(newRows);
|
||||||
// setEntrie(newRows);
|
|
||||||
setFieldValue(
|
setFieldValue(
|
||||||
'entries',
|
'entries',
|
||||||
newRows.map((row) => ({
|
newRows.map((row) => ({
|
||||||
@@ -224,7 +214,7 @@ function PaymentReceiveItemsTable({
|
|||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[rows, setFieldValue, setEntrie,setRows],
|
[rows, setFieldValue, setRows],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -71,11 +71,7 @@ function PaymentReceives({
|
|||||||
}, [history]);
|
}, [history]);
|
||||||
|
|
||||||
const handleCustomerChange = (customerId) => {
|
const handleCustomerChange = (customerId) => {
|
||||||
if (id) {
|
|
||||||
setCustomerId(!customerId);
|
|
||||||
} else {
|
|
||||||
setCustomerId(customerId);
|
setCustomerId(customerId);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -91,7 +87,6 @@ function PaymentReceives({
|
|||||||
<PaymentReceiveForm
|
<PaymentReceiveForm
|
||||||
onFormSubmit={handleFormSubmit}
|
onFormSubmit={handleFormSubmit}
|
||||||
paymentReceiveId={id}
|
paymentReceiveId={id}
|
||||||
paymentReceiveInvoices={id}
|
|
||||||
onCancelForm={handleCancel}
|
onCancelForm={handleCancel}
|
||||||
onCustomerChange={handleCustomerChange}
|
onCustomerChange={handleCustomerChange}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ export default {
|
|||||||
new_currency: 'New Currency',
|
new_currency: 'New Currency',
|
||||||
currency_name: 'Currency Name',
|
currency_name: 'Currency Name',
|
||||||
currency_code: 'Currency Code',
|
currency_code: 'Currency Code',
|
||||||
|
select_currency_code: 'select Currency Code',
|
||||||
edit_exchange_rate: 'Edit Exchange Rate',
|
edit_exchange_rate: 'Edit Exchange Rate',
|
||||||
new_exchange_rate: 'New Exchange Rate',
|
new_exchange_rate: 'New Exchange Rate',
|
||||||
delete_exchange_rate: 'Delete Exchange Rate',
|
delete_exchange_rate: 'Delete Exchange Rate',
|
||||||
@@ -714,4 +715,5 @@ export default {
|
|||||||
sell_account: 'Sell Account',
|
sell_account: 'Sell Account',
|
||||||
cost_account: 'Cost Account',
|
cost_account: 'Cost Account',
|
||||||
inventory_account: 'Inventory Account',
|
inventory_account: 'Inventory Account',
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export const fetchExchangeRates = () => {
|
|||||||
});
|
});
|
||||||
ApiService.get('exchange_rates')
|
ApiService.get('exchange_rates')
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: t.EXCHANGE_RATE_LIST_SET,
|
type: t.EXCHANGE_RATE_LIST_SET,
|
||||||
exchange_rates: response.data.exchange_rates.results,
|
exchange_rates: response.data.exchange_rates.results,
|
||||||
@@ -35,20 +36,18 @@ export const fetchExchangeRates = () => {
|
|||||||
export const submitExchangeRate = ({ form }) => {
|
export const submitExchangeRate = ({ form }) => {
|
||||||
return (dispatch) =>
|
return (dispatch) =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
ApiService.post('exchange_rates', form).then((response) => {
|
ApiService.post('exchange_rates', form)
|
||||||
|
.then((response) => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
}).catch((error)=>{
|
|
||||||
const {response} = error
|
|
||||||
const {data} = response;
|
|
||||||
reject(data?.errors)
|
|
||||||
})
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
const { response } = error;
|
||||||
|
const { data } = response;
|
||||||
|
reject(data?.errors);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// export const deleteExchangeRate = (id) => {
|
|
||||||
// return (dispatch) => ApiService.delete(`exchange_rates/${id}`);
|
|
||||||
// }
|
|
||||||
|
|
||||||
export const deleteExchangeRate = (id) => {
|
export const deleteExchangeRate = (id) => {
|
||||||
return (dispatch) =>
|
return (dispatch) =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import { pickItemsFromIds, getItemById } from 'store/selectors';
|
||||||
|
|
||||||
const exchangeRateItemsSelector = state => state.exchangeRates.exchangeRates;
|
const exchangeRateItemsSelector = (state) => state.exchangeRates.exchangeRates;
|
||||||
|
const exchangeRateIdPropSelector = (state, props) => props.exchangeRateId;
|
||||||
|
|
||||||
export const getExchangeRatesList = createSelector(
|
export const getExchangeRatesList = createSelector(
|
||||||
exchangeRateItemsSelector,
|
exchangeRateItemsSelector,
|
||||||
(exchangeRateItems) => {
|
(exchangeRateItems) => {
|
||||||
return Object.values(exchangeRateItems);
|
return Object.values(exchangeRateItems);
|
||||||
},
|
},
|
||||||
)
|
);
|
||||||
|
|
||||||
|
export const getExchangeRateById = createSelector(
|
||||||
|
exchangeRateItemsSelector,
|
||||||
|
exchangeRateIdPropSelector,
|
||||||
|
(exchangeRates, exchangeRateId) => {
|
||||||
|
return getItemById(exchangeRates, exchangeRateId);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ export const submitItemCategory = ({ form }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const fetchItemCategories = ({ query }) => {
|
export const fetchItemCategories = ({ query }) => {
|
||||||
return (dispatch, getState) => new Promise((resolve, reject) => {
|
return (dispatch, getState) =>
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||||
});
|
});
|
||||||
@@ -16,7 +17,7 @@ export const fetchItemCategories = ({ query }) => {
|
|||||||
type: t.ITEM_CATEGORIES_TABLE_LOADING,
|
type: t.ITEM_CATEGORIES_TABLE_LOADING,
|
||||||
payload: {
|
payload: {
|
||||||
loading: true,
|
loading: true,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
ApiService.get('item_categories', { params: { ...query } })
|
ApiService.get('item_categories', { params: { ...query } })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
@@ -31,7 +32,7 @@ export const fetchItemCategories = ({ query }) => {
|
|||||||
type: t.ITEM_CATEGORIES_TABLE_LOADING,
|
type: t.ITEM_CATEGORIES_TABLE_LOADING,
|
||||||
payload: {
|
payload: {
|
||||||
loading: false,
|
loading: false,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
@@ -46,19 +47,13 @@ export const editItemCategory = (id, form) => {
|
|||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
ApiService.post(`item_categories/${id}`, form)
|
ApiService.post(`item_categories/${id}`, form)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
dispatch({ type: t.CLEAR_CATEGORY_FORM_ERRORS });
|
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
const { response } = error;
|
const { response } = error;
|
||||||
const { data } = response;
|
const { data } = response;
|
||||||
const { errors } = data;
|
|
||||||
|
|
||||||
dispatch({ type: t.CLEAR_CATEGORY_FORM_ERRORS });
|
reject(data?.errors);
|
||||||
if (errors) {
|
|
||||||
dispatch({ type: t.CLEAR_CATEGORY_FORM_ERRORS, errors });
|
|
||||||
}
|
|
||||||
reject(error);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -81,14 +76,17 @@ export const deleteItemCategory = (id) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const deleteBulkItemCategories = ({ ids }) => {
|
export const deleteBulkItemCategories = ({ ids }) => {
|
||||||
return dispatch => new Promise((resolve, reject) => {
|
return (dispatch) =>
|
||||||
ApiService.delete(`item_categories/bulk`, { params: { ids }}).then((response) => {
|
new Promise((resolve, reject) => {
|
||||||
|
ApiService.delete(`item_categories/bulk`, { params: { ids } })
|
||||||
|
.then((response) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: t.ITEM_CATEGORIES_BULK_DELETE,
|
type: t.ITEM_CATEGORIES_BULK_DELETE,
|
||||||
payload: { ids }
|
payload: { ids },
|
||||||
});
|
});
|
||||||
resolve(response);
|
resolve(response);
|
||||||
}).catch((error) => {
|
})
|
||||||
|
.catch((error) => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user