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