mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat: apply new cards design system.
feat: empty status datatables. fix: edit account.
This commit is contained in:
56
client/src/containers/Items/ItemForm.schema.js
Normal file
56
client/src/containers/Items/ItemForm.schema.js
Normal file
@@ -0,0 +1,56 @@
|
||||
import * as Yup from 'yup';
|
||||
import { formatMessage } from 'services/intl';
|
||||
|
||||
const Schema = Yup.object().shape({
|
||||
active: Yup.boolean(),
|
||||
name: Yup.string()
|
||||
.required()
|
||||
.label(formatMessage({ id: 'item_name_' })),
|
||||
type: Yup.string()
|
||||
.trim()
|
||||
.required()
|
||||
.label(formatMessage({ id: 'item_type_' })),
|
||||
sku: Yup.string().trim(),
|
||||
cost_price: Yup.number().when(['purchasable'], {
|
||||
is: true,
|
||||
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()
|
||||
.label(formatMessage({ id: 'sell_price_' })),
|
||||
otherwise: Yup.number().nullable(true),
|
||||
}),
|
||||
cost_account_id: Yup.number()
|
||||
.when(['purchasable'], {
|
||||
is: true,
|
||||
then: Yup.number().required(),
|
||||
otherwise: Yup.number().nullable(true),
|
||||
})
|
||||
.label(formatMessage({ id: 'cost_account_id' })),
|
||||
sell_account_id: Yup.number()
|
||||
.when(['sellable'], {
|
||||
is: true,
|
||||
then: Yup.number().required(),
|
||||
otherwise: Yup.number().nullable(),
|
||||
})
|
||||
.label(formatMessage({ id: 'sell_account_id' })),
|
||||
inventory_account_id: Yup.number()
|
||||
.when(['type'], {
|
||||
is: (value) => value === 'inventory',
|
||||
then: Yup.number().required(),
|
||||
otherwise: Yup.number().nullable(),
|
||||
})
|
||||
.label(formatMessage({ id: 'inventory_account' })),
|
||||
category_id: Yup.number().positive().nullable(),
|
||||
stock: Yup.string() || Yup.boolean(),
|
||||
sellable: Yup.boolean().required(),
|
||||
purchasable: Yup.boolean().required(),
|
||||
});
|
||||
|
||||
export const CreateItemFormSchema = Schema;
|
||||
export const EditItemFormSchema = Schema;
|
||||
Reference in New Issue
Block a user