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