fix(webapp): auto-increment estimate transactions

This commit is contained in:
a.bouhuolia
2023-05-25 22:04:21 +02:00
parent aaceea5338
commit e92c4486aa
7 changed files with 48 additions and 18 deletions

View File

@@ -7,7 +7,6 @@ import { useFormikContext } from 'formik';
import { omit, first } from 'lodash';
import {
defaultFastFieldShouldUpdate,
transactionNumber,
repeatValue,
transformToForm,
formattedAmount,
@@ -37,6 +36,7 @@ export const defaultEstimate = {
estimate_date: moment(new Date()).format('YYYY-MM-DD'),
expiration_date: moment(new Date()).format('YYYY-MM-DD'),
estimate_number: '',
estimate_number_manually: '',
delivered: '',
reference: '',
note: '',
@@ -142,6 +142,8 @@ export const transfromsFormValuesToRequest = (values) => {
);
return {
...omit(values, ['estimate_number_manually', 'estimate_number']),
// The `estimate_number_manually` will be presented just if the auto-increment
// is disable, always both attributes hold the same value in manual mode.
...(values.estimate_number_manually && {
estimate_number: values.estimate_number,
}),
@@ -223,3 +225,17 @@ export const useEstimateIsForeignCustomer = () => {
);
return isForeignCustomer;
};
/**
* Resets the form values.
*/
export const resetFormState = ({ initialValues, values, resetForm }) => {
resetForm({
values: {
// Reset the all values except the warehouse and brand id.
...initialValues,
warehouse_id: values.warehouse_id,
brand_id: values.brand_id,
},
});
};