mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
Fix :data types variables.
This commit is contained in:
7
client/src/common/dataTypes.js
Normal file
7
client/src/common/dataTypes.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export const DATATYPES_LENGTH = {
|
||||||
|
STRING: 255,
|
||||||
|
TEXT: 65535,
|
||||||
|
INT_10: 4294967295,
|
||||||
|
DECIMAL_13_3: 9999999999.999,
|
||||||
|
DECIMAL_15_5: 999999999999.999,
|
||||||
|
};
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import * as Yup from 'yup';
|
||||||
|
import { formatMessage } from 'services/intl';
|
||||||
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
|
const Schema = Yup.object().shape({
|
||||||
|
journal_number: Yup.string()
|
||||||
|
.required()
|
||||||
|
.min(1)
|
||||||
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
|
.label(formatMessage({ id: 'journal_number_' })),
|
||||||
|
journal_type: Yup.string()
|
||||||
|
.required()
|
||||||
|
.min(1)
|
||||||
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
|
.label(formatMessage({ id: 'journal_type' })),
|
||||||
|
date: Yup.date()
|
||||||
|
.required()
|
||||||
|
.label(formatMessage({ id: 'date' })),
|
||||||
|
currency_code: Yup.string().max(3),
|
||||||
|
reference: Yup.string().min(1).max(DATATYPES_LENGTH.STRING),
|
||||||
|
description: Yup.string().min(1).max(DATATYPES_LENGTH.STRING),
|
||||||
|
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(DATATYPES_LENGTH.TEXT).nullable(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CreateMakeJournalFormSchema = Schema;
|
||||||
|
export const EditMakeJournalFormSchema = Schema;
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import * as Yup from 'yup';
|
||||||
|
import { formatMessage } from 'services/intl';
|
||||||
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
|
const Schema = Yup.object().shape({
|
||||||
|
name: Yup.string()
|
||||||
|
.required()
|
||||||
|
.min(3)
|
||||||
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
|
.label(formatMessage({ id: 'account_name_' })),
|
||||||
|
code: Yup.string().digits().min(3).max(6),
|
||||||
|
account_type_id: Yup.number()
|
||||||
|
.nullable()
|
||||||
|
.required()
|
||||||
|
.label(formatMessage({ id: 'account_type_id' })),
|
||||||
|
description: Yup.string().min(3).max(DATATYPES_LENGTH.TEXT).nullable().trim(),
|
||||||
|
parent_account_id: Yup.number().nullable(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CreateAccountFormSchema = Schema;
|
||||||
|
export const EditAccountFormSchema = Schema;
|
||||||
@@ -30,7 +30,10 @@ import withAccountsActions from 'containers/Accounts/withAccountsActions';
|
|||||||
import withAccountDetail from 'containers/Accounts/withAccountDetail';
|
import withAccountDetail from 'containers/Accounts/withAccountDetail';
|
||||||
import withAccounts from 'containers/Accounts/withAccounts';
|
import withAccounts from 'containers/Accounts/withAccounts';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
import {
|
||||||
|
EditAccountFormSchema,
|
||||||
|
CreateAccountFormSchema,
|
||||||
|
} from './AccountForm.schema';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,19 +64,12 @@ function AccountFormDialogContent({
|
|||||||
accountTypeId,
|
accountTypeId,
|
||||||
}) {
|
}) {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const validationSchema = Yup.object().shape({
|
const isNewMode = !accountId;
|
||||||
name: Yup.string()
|
|
||||||
.required()
|
const validationSchema = isNewMode
|
||||||
.min(3)
|
? CreateAccountFormSchema
|
||||||
.max(255)
|
: EditAccountFormSchema;
|
||||||
.label(formatMessage({ id: 'account_name_' })),
|
|
||||||
code: Yup.string().digits().min(3).max(6),
|
|
||||||
account_type_id: Yup.number().nullable()
|
|
||||||
.required()
|
|
||||||
.label(formatMessage({ id: 'account_type_id' })),
|
|
||||||
description: Yup.string().min(3).max(512).nullable().trim(),
|
|
||||||
parent_account_id: Yup.number().nullable(),
|
|
||||||
});
|
|
||||||
const initialValues = useMemo(
|
const initialValues = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
account_type_id: '',
|
account_type_id: '',
|
||||||
@@ -194,18 +190,14 @@ function AccountFormDialogContent({
|
|||||||
}, [closeDialog, dialogName]);
|
}, [closeDialog, dialogName]);
|
||||||
|
|
||||||
// Fetches accounts list.
|
// Fetches accounts list.
|
||||||
const fetchAccountsList = useQuery(
|
const fetchAccountsList = useQuery('accounts-list', () =>
|
||||||
'accounts-list',
|
requestFetchAccounts(),
|
||||||
() => requestFetchAccounts(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Fetches accounts types.
|
// Fetches accounts types.
|
||||||
const fetchAccountsTypes = useQuery(
|
const fetchAccountsTypes = useQuery('accounts-types-list', async () => {
|
||||||
'accounts-types-list',
|
await requestFetchAccountTypes();
|
||||||
async () => {
|
});
|
||||||
await requestFetchAccountTypes();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// Fetch the given account id on edit mode.
|
// Fetch the given account id on edit mode.
|
||||||
const fetchAccount = useQuery(
|
const fetchAccount = useQuery(
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import React, { useMemo, useCallback } from 'react';
|
import React, { useMemo, useCallback } from 'react';
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
import * as Yup from 'yup';
|
|
||||||
import { useQuery, queryCache } from 'react-query';
|
import { useQuery, queryCache } from 'react-query';
|
||||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
import { Formik } from 'formik';
|
import { Formik } from 'formik';
|
||||||
import { AppToaster, DialogContent } from 'components';
|
import { AppToaster, DialogContent } from 'components';
|
||||||
|
|
||||||
|
import ItemCategoryForm from './ItemCategoryForm';
|
||||||
import withItemCategories from 'containers/Items/withItemCategories';
|
import withItemCategories from 'containers/Items/withItemCategories';
|
||||||
import withItemCategoryDetail from 'containers/Items/withItemCategoryDetail';
|
import withItemCategoryDetail from 'containers/Items/withItemCategoryDetail';
|
||||||
import withItemCategoriesActions from 'containers/Items/withItemCategoriesActions';
|
import withItemCategoriesActions from 'containers/Items/withItemCategoriesActions';
|
||||||
@@ -14,8 +14,11 @@ import withAccounts from 'containers/Accounts/withAccounts';
|
|||||||
import withAccountsActions from 'containers/Accounts/withAccountsActions';
|
import withAccountsActions from 'containers/Accounts/withAccountsActions';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
|
import {
|
||||||
|
EditItemCategoryFormSchema,
|
||||||
|
CreateItemCategoryFormSchema,
|
||||||
|
} from './itemCategoryForm.schema';
|
||||||
import { compose, transformToForm } from 'utils';
|
import { compose, transformToForm } from 'utils';
|
||||||
import ItemCategoryForm from './ItemCategoryForm';
|
|
||||||
|
|
||||||
const defaultInitialValues = {
|
const defaultInitialValues = {
|
||||||
name: '',
|
name: '',
|
||||||
@@ -70,17 +73,6 @@ function ItemCategoryFormDialogContent({
|
|||||||
requestFetchAccounts(),
|
requestFetchAccounts(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
|
||||||
name: Yup.string()
|
|
||||||
.required()
|
|
||||||
.label(formatMessage({ id: 'category_name_' })),
|
|
||||||
parent_category_id: Yup.number().nullable(),
|
|
||||||
cost_account_id: Yup.number().nullable(),
|
|
||||||
sell_account_id: Yup.number().nullable(),
|
|
||||||
inventory_account_id: Yup.number().nullable(),
|
|
||||||
description: Yup.string().trim().nullable(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const initialValues = useMemo(
|
const initialValues = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
...defaultInitialValues,
|
...defaultInitialValues,
|
||||||
@@ -131,7 +123,9 @@ function ItemCategoryFormDialogContent({
|
|||||||
isLoading={fetchCategoriesList.isFetching || fetchAccountsList.isFetching}
|
isLoading={fetchCategoriesList.isFetching || fetchAccountsList.isFetching}
|
||||||
>
|
>
|
||||||
<Formik
|
<Formik
|
||||||
validationSchema={validationSchema}
|
validationSchema={
|
||||||
|
isNewMode ? CreateItemCategoryFormSchema : EditItemCategoryFormSchema
|
||||||
|
}
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
onSubmit={handleFormSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import * as Yup from 'yup';
|
||||||
|
import { formatMessage } from 'services/intl';
|
||||||
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
|
const Schema = Yup.object().shape({
|
||||||
|
name: Yup.string()
|
||||||
|
.required()
|
||||||
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
|
.label(formatMessage({ id: 'category_name_' })),
|
||||||
|
parent_category_id: Yup.number().nullable(),
|
||||||
|
cost_account_id: Yup.number().nullable(),
|
||||||
|
sell_account_id: Yup.number().nullable(),
|
||||||
|
inventory_account_id: Yup.number().nullable(),
|
||||||
|
description: Yup.string().trim().max(DATATYPES_LENGTH.TEXT).nullable(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CreateItemCategoryFormSchema = Schema;
|
||||||
|
export const EditItemCategoryFormSchema = Schema;
|
||||||
@@ -26,7 +26,10 @@ import withSettings from 'containers/Settings/withSettings';
|
|||||||
|
|
||||||
import AppToaster from 'components/AppToaster';
|
import AppToaster from 'components/AppToaster';
|
||||||
import Dragzone from 'components/Dragzone';
|
import Dragzone from 'components/Dragzone';
|
||||||
|
import {
|
||||||
|
CreateExpenseFormSchema,
|
||||||
|
EditExpenseFormSchema,
|
||||||
|
} from './ExpenseForm.schema';
|
||||||
import useMedia from 'hooks/useMedia';
|
import useMedia from 'hooks/useMedia';
|
||||||
import { compose, repeatValue, transformToForm } from 'utils';
|
import { compose, repeatValue, transformToForm } from 'utils';
|
||||||
|
|
||||||
@@ -64,8 +67,9 @@ function ExpenseForm({
|
|||||||
onCancelForm,
|
onCancelForm,
|
||||||
}) {
|
}) {
|
||||||
const [payload, setPayload] = useState({});
|
const [payload, setPayload] = useState({});
|
||||||
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
|
const isNewMode = !expenseId;
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -79,38 +83,9 @@ function ExpenseForm({
|
|||||||
deleteCallback: requestDeleteMedia,
|
deleteCallback: requestDeleteMedia,
|
||||||
});
|
});
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = isNewMode
|
||||||
beneficiary: Yup.string().label(formatMessage({ id: 'beneficiary' })),
|
? CreateExpenseFormSchema
|
||||||
payment_account_id: Yup.number()
|
: EditExpenseFormSchema;
|
||||||
.required()
|
|
||||||
.label(formatMessage({ id: 'payment_account_' })),
|
|
||||||
payment_date: Yup.date()
|
|
||||||
.required()
|
|
||||||
.label(formatMessage({ id: 'payment_date_' })),
|
|
||||||
reference_no: Yup.string().min(1).max(255),
|
|
||||||
currency_code: Yup.string()
|
|
||||||
.nullable()
|
|
||||||
.label(formatMessage({ id: 'currency_code' })),
|
|
||||||
description: Yup.string()
|
|
||||||
.trim()
|
|
||||||
.min(1)
|
|
||||||
.max(1024)
|
|
||||||
.label(formatMessage({ id: 'description' })),
|
|
||||||
publish: Yup.boolean().label(formatMessage({ id: 'publish' })),
|
|
||||||
categories: Yup.array().of(
|
|
||||||
Yup.object().shape({
|
|
||||||
index: Yup.number().min(1).max(1000).nullable(),
|
|
||||||
amount: Yup.number().decimalScale(13).nullable(),
|
|
||||||
expense_account_id: Yup.number()
|
|
||||||
.nullable()
|
|
||||||
.when(['amount'], {
|
|
||||||
is: (amount) => amount,
|
|
||||||
then: Yup.number().required(),
|
|
||||||
}),
|
|
||||||
description: Yup.string().nullable(),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleDropFiles = useCallback((_files) => {
|
const handleDropFiles = useCallback((_files) => {
|
||||||
setFiles(_files.filter((file) => file.uploaded === false));
|
setFiles(_files.filter((file) => file.uploaded === false));
|
||||||
|
|||||||
40
client/src/containers/Expenses/ExpenseForm.schema.js
Normal file
40
client/src/containers/Expenses/ExpenseForm.schema.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import * as Yup from 'yup';
|
||||||
|
import { formatMessage } from 'services/intl';
|
||||||
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
|
const Schema = Yup.object().shape({
|
||||||
|
beneficiary: Yup.string().label(formatMessage({ id: 'beneficiary' })),
|
||||||
|
payment_account_id: Yup.number()
|
||||||
|
.required()
|
||||||
|
.label(formatMessage({ id: 'payment_account_' })),
|
||||||
|
payment_date: Yup.date()
|
||||||
|
.required()
|
||||||
|
.label(formatMessage({ id: 'payment_date_' })),
|
||||||
|
reference_no: Yup.string().min(1).max(DATATYPES_LENGTH.STRING),
|
||||||
|
currency_code: Yup.string()
|
||||||
|
.nullable()
|
||||||
|
.max(3)
|
||||||
|
.label(formatMessage({ id: 'currency_code' })),
|
||||||
|
description: Yup.string()
|
||||||
|
.trim()
|
||||||
|
.min(1)
|
||||||
|
.max(DATATYPES_LENGTH.TEXT)
|
||||||
|
.label(formatMessage({ id: 'description' })),
|
||||||
|
publish: Yup.boolean().label(formatMessage({ id: 'publish' })),
|
||||||
|
categories: Yup.array().of(
|
||||||
|
Yup.object().shape({
|
||||||
|
index: Yup.number().min(1).max(DATATYPES_LENGTH.INT_10).nullable(),
|
||||||
|
amount: Yup.number().decimalScale(13).nullable(),
|
||||||
|
expense_account_id: Yup.number()
|
||||||
|
.nullable()
|
||||||
|
.when(['amount'], {
|
||||||
|
is: (amount) => amount,
|
||||||
|
then: Yup.number().required(),
|
||||||
|
}),
|
||||||
|
description: Yup.string().max(DATATYPES_LENGTH.TEXT).nullable(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CreateExpenseFormSchema = Schema;
|
||||||
|
export const EditExpenseFormSchema = Schema;
|
||||||
@@ -1,16 +1,21 @@
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import { formatMessage } from 'services/intl';
|
import { formatMessage } from 'services/intl';
|
||||||
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
const Schema = Yup.object().shape({
|
const Schema = Yup.object().shape({
|
||||||
active: Yup.boolean(),
|
active: Yup.boolean(),
|
||||||
name: Yup.string()
|
name: Yup.string()
|
||||||
.required()
|
.required()
|
||||||
|
.min(0)
|
||||||
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(formatMessage({ id: 'item_name_' })),
|
.label(formatMessage({ id: 'item_name_' })),
|
||||||
type: Yup.string()
|
type: Yup.string()
|
||||||
.trim()
|
.trim()
|
||||||
.required()
|
.required()
|
||||||
|
.min(0)
|
||||||
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(formatMessage({ id: 'item_type_' })),
|
.label(formatMessage({ id: 'item_type_' })),
|
||||||
sku: Yup.string().trim(),
|
sku: Yup.string().trim().min(0).max(DATATYPES_LENGTH.STRING),
|
||||||
cost_price: Yup.number().when(['purchasable'], {
|
cost_price: Yup.number().when(['purchasable'], {
|
||||||
is: true,
|
is: true,
|
||||||
then: Yup.number()
|
then: Yup.number()
|
||||||
@@ -53,4 +58,4 @@ const Schema = Yup.object().shape({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const CreateItemFormSchema = Schema;
|
export const CreateItemFormSchema = Schema;
|
||||||
export const EditItemFormSchema = Schema;
|
export const EditItemFormSchema = Schema;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import { formatMessage } from 'services/intl';
|
import { formatMessage } from 'services/intl';
|
||||||
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
const BillFormSchema = Yup.object().shape({
|
const BillFormSchema = Yup.object().shape({
|
||||||
vendor_id: Yup.number()
|
vendor_id: Yup.number()
|
||||||
@@ -12,22 +13,24 @@ const BillFormSchema = Yup.object().shape({
|
|||||||
.required()
|
.required()
|
||||||
.label(formatMessage({ id: 'due_date_' })),
|
.label(formatMessage({ id: 'due_date_' })),
|
||||||
bill_number: Yup.string()
|
bill_number: Yup.string()
|
||||||
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(formatMessage({ id: 'bill_number_' })),
|
.label(formatMessage({ id: 'bill_number_' })),
|
||||||
reference_no: Yup.string().nullable().min(1).max(255),
|
reference_no: Yup.string().nullable().min(1).max(DATATYPES_LENGTH.STRING),
|
||||||
note: Yup.string()
|
note: Yup.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(1)
|
.min(1)
|
||||||
.max(1024)
|
.max(DATATYPES_LENGTH.TEXT)
|
||||||
.label(formatMessage({ id: 'note' })),
|
.label(formatMessage({ id: 'note' })),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
quantity: Yup.number()
|
quantity: Yup.number()
|
||||||
.nullable()
|
.nullable()
|
||||||
|
.max(DATATYPES_LENGTH.INT_10)
|
||||||
.when(['rate'], {
|
.when(['rate'], {
|
||||||
is: (rate) => rate,
|
is: (rate) => rate,
|
||||||
then: Yup.number().required(),
|
then: Yup.number().required(),
|
||||||
}),
|
}),
|
||||||
rate: Yup.number().nullable(),
|
rate: Yup.number().nullable().max(DATATYPES_LENGTH.INT_10),
|
||||||
item_id: Yup.number()
|
item_id: Yup.number()
|
||||||
.nullable()
|
.nullable()
|
||||||
.when(['quantity', 'rate'], {
|
.when(['quantity', 'rate'], {
|
||||||
@@ -35,8 +38,8 @@ const BillFormSchema = Yup.object().shape({
|
|||||||
then: Yup.number().required(),
|
then: Yup.number().required(),
|
||||||
}),
|
}),
|
||||||
total: Yup.number().nullable(),
|
total: Yup.number().nullable(),
|
||||||
discount: Yup.number().nullable().min(0).max(100),
|
discount: Yup.number().nullable().min(0).max(DATATYPES_LENGTH.INT_10),
|
||||||
description: Yup.string().nullable(),
|
description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
@@ -44,7 +47,4 @@ const BillFormSchema = Yup.object().shape({
|
|||||||
const CreateBillFormSchema = BillFormSchema;
|
const CreateBillFormSchema = BillFormSchema;
|
||||||
const EditBillFormSchema = BillFormSchema;
|
const EditBillFormSchema = BillFormSchema;
|
||||||
|
|
||||||
export {
|
export { CreateBillFormSchema, EditBillFormSchema };
|
||||||
CreateBillFormSchema,
|
|
||||||
EditBillFormSchema,
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ import withPaymentMadeDetail from './withPaymentMadeDetail';
|
|||||||
import withPaymentMade from './withPaymentMade';
|
import withPaymentMade from './withPaymentMade';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
||||||
|
import {
|
||||||
|
EditPaymentMadeFormSchema,
|
||||||
|
CreatePaymentMadeFormSchema,
|
||||||
|
} from './PaymentMadeForm.schema';
|
||||||
import { compose, orderingLinesIndexes } from 'utils';
|
import { compose, orderingLinesIndexes } from 'utils';
|
||||||
|
|
||||||
const ERRORS = {
|
const ERRORS = {
|
||||||
@@ -73,50 +76,27 @@ function PaymentMadeForm({
|
|||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
const isNewMode = !paymentMadeId;
|
||||||
const [amountChangeAlert, setAmountChangeAlert] = useState(false);
|
const [amountChangeAlert, setAmountChangeAlert] = useState(false);
|
||||||
const [clearLinesAlert, setClearLinesAlert] = useState(false);
|
const [clearLinesAlert, setClearLinesAlert] = useState(false);
|
||||||
const [clearFormAlert, setClearFormAlert] = useState(false);
|
const [clearFormAlert, setClearFormAlert] = useState(false);
|
||||||
const [fullAmount, setFullAmount] = useState(null);
|
const [fullAmount, setFullAmount] = useState(null);
|
||||||
|
|
||||||
const [localPaymentEntries, setLocalPaymentEntries] = useState(paymentMadeEntries);
|
const [localPaymentEntries, setLocalPaymentEntries] = useState(
|
||||||
|
paymentMadeEntries,
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (localPaymentEntries !== paymentMadeEntries) {
|
if (localPaymentEntries !== paymentMadeEntries) {
|
||||||
setLocalPaymentEntries(paymentMadeEntries);
|
setLocalPaymentEntries(paymentMadeEntries);
|
||||||
}
|
}
|
||||||
}, [localPaymentEntries, paymentMadeEntries])
|
}, [localPaymentEntries, paymentMadeEntries]);
|
||||||
|
|
||||||
// Yup validation schema.
|
// Yup validation schema.
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = isNewMode
|
||||||
vendor_id: Yup.string()
|
? CreatePaymentMadeFormSchema
|
||||||
.label(formatMessage({ id: 'vendor_name_' }))
|
: EditPaymentMadeFormSchema;
|
||||||
.required(),
|
|
||||||
payment_date: Yup.date()
|
|
||||||
.required()
|
|
||||||
.label(formatMessage({ id: 'payment_date_' })),
|
|
||||||
payment_account_id: Yup.number()
|
|
||||||
.required()
|
|
||||||
.label(formatMessage({ id: 'payment_account_' })),
|
|
||||||
payment_number: Yup.string()
|
|
||||||
.label(formatMessage({ id: 'payment_no_' })),
|
|
||||||
reference: Yup.string().min(1).max(255).nullable(),
|
|
||||||
description: Yup.string(),
|
|
||||||
entries: Yup.array().of(
|
|
||||||
Yup.object().shape({
|
|
||||||
id: Yup.number().nullable(),
|
|
||||||
due_amount: Yup.number().nullable(),
|
|
||||||
payment_amount: Yup.number().nullable().max(Yup.ref('due_amount')),
|
|
||||||
bill_id: Yup.number()
|
|
||||||
.nullable()
|
|
||||||
.when(['payment_amount'], {
|
|
||||||
is: (payment_amount) => payment_amount,
|
|
||||||
then: Yup.number().required(),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Form initial values.
|
// Form initial values.
|
||||||
const initialValues = useMemo(
|
const initialValues = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
@@ -246,7 +226,7 @@ function PaymentMadeForm({
|
|||||||
|
|
||||||
const resetEntriesPaymentAmount = (entries) => {
|
const resetEntriesPaymentAmount = (entries) => {
|
||||||
return entries.map((entry) => ({ ...entry, payment_amount: 0 }));
|
return entries.map((entry) => ({ ...entry, payment_amount: 0 }));
|
||||||
}
|
};
|
||||||
// Handle fetch success of vendor bills entries.
|
// Handle fetch success of vendor bills entries.
|
||||||
const handleFetchEntriesSuccess = useCallback(
|
const handleFetchEntriesSuccess = useCallback(
|
||||||
(entries) => {
|
(entries) => {
|
||||||
@@ -307,10 +287,13 @@ function PaymentMadeForm({
|
|||||||
changePageSubtitle(paymentNumber);
|
changePageSubtitle(paymentNumber);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clear page subtitle before once page leave.
|
// Clear page subtitle before once page leave.
|
||||||
useEffect(() => () => {
|
useEffect(
|
||||||
changePageSubtitle('')
|
() => () => {
|
||||||
}, [changePageSubtitle]);
|
changePageSubtitle('');
|
||||||
|
},
|
||||||
|
[changePageSubtitle],
|
||||||
|
);
|
||||||
|
|
||||||
const fullAmountPaid = useMemo(
|
const fullAmountPaid = useMemo(
|
||||||
() => sumBy(values.entries, 'payment_amount'),
|
() => sumBy(values.entries, 'payment_amount'),
|
||||||
@@ -385,9 +368,7 @@ function PaymentMadeForm({
|
|||||||
<p>Are you sure you want to clear this transaction?</p>
|
<p>Are you sure you want to clear this transaction?</p>
|
||||||
</Alert>
|
</Alert>
|
||||||
|
|
||||||
<PaymentMadeFooter
|
<PaymentMadeFooter getFieldProps={getFieldProps} />
|
||||||
getFieldProps={getFieldProps}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<PaymentMadeFloatingActions
|
<PaymentMadeFloatingActions
|
||||||
isSubmitting={isSubmitting}
|
isSubmitting={isSubmitting}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import * as Yup from 'yup';
|
||||||
|
import { formatMessage } from 'services/intl';
|
||||||
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
|
const Schema = Yup.object().shape({
|
||||||
|
vendor_id: Yup.string()
|
||||||
|
.label(formatMessage({ id: 'vendor_name_' }))
|
||||||
|
.required(),
|
||||||
|
payment_date: Yup.date()
|
||||||
|
.required()
|
||||||
|
.label(formatMessage({ id: 'payment_date_' })),
|
||||||
|
payment_account_id: Yup.number()
|
||||||
|
.required()
|
||||||
|
.label(formatMessage({ id: 'payment_account_' })),
|
||||||
|
payment_number: Yup.string()
|
||||||
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
|
.label(formatMessage({ id: 'payment_no_' })),
|
||||||
|
reference: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
||||||
|
description: Yup.string().max(DATATYPES_LENGTH.TEXT),
|
||||||
|
entries: Yup.array().of(
|
||||||
|
Yup.object().shape({
|
||||||
|
id: Yup.number().nullable(),
|
||||||
|
due_amount: Yup.number().nullable(),
|
||||||
|
payment_amount: Yup.number().nullable().max(Yup.ref('due_amount')),
|
||||||
|
bill_id: Yup.number()
|
||||||
|
.nullable()
|
||||||
|
.when(['payment_amount'], {
|
||||||
|
is: (payment_amount) => payment_amount,
|
||||||
|
then: Yup.number().required(),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CreatePaymentMadeFormSchema = Schema;
|
||||||
|
export const EditPaymentMadeFormSchema = Schema;
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import { formatMessage } from 'services/intl';
|
import { formatMessage } from 'services/intl';
|
||||||
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
const Schema = Yup.object().shape({
|
const Schema = Yup.object().shape({
|
||||||
customer_id: Yup.number()
|
customer_id: Yup.number()
|
||||||
.label(formatMessage({ id: 'customer_name_' }))
|
.label(formatMessage({ id: 'customer_name_' }))
|
||||||
.required(),
|
.required(),
|
||||||
@@ -13,38 +14,40 @@ const Schema = Yup.object().shape({
|
|||||||
.label(formatMessage({ id: 'expiration_date_' })),
|
.label(formatMessage({ id: 'expiration_date_' })),
|
||||||
estimate_number: Yup.string()
|
estimate_number: Yup.string()
|
||||||
.nullable()
|
.nullable()
|
||||||
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(formatMessage({ id: 'estimate_number_' })),
|
.label(formatMessage({ id: 'estimate_number_' })),
|
||||||
reference: Yup.string().min(1).max(255).nullable(),
|
reference: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
||||||
note: Yup.string()
|
note: Yup.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(1)
|
.min(1)
|
||||||
.max(1024)
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(formatMessage({ id: 'note' })),
|
.label(formatMessage({ id: 'note' })),
|
||||||
terms_conditions: Yup.string()
|
terms_conditions: Yup.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(1)
|
.min(1)
|
||||||
.max(1024)
|
.max(DATATYPES_LENGTH.TEXT)
|
||||||
.label(formatMessage({ id: 'note' })),
|
.label(formatMessage({ id: 'note' })),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
quantity: Yup.number()
|
quantity: Yup.number()
|
||||||
.nullable()
|
.nullable()
|
||||||
|
.max(DATATYPES_LENGTH.INT_10)
|
||||||
.when(['rate'], {
|
.when(['rate'], {
|
||||||
is: (rate) => rate,
|
is: (rate) => rate,
|
||||||
then: Yup.number().required(),
|
then: Yup.number().required(),
|
||||||
}),
|
}),
|
||||||
rate: Yup.number().nullable(),
|
rate: Yup.number().nullable().max(DATATYPES_LENGTH.INT_10),
|
||||||
item_id: Yup.number()
|
item_id: Yup.number()
|
||||||
.nullable()
|
.nullable()
|
||||||
.when(['quantity', 'rate'], {
|
.when(['quantity', 'rate'], {
|
||||||
is: (quantity, rate) => quantity || rate,
|
is: (quantity, rate) => quantity || rate,
|
||||||
then: Yup.number().required(),
|
then: Yup.number().required(),
|
||||||
}),
|
}),
|
||||||
discount: Yup.number().nullable().min(0).max(100),
|
discount: Yup.number().nullable().min(0).max(DATATYPES_LENGTH.INT_10),
|
||||||
description: Yup.string().nullable(),
|
description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const CreateEstimateFormSchema = Schema;
|
export const CreateEstimateFormSchema = Schema;
|
||||||
export const EditEstimateFormSchema = Schema;
|
export const EditEstimateFormSchema = Schema;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import { formatMessage } from 'services/intl';
|
import { formatMessage } from 'services/intl';
|
||||||
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
const Schema = Yup.object().shape({
|
const Schema = Yup.object().shape({
|
||||||
customer_id: Yup.string()
|
customer_id: Yup.string()
|
||||||
@@ -12,39 +13,40 @@ const Schema = Yup.object().shape({
|
|||||||
.required()
|
.required()
|
||||||
.label(formatMessage({ id: 'due_date_' })),
|
.label(formatMessage({ id: 'due_date_' })),
|
||||||
invoice_no: Yup.string()
|
invoice_no: Yup.string()
|
||||||
.label(formatMessage({ id: 'invoice_no_' })),
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
reference_no: Yup.string().min(1).max(255),
|
.label(formatMessage({ id: 'invoice_no_' })),
|
||||||
|
reference_no: Yup.string().min(1).max(DATATYPES_LENGTH.STRING),
|
||||||
status: Yup.string().required(),
|
status: Yup.string().required(),
|
||||||
invoice_message: Yup.string()
|
invoice_message: Yup.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(1)
|
.min(1)
|
||||||
.max(1024)
|
.max(DATATYPES_LENGTH.TEXT)
|
||||||
.label(formatMessage({ id: 'note' })),
|
.label(formatMessage({ id: 'note' })),
|
||||||
terms_conditions: Yup.string()
|
terms_conditions: Yup.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(1)
|
.min(1)
|
||||||
.max(1024)
|
.max(DATATYPES_LENGTH.TEXT)
|
||||||
.label(formatMessage({ id: 'note' })),
|
.label(formatMessage({ id: 'note' })),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
quantity: Yup.number()
|
quantity: Yup.number()
|
||||||
.nullable()
|
.nullable().max(DATATYPES_LENGTH.INT_10)
|
||||||
.when(['rate'], {
|
.when(['rate'], {
|
||||||
is: (rate) => rate,
|
is: (rate) => rate,
|
||||||
then: Yup.number().required(),
|
then: Yup.number().required(),
|
||||||
}),
|
}),
|
||||||
rate: Yup.number().nullable(),
|
rate: Yup.number().nullable().max(DATATYPES_LENGTH.INT_10),
|
||||||
item_id: Yup.number()
|
item_id: Yup.number()
|
||||||
.nullable()
|
.nullable()
|
||||||
.when(['quantity', 'rate'], {
|
.when(['quantity', 'rate'], {
|
||||||
is: (quantity, rate) => quantity || rate,
|
is: (quantity, rate) => quantity || rate,
|
||||||
then: Yup.number().required(),
|
then: Yup.number().required(),
|
||||||
}),
|
}),
|
||||||
discount: Yup.number().nullable().min(0).max(100),
|
discount: Yup.number().nullable().min(0).max(DATATYPES_LENGTH.INT_10),
|
||||||
description: Yup.string().nullable(),
|
description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const CreateInvoiceFormSchema = Schema;
|
export const CreateInvoiceFormSchema = Schema;
|
||||||
export const EditInvoiceFormSchema = Schema;
|
export const EditInvoiceFormSchema = Schema;
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ import withPaymentReceiveDetail from './withPaymentReceiveDetail';
|
|||||||
import withPaymentReceives from './withPaymentReceives';
|
import withPaymentReceives from './withPaymentReceives';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
||||||
|
import {
|
||||||
|
EditPaymentReceiveFormSchema,
|
||||||
|
CreatePaymentReceiveFormSchema,
|
||||||
|
} from './PaymentReceiveForm.schema';
|
||||||
import { AppToaster } from 'components';
|
import { AppToaster } from 'components';
|
||||||
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
@@ -64,7 +68,7 @@ function PaymentReceiveForm({
|
|||||||
const [clearFormAlert, setClearFormAlert] = useState(false);
|
const [clearFormAlert, setClearFormAlert] = useState(false);
|
||||||
|
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
const isNewMode = !paymentReceiveId;
|
||||||
const [localPaymentEntries, setLocalPaymentEntries] = useState(
|
const [localPaymentEntries, setLocalPaymentEntries] = useState(
|
||||||
paymentReceiveEntries,
|
paymentReceiveEntries,
|
||||||
);
|
);
|
||||||
@@ -96,37 +100,10 @@ function PaymentReceiveForm({
|
|||||||
}, [localPaymentEntries, paymentReceiveEntries]);
|
}, [localPaymentEntries, paymentReceiveEntries]);
|
||||||
|
|
||||||
// Form validation schema.
|
// Form validation schema.
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = isNewMode
|
||||||
customer_id: Yup.string()
|
? CreatePaymentReceiveFormSchema
|
||||||
.label(formatMessage({ id: 'customer_name_' }))
|
: EditPaymentReceiveFormSchema;
|
||||||
.required(),
|
|
||||||
payment_date: Yup.date()
|
|
||||||
.required()
|
|
||||||
.label(formatMessage({ id: 'payment_date_' })),
|
|
||||||
deposit_account_id: Yup.number()
|
|
||||||
.required()
|
|
||||||
.label(formatMessage({ id: 'deposit_account_' })),
|
|
||||||
full_amount: Yup.number().nullable(),
|
|
||||||
payment_receive_no: Yup.string().label(
|
|
||||||
formatMessage({ id: 'payment_receive_no_' }),
|
|
||||||
),
|
|
||||||
reference_no: Yup.string().min(1).max(255).nullable(),
|
|
||||||
description: Yup.string().nullable(),
|
|
||||||
entries: Yup.array().of(
|
|
||||||
Yup.object().shape({
|
|
||||||
id: Yup.number().nullable(),
|
|
||||||
due_amount: Yup.number().nullable(),
|
|
||||||
payment_amount: Yup.number().nullable().max(Yup.ref('due_amount')),
|
|
||||||
invoice_id: Yup.number()
|
|
||||||
.nullable()
|
|
||||||
.when(['payment_amount'], {
|
|
||||||
is: (payment_amount) => payment_amount,
|
|
||||||
then: Yup.number().required(),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Default payment receive entry.
|
// Default payment receive entry.
|
||||||
const defaultPaymentReceiveEntry = {
|
const defaultPaymentReceiveEntry = {
|
||||||
id: null,
|
id: null,
|
||||||
@@ -354,7 +331,6 @@ function PaymentReceiveForm({
|
|||||||
changePageSubtitle,
|
changePageSubtitle,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
const handlePaymentReceiveNumberChanged = useCallback(
|
const handlePaymentReceiveNumberChanged = useCallback(
|
||||||
(payment_receive_no) => {
|
(payment_receive_no) => {
|
||||||
changePageSubtitle(`No.${payment_receive_no}`);
|
changePageSubtitle(`No.${payment_receive_no}`);
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import * as Yup from 'yup';
|
||||||
|
import { formatMessage } from 'services/intl';
|
||||||
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
|
const Schema = Yup.object().shape({
|
||||||
|
customer_id: Yup.string()
|
||||||
|
.label(formatMessage({ id: 'customer_name_' }))
|
||||||
|
.required(),
|
||||||
|
payment_date: Yup.date()
|
||||||
|
.required()
|
||||||
|
.label(formatMessage({ id: 'payment_date_' })),
|
||||||
|
deposit_account_id: Yup.number()
|
||||||
|
.required()
|
||||||
|
.label(formatMessage({ id: 'deposit_account_' })),
|
||||||
|
full_amount: Yup.number().nullable(),
|
||||||
|
payment_receive_no: Yup.string()
|
||||||
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
|
.label(formatMessage({ id: 'payment_receive_no_' })),
|
||||||
|
reference_no: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
||||||
|
description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
||||||
|
entries: Yup.array().of(
|
||||||
|
Yup.object().shape({
|
||||||
|
id: Yup.number().nullable(),
|
||||||
|
due_amount: Yup.number().nullable(),
|
||||||
|
payment_amount: Yup.number().nullable().max(Yup.ref('due_amount')),
|
||||||
|
invoice_id: Yup.number()
|
||||||
|
.nullable()
|
||||||
|
.when(['payment_amount'], {
|
||||||
|
is: (payment_amount) => payment_amount,
|
||||||
|
then: Yup.number().required(),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CreatePaymentReceiveFormSchema = Schema;
|
||||||
|
export const EditPaymentReceiveFormSchema = Schema;
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import { formatMessage } from 'services/intl';
|
import { formatMessage } from 'services/intl';
|
||||||
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
const Schema = Yup.object().shape({
|
const Schema = Yup.object().shape({
|
||||||
customer_id: Yup.string()
|
customer_id: Yup.string()
|
||||||
@@ -10,38 +11,40 @@ const Schema = Yup.object().shape({
|
|||||||
.label(formatMessage({ id: 'receipt_date_' })),
|
.label(formatMessage({ id: 'receipt_date_' })),
|
||||||
receipt_number: Yup.string()
|
receipt_number: Yup.string()
|
||||||
.nullable()
|
.nullable()
|
||||||
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(formatMessage({ id: 'receipt_no_' })),
|
.label(formatMessage({ id: 'receipt_no_' })),
|
||||||
deposit_account_id: Yup.number()
|
deposit_account_id: Yup.number()
|
||||||
.required()
|
.required()
|
||||||
.label(formatMessage({ id: 'deposit_account_' })),
|
.label(formatMessage({ id: 'deposit_account_' })),
|
||||||
reference_no: Yup.string().min(1).max(255),
|
reference_no: Yup.string().min(1).max(DATATYPES_LENGTH.STRING),
|
||||||
receipt_message: Yup.string()
|
receipt_message: Yup.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(1)
|
.min(1)
|
||||||
.max(1024)
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(formatMessage({ id: 'receipt_message_' })),
|
.label(formatMessage({ id: 'receipt_message_' })),
|
||||||
statement: Yup.string()
|
statement: Yup.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(1)
|
.min(1)
|
||||||
.max(1024)
|
.max(DATATYPES_LENGTH.TEXT)
|
||||||
.label(formatMessage({ id: 'note' })),
|
.label(formatMessage({ id: 'note' })),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
quantity: Yup.number()
|
quantity: Yup.number()
|
||||||
.nullable()
|
.nullable()
|
||||||
|
.max(DATATYPES_LENGTH.INT_10)
|
||||||
.when(['rate'], {
|
.when(['rate'], {
|
||||||
is: (rate) => rate,
|
is: (rate) => rate,
|
||||||
then: Yup.number().required(),
|
then: Yup.number().required(),
|
||||||
}),
|
}),
|
||||||
rate: Yup.number().nullable(),
|
rate: Yup.number().nullable().max(DATATYPES_LENGTH.INT_10),
|
||||||
item_id: Yup.number()
|
item_id: Yup.number()
|
||||||
.nullable()
|
.nullable()
|
||||||
.when(['quantity', 'rate'], {
|
.when(['quantity', 'rate'], {
|
||||||
is: (quantity, rate) => quantity || rate,
|
is: (quantity, rate) => quantity || rate,
|
||||||
then: Yup.number().required(),
|
then: Yup.number().required(),
|
||||||
}),
|
}),
|
||||||
discount: Yup.number().nullable().min(0).max(100),
|
discount: Yup.number().nullable().min(0).max(DATATYPES_LENGTH.INT_10),
|
||||||
description: Yup.string().nullable(),
|
description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user