mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: rename item sku to code.
feat: fix sidebar current tab issue.
This commit is contained in:
@@ -33,7 +33,7 @@ const defaultInitialValues = {
|
||||
active: true,
|
||||
name: '',
|
||||
type: 'service',
|
||||
sku: '',
|
||||
code: '',
|
||||
cost_price: '',
|
||||
sell_price: '',
|
||||
cost_account_id: '',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as Yup from 'yup';
|
||||
import { defaultTo } from 'lodash';
|
||||
import { formatMessage } from 'services/intl';
|
||||
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||
|
||||
@@ -15,7 +16,7 @@ const Schema = Yup.object().shape({
|
||||
.min(0)
|
||||
.max(DATATYPES_LENGTH.STRING)
|
||||
.label(formatMessage({ id: 'item_type_' })),
|
||||
sku: Yup.string().trim().min(0).max(DATATYPES_LENGTH.STRING),
|
||||
code: Yup.string().trim().min(0).max(DATATYPES_LENGTH.STRING),
|
||||
cost_price: Yup.number().when(['purchasable'], {
|
||||
is: true,
|
||||
then: Yup.number()
|
||||
@@ -61,8 +62,8 @@ const Schema = Yup.object().shape({
|
||||
export const transformItemFormData = (item, defaultValue) => {
|
||||
return {
|
||||
...item,
|
||||
sellable: item?.sellable ? Boolean(item.sellable) : defaultValue.sellable,
|
||||
purchasable: item?.purchasable ? Boolean(item.purchasable) : defaultValue.purchasable,
|
||||
sellable: !!defaultTo(item?.sellable, defaultValue.sellable),
|
||||
purchasable: !!defaultTo(item?.purchasable, defaultValue.purchasable),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ function ItemFormBody({ accountsList, baseCurrency }) {
|
||||
<Col xs={6}>
|
||||
{/*------------- Purchasable checbox ------------- */}
|
||||
<FastField name={'sellable'} type="checkbox">
|
||||
{({ field }) => (
|
||||
{({ form, field }) => (
|
||||
<FormGroup inline={true} className={'form-group--sellable'}>
|
||||
<Checkbox
|
||||
inline={true}
|
||||
@@ -44,7 +44,7 @@ function ItemFormBody({ accountsList, baseCurrency }) {
|
||||
</FastField>
|
||||
|
||||
{/*------------- Selling price ------------- */}
|
||||
<Field name={'sell_price'}>
|
||||
<FastField name={'sell_price'}>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={<T id={'selling_price'} />}
|
||||
@@ -67,7 +67,7 @@ function ItemFormBody({ accountsList, baseCurrency }) {
|
||||
</ControlGroup>
|
||||
</FormGroup>
|
||||
)}
|
||||
</Field>
|
||||
</FastField>
|
||||
|
||||
{/*------------- Selling account ------------- */}
|
||||
<FastField name={'sell_account_id'}>
|
||||
@@ -93,6 +93,7 @@ function ItemFormBody({ accountsList, baseCurrency }) {
|
||||
selectedAccountId={value}
|
||||
disabled={!form.values.sellable}
|
||||
filterByTypes={['income']}
|
||||
popoverFill={true}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
@@ -118,7 +119,7 @@ function ItemFormBody({ accountsList, baseCurrency }) {
|
||||
</FastField>
|
||||
|
||||
{/*------------- Cost price ------------- */}
|
||||
<Field name={'cost_price'}>
|
||||
<FastField name={'cost_price'}>
|
||||
{({ field, form, field: { value }, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={<T id={'cost_price'} />}
|
||||
@@ -141,7 +142,7 @@ function ItemFormBody({ accountsList, baseCurrency }) {
|
||||
</ControlGroup>
|
||||
</FormGroup>
|
||||
)}
|
||||
</Field>
|
||||
</FastField>
|
||||
|
||||
{/*------------- Cost account ------------- */}
|
||||
<FastField name={'cost_account_id'}>
|
||||
@@ -167,6 +168,7 @@ function ItemFormBody({ accountsList, baseCurrency }) {
|
||||
selectedAccountId={value}
|
||||
disabled={!form.values.purchasable}
|
||||
filterByTypes={['cost_of_goods_sold']}
|
||||
popoverFill={true}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
|
||||
@@ -135,7 +135,7 @@ function ItemFormPrimarySection({
|
||||
</FastField>
|
||||
|
||||
{/*----------- Item category ----------*/}
|
||||
<FastField name={'type'}>
|
||||
<FastField name={'category_id'}>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={<T id={'category'} />}
|
||||
@@ -143,7 +143,6 @@ function ItemFormPrimarySection({
|
||||
intent={inputIntent({ error, touched })}
|
||||
helperText={<ErrorMessage name="category_id" />}
|
||||
className={classNames(
|
||||
'form-group--select-list',
|
||||
'form-group--category',
|
||||
Classes.FILL,
|
||||
)}
|
||||
@@ -154,7 +153,6 @@ function ItemFormPrimarySection({
|
||||
onCategorySelected={(category) => {
|
||||
form.setFieldValue('category_id', category.id);
|
||||
}}
|
||||
popoverProps={{ minimal: true }}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
|
||||
@@ -111,8 +111,8 @@ function ItemsDataTable({
|
||||
},
|
||||
{
|
||||
Header: formatMessage({ id: 'item_code' }),
|
||||
accessor: 'sku',
|
||||
className: 'sku',
|
||||
accessor: 'code',
|
||||
className: 'code',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user