mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -126,6 +126,7 @@ function MakeJournalEntriesForm({
|
||||
date: Yup.date()
|
||||
.required()
|
||||
.label(formatMessage({ id: 'date' })),
|
||||
currency_code: Yup.string(),
|
||||
reference: Yup.string().min(1).max(255),
|
||||
description: Yup.string().min(1).max(1024),
|
||||
entries: Yup.array().of(
|
||||
@@ -172,6 +173,7 @@ function MakeJournalEntriesForm({
|
||||
date: moment(new Date()).format('YYYY-MM-DD'),
|
||||
description: '',
|
||||
reference: '',
|
||||
currency_code: '',
|
||||
entries: [...repeatValue(defaultEntry, 4)],
|
||||
}),
|
||||
[defaultEntry, journalNumber],
|
||||
@@ -442,11 +444,12 @@ function MakeJournalEntriesForm({
|
||||
},
|
||||
[changePageSubtitle],
|
||||
);
|
||||
|
||||
console.log(values, 'Val');
|
||||
return (
|
||||
<div class="make-journal-entries">
|
||||
<form onSubmit={handleSubmit}>
|
||||
<MakeJournalEntriesHeader
|
||||
manualJournal={manualJournalId}
|
||||
errors={errors}
|
||||
touched={touched}
|
||||
values={values}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useMemo, useCallback } from 'react';
|
||||
import React, { useMemo, useState, useCallback } from 'react';
|
||||
import {
|
||||
InputGroup,
|
||||
FormGroup,
|
||||
@@ -15,16 +15,18 @@ import classNames from 'classnames';
|
||||
import { CLASSES } from 'common/classes';
|
||||
import { momentFormatter, tansformDateValue, saveInvoke } from 'utils';
|
||||
import {
|
||||
CurrenciesSelectList,
|
||||
ErrorMessage,
|
||||
Hint,
|
||||
FieldHint,
|
||||
FieldRequiredHint,
|
||||
Icon,
|
||||
InputPrependButton,
|
||||
CurrencySelectList,
|
||||
} from 'components';
|
||||
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withCurrencies from 'containers/Currencies/withCurrencies';
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
@@ -36,11 +38,20 @@ function MakeJournalEntriesHeader({
|
||||
getFieldProps,
|
||||
|
||||
// #ownProps
|
||||
manualJournal,
|
||||
onJournalNumberChanged,
|
||||
|
||||
// #withSettings
|
||||
baseCurrency,
|
||||
|
||||
// #withCurrencies
|
||||
currenciesList,
|
||||
|
||||
// #withDialog
|
||||
openDialog,
|
||||
}) {
|
||||
const [selectedItems, setSelectedItems] = useState({});
|
||||
|
||||
const handleDateChange = useCallback(
|
||||
(date) => {
|
||||
const formatted = moment(date).format('YYYY-MM-DD');
|
||||
@@ -57,6 +68,19 @@ function MakeJournalEntriesHeader({
|
||||
saveInvoke(onJournalNumberChanged, event.currentTarget.value);
|
||||
};
|
||||
|
||||
const onItemsSelect = useCallback(
|
||||
(filedName) => {
|
||||
return (filed) => {
|
||||
setSelectedItems({
|
||||
...selectedItems,
|
||||
[filedName]: filed,
|
||||
});
|
||||
setFieldValue(filedName, filed.currency_code);
|
||||
};
|
||||
},
|
||||
[setFieldValue, selectedItems],
|
||||
);
|
||||
|
||||
return (
|
||||
<div class="make-journal-entries__header">
|
||||
<Row>
|
||||
@@ -197,7 +221,12 @@ function MakeJournalEntriesHeader({
|
||||
CLASSES.FILL,
|
||||
)}
|
||||
>
|
||||
<CurrenciesSelectList />
|
||||
<CurrencySelectList
|
||||
currenciesList={currenciesList}
|
||||
selectedCurrencyCode={values.currency_code}
|
||||
onCurrencySelected={onItemsSelect('currency_code')}
|
||||
defaultSelectText={baseCurrency}
|
||||
/>
|
||||
</FormGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
@@ -205,4 +234,12 @@ function MakeJournalEntriesHeader({
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogActions)(MakeJournalEntriesHeader);
|
||||
export default compose(
|
||||
withDialogActions,
|
||||
withSettings(({ organizationSettings }) => ({
|
||||
baseCurrency: organizationSettings?.baseCurrency,
|
||||
})),
|
||||
withCurrencies(({ currenciesList }) => ({
|
||||
currenciesList,
|
||||
})),
|
||||
)(MakeJournalEntriesHeader);
|
||||
|
||||
@@ -8,6 +8,7 @@ import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||
import withCustomersActions from 'containers/Customers/withCustomersActions';
|
||||
import withAccountsActions from 'containers/Accounts/withAccountsActions';
|
||||
import withManualJournalsActions from 'containers/Accounting/withManualJournalsActions';
|
||||
import withCurrenciesActions from 'containers/Currencies/withCurrenciesActions';
|
||||
import withSettingsActions from 'containers/Settings/withSettingsActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
@@ -22,6 +23,9 @@ function MakeJournalEntriesPage({
|
||||
// #withManualJournalActions
|
||||
requestFetchManualJournal,
|
||||
|
||||
// #wihtCurrenciesActions
|
||||
requestFetchCurrencies,
|
||||
|
||||
// #withSettingsActions
|
||||
requestFetchOptions,
|
||||
}) {
|
||||
@@ -36,11 +40,12 @@ function MakeJournalEntriesPage({
|
||||
requestFetchCustomers(),
|
||||
);
|
||||
|
||||
const fetchSettings = useQuery(
|
||||
['settings'],
|
||||
() => requestFetchOptions({}),
|
||||
const fetchCurrencies = useQuery('currencies', () =>
|
||||
requestFetchCurrencies(),
|
||||
);
|
||||
|
||||
const fetchSettings = useQuery(['settings'], () => requestFetchOptions({}));
|
||||
|
||||
const fetchJournal = useQuery(
|
||||
['manual-journal', id],
|
||||
(key, journalId) => requestFetchManualJournal(journalId),
|
||||
@@ -63,6 +68,7 @@ function MakeJournalEntriesPage({
|
||||
loading={
|
||||
fetchJournal.isFetching ||
|
||||
fetchAccounts.isFetching ||
|
||||
fetchCurrencies.isFetching ||
|
||||
fetchCustomers.isFetching
|
||||
}
|
||||
name={'make-journal-page'}
|
||||
@@ -80,5 +86,6 @@ export default compose(
|
||||
withAccountsActions,
|
||||
withCustomersActions,
|
||||
withManualJournalsActions,
|
||||
withSettingsActions
|
||||
withCurrenciesActions,
|
||||
withSettingsActions,
|
||||
)(MakeJournalEntriesPage);
|
||||
|
||||
@@ -68,7 +68,7 @@ function AccountFormDialogContent({
|
||||
.max(255)
|
||||
.label(formatMessage({ id: 'account_name_' })),
|
||||
code: Yup.string().digits().min(3).max(6),
|
||||
account_type_id: Yup.number()
|
||||
account_type_id: Yup.number().nullable()
|
||||
.required()
|
||||
.label(formatMessage({ id: 'account_type_id' })),
|
||||
description: Yup.string().min(3).max(512).nullable().trim(),
|
||||
@@ -76,7 +76,7 @@ function AccountFormDialogContent({
|
||||
});
|
||||
const initialValues = useMemo(
|
||||
() => ({
|
||||
account_type_id: null,
|
||||
account_type_id: '',
|
||||
name: '',
|
||||
code: '',
|
||||
description: '',
|
||||
|
||||
@@ -24,6 +24,7 @@ export default function ItemCategoryForm({
|
||||
accountsList,
|
||||
categoriesList,
|
||||
isSubmitting,
|
||||
onClose,
|
||||
}) {
|
||||
// Filters Item Categories list.
|
||||
const filterItemCategories = useCallback(
|
||||
@@ -73,7 +74,7 @@ export default function ItemCategoryForm({
|
||||
</FastField>
|
||||
|
||||
{/* ----------- Parent Category ----------- */}
|
||||
<FastField name={'parent_account_id'}>
|
||||
<FastField name={'parent_category_id'}>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={<T id={'parent_category'} />}
|
||||
@@ -106,7 +107,7 @@ export default function ItemCategoryForm({
|
||||
</FastField>
|
||||
|
||||
{/* ----------- Description ----------- */}
|
||||
<FastField name={'description`'}>
|
||||
<FastField name={'description'}>
|
||||
{({ field, field: { value }, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={<T id={'description'} />}
|
||||
@@ -137,7 +138,7 @@ export default function ItemCategoryForm({
|
||||
<AccountsSelectList
|
||||
accounts={accountsList}
|
||||
onAccountSelected={(account) => {
|
||||
form.setFieldValue(account.id);
|
||||
form.setFieldValue('cost_account_id', account.id);
|
||||
}}
|
||||
defaultSelectText={<T id={'select_account'} />}
|
||||
selectedAccountId={value}
|
||||
@@ -203,7 +204,7 @@ export default function ItemCategoryForm({
|
||||
|
||||
<div className={Classes.DIALOG_FOOTER}>
|
||||
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||
<Button>
|
||||
<Button onClick={onClose}>
|
||||
<T id={'close'} />
|
||||
</Button>
|
||||
<Button intent={Intent.PRIMARY} type="submit" disabled={isSubmitting}>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useMemo, useCallback } from 'react';
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import * as Yup from 'yup';
|
||||
import { useQuery, queryCache } from 'react-query';
|
||||
@@ -121,6 +121,11 @@ function ItemCategoryFormDialogContent({
|
||||
}
|
||||
};
|
||||
|
||||
// Handles dialog close.
|
||||
const handleClose = useCallback(() => {
|
||||
closeDialog(dialogName);
|
||||
}, [closeDialog, dialogName]);
|
||||
|
||||
return (
|
||||
<DialogContent
|
||||
isLoading={fetchCategoriesList.isFetching || fetchAccountsList.isFetching}
|
||||
@@ -136,6 +141,7 @@ function ItemCategoryFormDialogContent({
|
||||
accountsList={accountsList}
|
||||
categoriesList={categoriesList}
|
||||
isSubmitting={isSubmitting}
|
||||
onClose={handleClose}
|
||||
/>
|
||||
)}
|
||||
</Formik>
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from 'react-intl';
|
||||
|
||||
import AppToaster from 'components/AppToaster';
|
||||
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||
import ItemCategoriesDataTable from 'containers/Items/ItemCategoriesTable';
|
||||
import ItemsCategoryActionsBar from 'containers/Items/ItemsCategoryActionsBar';
|
||||
@@ -156,7 +157,7 @@ const ItemCategoryList = ({
|
||||
|
||||
return (
|
||||
<DashboardInsider
|
||||
loading={fetchResourceFields.isFetching}
|
||||
loading={fetchResourceFields.isFetching || fetchCategories.isFetching}
|
||||
name={'item-category-list'}
|
||||
>
|
||||
<ItemsCategoryActionsBar
|
||||
@@ -164,50 +165,50 @@ const ItemCategoryList = ({
|
||||
onFilterChanged={handleFilterChanged}
|
||||
onBulkDelete={handleBulkDelete}
|
||||
/>
|
||||
<DashboardPageContent>
|
||||
<ItemCategoriesDataTable
|
||||
onEditCategory={handleEditCategory}
|
||||
onFetchData={handleFetchData}
|
||||
onSelectedRowsChange={handleSelectedRowsChange}
|
||||
onDeleteCategory={handleDeleteCategory}
|
||||
/>
|
||||
|
||||
<ItemCategoriesDataTable
|
||||
onEditCategory={handleEditCategory}
|
||||
onFetchData={handleFetchData}
|
||||
onSelectedRowsChange={handleSelectedRowsChange}
|
||||
onDeleteCategory={handleDeleteCategory}
|
||||
loading={fetchCategories.isFetching}
|
||||
/>
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'delete'} />}
|
||||
icon="trash"
|
||||
intent={Intent.DANGER}
|
||||
isOpen={deleteCategory}
|
||||
onCancel={handleCancelItemDelete}
|
||||
onConfirm={handleConfirmItemDelete}
|
||||
>
|
||||
<p>
|
||||
<FormattedHTMLMessage
|
||||
id={'once_delete_this_item_category_you_will_able_to_restore_it'}
|
||||
/>
|
||||
</p>
|
||||
</Alert>
|
||||
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'delete'} />}
|
||||
icon="trash"
|
||||
intent={Intent.DANGER}
|
||||
isOpen={deleteCategory}
|
||||
onCancel={handleCancelItemDelete}
|
||||
onConfirm={handleConfirmItemDelete}
|
||||
>
|
||||
<p>
|
||||
<FormattedHTMLMessage
|
||||
id={'once_delete_this_item_category_you_will_able_to_restore_it'}
|
||||
/>
|
||||
</p>
|
||||
</Alert>
|
||||
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={`${formatMessage({
|
||||
id: 'delete',
|
||||
})} (${selectedRowsCount})`}
|
||||
icon="trash"
|
||||
intent={Intent.DANGER}
|
||||
isOpen={bulkDelete}
|
||||
onCancel={handleCancelBulkDelete}
|
||||
onConfirm={handleConfirmBulkDelete}
|
||||
>
|
||||
<p>
|
||||
<FormattedHTMLMessage
|
||||
id={
|
||||
'once_delete_these_item_categories_you_will_not_able_restore_them'
|
||||
}
|
||||
/>
|
||||
</p>
|
||||
</Alert>
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={`${formatMessage({
|
||||
id: 'delete',
|
||||
})} (${selectedRowsCount})`}
|
||||
icon="trash"
|
||||
intent={Intent.DANGER}
|
||||
isOpen={bulkDelete}
|
||||
onCancel={handleCancelBulkDelete}
|
||||
onConfirm={handleConfirmBulkDelete}
|
||||
>
|
||||
<p>
|
||||
<FormattedHTMLMessage
|
||||
id={
|
||||
'once_delete_these_item_categories_you_will_not_able_restore_them'
|
||||
}
|
||||
/>
|
||||
</p>
|
||||
</Alert>
|
||||
</DashboardPageContent>
|
||||
</DashboardInsider>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@ import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
const ItemsCategoryList = ({
|
||||
// #withItemCategories
|
||||
categoriesList,
|
||||
categoriesTableLoading,
|
||||
|
||||
// #withDialogActions.
|
||||
openDialog,
|
||||
@@ -72,21 +73,21 @@ const ItemsCategoryList = ({
|
||||
id: 'name',
|
||||
Header: formatMessage({ id: 'category_name' }),
|
||||
accessor: 'name',
|
||||
width: 150,
|
||||
width: 220,
|
||||
},
|
||||
{
|
||||
id: 'description',
|
||||
Header: formatMessage({ id: 'description' }),
|
||||
accessor: 'description',
|
||||
className: 'description',
|
||||
width: 150,
|
||||
width: 220,
|
||||
},
|
||||
{
|
||||
id: 'count',
|
||||
Header: formatMessage({ id: 'count' }),
|
||||
accessor: 'count',
|
||||
className: 'count',
|
||||
width: 50,
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
@@ -94,14 +95,13 @@ const ItemsCategoryList = ({
|
||||
Cell: ({ cell }) => (
|
||||
<Popover
|
||||
content={actionMenuList(cell.row.original)}
|
||||
position={Position.RIGHT_BOTTOM}
|
||||
position={Position.RIGHT_TOP}
|
||||
>
|
||||
<Button icon={<Icon icon="more-h-16" iconSize={16} />} />
|
||||
</Popover>
|
||||
),
|
||||
className: 'actions',
|
||||
width: 50,
|
||||
disableResizing: false,
|
||||
},
|
||||
],
|
||||
[actionMenuList, formatMessage],
|
||||
@@ -148,9 +148,9 @@ const ItemsCategoryList = ({
|
||||
manualSortBy={true}
|
||||
selectionColumn={selectionColumn}
|
||||
expandable={true}
|
||||
sticky={true}
|
||||
onSelectedRowsChange={handleSelectedRowsChange}
|
||||
treeGraph={true}
|
||||
spinnerProps={{ size: 30 }}
|
||||
loading={categoriesTableLoading}
|
||||
rowContextMenu={handleRowContextMenu}
|
||||
/>
|
||||
</LoadingIndicator>
|
||||
@@ -158,8 +158,9 @@ const ItemsCategoryList = ({
|
||||
};
|
||||
|
||||
export default compose(
|
||||
withItemCategories(({ categoriesList }) => ({
|
||||
withItemCategories(({ categoriesList, categoriesTableLoading }) => ({
|
||||
categoriesList,
|
||||
categoriesTableLoading,
|
||||
})),
|
||||
withDialogActions,
|
||||
)(ItemsCategoryList);
|
||||
|
||||
@@ -89,12 +89,14 @@ function ItemForm({
|
||||
sku: Yup.string().trim(),
|
||||
cost_price: Yup.number().when(['purchasable'], {
|
||||
is: true,
|
||||
then: Yup.number().required(),
|
||||
then: Yup.number().required()
|
||||
.label(formatMessage({ id: 'cost_price_' })),
|
||||
otherwise: Yup.number().nullable(true),
|
||||
}),
|
||||
sell_price: Yup.number().when(['sellable'], {
|
||||
is: true,
|
||||
then: Yup.number().required(),
|
||||
then: Yup.number().required()
|
||||
.label(formatMessage({ id: 'sell_price_' })),
|
||||
otherwise: Yup.number().nullable(true),
|
||||
}),
|
||||
cost_account_id: Yup.number()
|
||||
|
||||
@@ -54,7 +54,7 @@ export default function ItemFormFloatingActions({
|
||||
</Button>
|
||||
|
||||
{/*----------- Active ----------*/}
|
||||
<FastField name={'type'}>
|
||||
<FastField name={'active'}>
|
||||
{({ field, field: { value } }) => (
|
||||
<FormGroup label={' '} inline={true} className={'form-group--active'}>
|
||||
<Checkbox
|
||||
|
||||
@@ -34,7 +34,7 @@ function ItemFormPrimarySection({
|
||||
categoriesList,
|
||||
|
||||
// #withDashboardActions
|
||||
changePageSubtitle
|
||||
changePageSubtitle,
|
||||
}) {
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
@@ -88,13 +88,14 @@ function ItemFormPrimarySection({
|
||||
changePageSubtitle(formatMessage({ id: _value }));
|
||||
})}
|
||||
selectedValue={value}
|
||||
disabled={value === 'inventory'}
|
||||
>
|
||||
<Radio label={<T id={'service'} />} value="service" />
|
||||
<Radio label={<T id={'inventory'} />} value="inventory" />
|
||||
<Radio
|
||||
label={<T id={'non_inventory'} />}
|
||||
value="non-inventory"
|
||||
/>
|
||||
<Radio label={<T id={'inventory'} />} value="inventory" />
|
||||
</RadioGroup>
|
||||
</FormGroup>
|
||||
)}
|
||||
@@ -179,5 +180,5 @@ export default compose(
|
||||
withItemCategories(({ categoriesList }) => ({
|
||||
categoriesList,
|
||||
})),
|
||||
withDashboardActions
|
||||
withDashboardActions,
|
||||
)(ItemFormPrimarySection);
|
||||
|
||||
@@ -12,7 +12,6 @@ const BillFormSchema = Yup.object().shape({
|
||||
.required()
|
||||
.label(formatMessage({ id: 'due_date_' })),
|
||||
bill_number: Yup.string()
|
||||
.required()
|
||||
.label(formatMessage({ id: 'bill_number_' })),
|
||||
reference_no: Yup.string().nullable().min(1).max(255),
|
||||
note: Yup.string()
|
||||
|
||||
@@ -12,10 +12,9 @@ const Schema = Yup.object().shape({
|
||||
.required()
|
||||
.label(formatMessage({ id: 'expiration_date_' })),
|
||||
estimate_number: Yup.string()
|
||||
.required()
|
||||
.nullable()
|
||||
.label(formatMessage({ id: 'estimate_number_' })),
|
||||
reference: Yup.string().min(1).max(255),
|
||||
reference: Yup.string().min(1).max(255).nullable(),
|
||||
note: Yup.string()
|
||||
.trim()
|
||||
.min(1)
|
||||
|
||||
@@ -11,7 +11,8 @@ const Schema = Yup.object().shape({
|
||||
due_date: Yup.date()
|
||||
.required()
|
||||
.label(formatMessage({ id: 'due_date_' })),
|
||||
invoice_no: Yup.string().label(formatMessage({ id: 'invoice_no_' })),
|
||||
invoice_no: Yup.string()
|
||||
.label(formatMessage({ id: 'invoice_no_' })),
|
||||
reference_no: Yup.string().min(1).max(255),
|
||||
status: Yup.string().required(),
|
||||
invoice_message: Yup.string()
|
||||
|
||||
@@ -9,7 +9,6 @@ const Schema = Yup.object().shape({
|
||||
.required()
|
||||
.label(formatMessage({ id: 'receipt_date_' })),
|
||||
receipt_number: Yup.string()
|
||||
.required()
|
||||
.label(formatMessage({ id: 'receipt_no_' })),
|
||||
deposit_account_id: Yup.number()
|
||||
.required()
|
||||
|
||||
Reference in New Issue
Block a user