fix: remove opening quantity & cost & date from item.

This commit is contained in:
elforjani3
2021-01-12 15:37:25 +02:00
parent 8634e08ec7
commit f042e23e6c
3 changed files with 0 additions and 94 deletions

View File

@@ -43,9 +43,6 @@ const defaultInitialValues = {
category_id: '',
sellable: 1,
purchasable: true,
opening_quantity: '',
opening_cost: '',
opening_date: moment(new Date()).format('YYYY-MM-DD'),
};
/**

View File

@@ -61,26 +61,6 @@ const Schema = Yup.object().shape({
stock: Yup.string() || Yup.boolean(),
sellable: Yup.boolean().required(),
purchasable: Yup.boolean().required(),
opening_cost: Yup.number().when(['opening_quantity'], {
is: (value) => value,
then: Yup.number()
.min(0)
.required()
.label(formatMessage({ id: 'opening_cost_' })),
otherwise: Yup.number().nullable(),
}),
opening_quantity: Yup.number()
.integer()
.min(1)
.nullable()
.label(formatMessage({ id: 'opening_quantity_' })),
opening_date: Yup.date().when(['opening_quantity', 'opening_cost'], {
is: (quantity, cost) => !isBlank(quantity) && !isBlank(cost),
then: Yup.date()
.required()
.label(formatMessage({ id: 'opening_date_' })),
otherwise: Yup.date().nullable(),
}),
});
export const transformItemFormData = (item, defaultValue) => {

View File

@@ -65,77 +65,6 @@ function ItemFormInventorySection({ accountsList, baseCurrency }) {
</FormGroup>
)}
</FastField>
{/*------------- Opening quantity ------------- */}
<FastField name={'opening_quantity'}>
{({ field, meta: { touched, error } }) => (
<FormGroup
label={<T id={'opening_quantity'} />}
labelInfo={<Hint />}
className={'form-group--opening_quantity'}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'opening_quantity'} />}
inline={true}
>
<InputGroup medium={true} {...field} />
</FormGroup>
)}
</FastField>
{/*------------- Opening date ------------- */}
<FastField name={'opening_date'}>
{({ form, field: { value }, meta: { touched, error } }) => (
<FormGroup
label={<T id={'opening_date'} />}
labelInfo={<Hint />}
className={classNames(
'form-group--select-list',
'form-group--opening_date',
CLASSES.FILL,
)}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'opening_date'} />}
inline={true}
>
<DateInput
{...momentFormatter('YYYY/MM/DD')}
value={tansformDateValue(value)}
onChange={handleDateChange((value) => {
form.setFieldValue('opening_date', value);
})}
helperText={<ErrorMessage name={'opening_date'} />}
popoverProps={{ position: Position.BOTTOM, minimal: true }}
/>
</FormGroup>
)}
</FastField>
</Col>
{/*------------- Opening cost ------------- */}
<Col xs={6}>
<FastField name={'opening_cost'}>
{({ form, field: { value }, meta: { touched, error } }) => (
<FormGroup
label={<T id={'opening_average_cost'} />}
labelInfo={<Hint />}
className={'form-group--opening_cost'}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'opening_cost'} />}
inline={true}
>
<ControlGroup>
<InputPrependText text={baseCurrency} />
<MoneyInputGroup
value={value}
inputGroupProps={{ fill: true }}
onChange={(unformattedValue) => {
form.setFieldValue('opening_cost', unformattedValue);
}}
/>
</ControlGroup>
</FormGroup>
)}
</FastField>
</Col>
</Row>
</div>