mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
Fix: Estimate &MakeJournal DataTypes.
This commit is contained in:
@@ -17,6 +17,11 @@ import MakeJournalEntriesHeader from './MakeJournalEntriesHeader';
|
|||||||
import MakeJournalEntriesFooter from './MakeJournalEntriesFooter';
|
import MakeJournalEntriesFooter from './MakeJournalEntriesFooter';
|
||||||
import MakeJournalEntriesTable from './MakeJournalEntriesTable';
|
import MakeJournalEntriesTable from './MakeJournalEntriesTable';
|
||||||
|
|
||||||
|
import {
|
||||||
|
CreateMakeJournalFormSchema,
|
||||||
|
EditMakeJournalFormSchema,
|
||||||
|
} from './MakeJournalEntriesForm.schema';
|
||||||
|
|
||||||
import withJournalsActions from 'containers/Accounting/withJournalsActions';
|
import withJournalsActions from 'containers/Accounting/withJournalsActions';
|
||||||
import withManualJournalDetail from 'containers/Accounting/withManualJournalDetail';
|
import withManualJournalDetail from 'containers/Accounting/withManualJournalDetail';
|
||||||
import withAccountsActions from 'containers/Accounts/withAccountsActions';
|
import withAccountsActions from 'containers/Accounts/withAccountsActions';
|
||||||
@@ -77,6 +82,7 @@ function MakeJournalEntriesForm({
|
|||||||
onFormSubmit,
|
onFormSubmit,
|
||||||
onCancelForm,
|
onCancelForm,
|
||||||
}) {
|
}) {
|
||||||
|
const isNewMode = !manualJournalId;
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [submitPayload, setSubmitPayload] = useState({});
|
const [submitPayload, setSubmitPayload] = useState({});
|
||||||
@@ -126,39 +132,9 @@ function MakeJournalEntriesForm({
|
|||||||
formatMessage,
|
formatMessage,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = isNewMode
|
||||||
journal_number: Yup.string()
|
? CreateMakeJournalFormSchema
|
||||||
.required()
|
: EditMakeJournalFormSchema;
|
||||||
.min(1)
|
|
||||||
.max(255)
|
|
||||||
.label(formatMessage({ id: 'journal_number_' })),
|
|
||||||
journal_type: Yup.string()
|
|
||||||
.required()
|
|
||||||
.min(1)
|
|
||||||
.max(255)
|
|
||||||
.label(formatMessage({ id: 'journal_type' })),
|
|
||||||
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(
|
|
||||||
Yup.object().shape({
|
|
||||||
credit: Yup.number().decimalScale(13).nullable(),
|
|
||||||
debit: Yup.number().decimalScale(13).nullable(),
|
|
||||||
account_id: Yup.number()
|
|
||||||
.nullable()
|
|
||||||
.when(['credit', 'debit'], {
|
|
||||||
is: (credit, debit) => credit || debit,
|
|
||||||
then: Yup.number().required(),
|
|
||||||
}),
|
|
||||||
contact_id: Yup.number().nullable(),
|
|
||||||
contact_type: Yup.string().nullable(),
|
|
||||||
note: Yup.string().max(255).nullable(),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
const saveInvokeSubmit = useCallback(
|
const saveInvokeSubmit = useCallback(
|
||||||
(payload) => {
|
(payload) => {
|
||||||
@@ -185,7 +161,7 @@ function MakeJournalEntriesForm({
|
|||||||
date: moment(new Date()).format('YYYY-MM-DD'),
|
date: moment(new Date()).format('YYYY-MM-DD'),
|
||||||
description: '',
|
description: '',
|
||||||
reference: '',
|
reference: '',
|
||||||
status:'',
|
status: '',
|
||||||
currency_code: '',
|
currency_code: '',
|
||||||
entries: [...repeatValue(defaultEntry, 4)],
|
entries: [...repeatValue(defaultEntry, 4)],
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { DATATYPES_LENGTH } from 'common/dataTypes';
|
|||||||
|
|
||||||
const Schema = Yup.object().shape({
|
const Schema = Yup.object().shape({
|
||||||
journal_number: Yup.string()
|
journal_number: Yup.string()
|
||||||
.required()
|
// .required()
|
||||||
.min(1)
|
.min(1)
|
||||||
.max(DATATYPES_LENGTH.STRING)
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(formatMessage({ id: 'journal_number_' })),
|
.label(formatMessage({ id: 'journal_number_' })),
|
||||||
@@ -17,8 +17,9 @@ const Schema = Yup.object().shape({
|
|||||||
.required()
|
.required()
|
||||||
.label(formatMessage({ id: 'date' })),
|
.label(formatMessage({ id: 'date' })),
|
||||||
currency_code: Yup.string().max(3),
|
currency_code: Yup.string().max(3),
|
||||||
reference: Yup.string().min(1).max(DATATYPES_LENGTH.STRING),
|
reference: Yup.string().nullable().min(1).max(DATATYPES_LENGTH.STRING),
|
||||||
description: Yup.string().min(1).max(DATATYPES_LENGTH.STRING),
|
description: Yup.string().min(1).max(DATATYPES_LENGTH.STRING),
|
||||||
|
status: Yup.boolean(),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
credit: Yup.number().decimalScale(13).nullable(),
|
credit: Yup.number().decimalScale(13).nullable(),
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ const Schema = Yup.object().shape({
|
|||||||
.required()
|
.required()
|
||||||
.label(formatMessage({ id: 'expiration_date_' })),
|
.label(formatMessage({ id: 'expiration_date_' })),
|
||||||
estimate_number: Yup.string()
|
estimate_number: Yup.string()
|
||||||
.nullable()
|
|
||||||
.max(DATATYPES_LENGTH.STRING)
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(formatMessage({ id: 'estimate_number_' })),
|
.label(formatMessage({ id: 'estimate_number_' })),
|
||||||
reference: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
reference: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
||||||
|
|||||||
Reference in New Issue
Block a user