mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
feat: add project to journal
This commit is contained in:
@@ -32,6 +32,7 @@ const Schema = Yup.object().shape({
|
|||||||
}),
|
}),
|
||||||
contact_id: Yup.number().nullable(),
|
contact_id: Yup.number().nullable(),
|
||||||
contact_type: Yup.string().nullable(),
|
contact_type: Yup.string().nullable(),
|
||||||
|
project_id: Yup.number().nullable(),
|
||||||
note: Yup.string().max(DATATYPES_LENGTH.TEXT).nullable(),
|
note: Yup.string().max(DATATYPES_LENGTH.TEXT).nullable(),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import React from 'react';
|
|||||||
import { FastField } from 'formik';
|
import { FastField } from 'formik';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { CLASSES } from '@/constants/classes';
|
||||||
import { entriesFieldShouldUpdate, defaultEntry, MIN_LINES_NUMBER } from './utils';
|
import {
|
||||||
|
entriesFieldShouldUpdate,
|
||||||
|
defaultEntry,
|
||||||
|
MIN_LINES_NUMBER,
|
||||||
|
} from './utils';
|
||||||
import { useMakeJournalFormContext } from './MakeJournalProvider';
|
import { useMakeJournalFormContext } from './MakeJournalProvider';
|
||||||
import MakeJournalEntriesTable from './MakeJournalEntriesTable';
|
import MakeJournalEntriesTable from './MakeJournalEntriesTable';
|
||||||
|
|
||||||
@@ -10,7 +14,8 @@ import MakeJournalEntriesTable from './MakeJournalEntriesTable';
|
|||||||
* Make journal entries field.
|
* Make journal entries field.
|
||||||
*/
|
*/
|
||||||
export default function MakeJournalEntriesField() {
|
export default function MakeJournalEntriesField() {
|
||||||
const { accounts, contacts ,branches } = useMakeJournalFormContext();
|
const { accounts, contacts, branches, projects } =
|
||||||
|
useMakeJournalFormContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
|
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
|
||||||
@@ -19,6 +24,7 @@ export default function MakeJournalEntriesField() {
|
|||||||
contacts={contacts}
|
contacts={contacts}
|
||||||
accounts={accounts}
|
accounts={accounts}
|
||||||
branches={branches}
|
branches={branches}
|
||||||
|
projects={projects}
|
||||||
shouldUpdate={entriesFieldShouldUpdate}
|
shouldUpdate={entriesFieldShouldUpdate}
|
||||||
>
|
>
|
||||||
{({
|
{({
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ export default function MakeJournalEntriesTable({
|
|||||||
minLinesNumber = 1,
|
minLinesNumber = 1,
|
||||||
currencyCode,
|
currencyCode,
|
||||||
}) {
|
}) {
|
||||||
const { accounts, contacts, branches } = useMakeJournalFormContext();
|
const { accounts, contacts, branches, projects } =
|
||||||
|
useMakeJournalFormContext();
|
||||||
|
|
||||||
// Memorized data table columns.
|
// Memorized data table columns.
|
||||||
const columns = useJournalTableEntriesColumns();
|
const columns = useJournalTableEntriesColumns();
|
||||||
@@ -69,6 +70,7 @@ export default function MakeJournalEntriesTable({
|
|||||||
removeRow: handleRemoveRow,
|
removeRow: handleRemoveRow,
|
||||||
contacts,
|
contacts,
|
||||||
branches,
|
branches,
|
||||||
|
projects,
|
||||||
autoFocus: ['account_id', 0],
|
autoFocus: ['account_id', 0],
|
||||||
currencyCode,
|
currencyCode,
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
useBranches,
|
useBranches,
|
||||||
useSettingsManualJournals,
|
useSettingsManualJournals,
|
||||||
} from '@/hooks/query';
|
} from '@/hooks/query';
|
||||||
|
import { useProjects } from '@/containers/Projects/hooks';
|
||||||
|
|
||||||
const MakeJournalFormContext = createContext();
|
const MakeJournalFormContext = createContext();
|
||||||
|
|
||||||
@@ -54,6 +55,12 @@ function MakeJournalProvider({ journalId, query, ...props }) {
|
|||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches(query, { enabled: isBranchFeatureCan });
|
} = useBranches(query, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
|
// Fetch the projects list.
|
||||||
|
const {
|
||||||
|
data: { projects },
|
||||||
|
isLoading: isProjectsLoading,
|
||||||
|
} = useProjects();
|
||||||
|
|
||||||
// Submit form payload.
|
// Submit form payload.
|
||||||
const [submitPayload, setSubmitPayload] = useState({});
|
const [submitPayload, setSubmitPayload] = useState({});
|
||||||
|
|
||||||
@@ -65,7 +72,7 @@ function MakeJournalProvider({ journalId, query, ...props }) {
|
|||||||
contacts,
|
contacts,
|
||||||
currencies,
|
currencies,
|
||||||
manualJournal,
|
manualJournal,
|
||||||
|
projects,
|
||||||
branches,
|
branches,
|
||||||
|
|
||||||
createJournalMutate,
|
createJournalMutate,
|
||||||
@@ -91,7 +98,8 @@ function MakeJournalProvider({ journalId, query, ...props }) {
|
|||||||
isAccountsLoading ||
|
isAccountsLoading ||
|
||||||
isCurrenciesLoading ||
|
isCurrenciesLoading ||
|
||||||
isContactsLoading ||
|
isContactsLoading ||
|
||||||
isSettingsLoading
|
isSettingsLoading ||
|
||||||
|
isProjectsLoading
|
||||||
}
|
}
|
||||||
name={'make-journal-page'}
|
name={'make-journal-page'}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
InputGroupCell,
|
InputGroupCell,
|
||||||
ContactsListFieldCell,
|
ContactsListFieldCell,
|
||||||
BranchesListFieldCell,
|
BranchesListFieldCell,
|
||||||
|
ProjectsListFieldCell,
|
||||||
} from '@/components/DataTableCells';
|
} from '@/components/DataTableCells';
|
||||||
|
|
||||||
import { CellType, Features, Align } from '@/constants';
|
import { CellType, Features, Align } from '@/constants';
|
||||||
@@ -127,6 +128,21 @@ export const useJournalTableEntriesColumns = () => {
|
|||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
width: 120,
|
width: 120,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
...(featureCan(Features.Branches)
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
Header: intl.get('project'),
|
||||||
|
id: 'project_id',
|
||||||
|
accessor: 'project_id',
|
||||||
|
Cell: ProjectsListFieldCell,
|
||||||
|
className: 'project_id',
|
||||||
|
disableSortBy: true,
|
||||||
|
width: 120,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
|
||||||
...(featureCan(Features.Branches)
|
...(featureCan(Features.Branches)
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export const defaultEntry = {
|
|||||||
debit: '',
|
debit: '',
|
||||||
contact_id: '',
|
contact_id: '',
|
||||||
branch_id: '',
|
branch_id: '',
|
||||||
|
project_id: '',
|
||||||
note: '',
|
note: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user