mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
37 lines
989 B
JavaScript
37 lines
989 B
JavaScript
import {
|
|
transformToForm,
|
|
optionsMapToArray,
|
|
transfromToSnakeCase,
|
|
transactionNumber,
|
|
} from 'utils';
|
|
|
|
export const defaultInvoiceNoSettings = {
|
|
nextNumber: '',
|
|
numberPrefix: '',
|
|
autoIncrement: '',
|
|
};
|
|
|
|
export const transformSettingsToForm = (settings) => ({
|
|
...settings,
|
|
incrementMode: settings.autoIncrement === 'true' ? 'auto' : 'manual',
|
|
});
|
|
|
|
export const transformFormToSettings = (values, group) => {
|
|
const options = transfromToSnakeCase({
|
|
...transformToForm(values, defaultInvoiceNoSettings),
|
|
autoIncrement: values.incrementMode === 'auto',
|
|
});
|
|
return optionsMapToArray(options).map((option) => ({ ...option, group }));
|
|
};
|
|
|
|
export const transformValuesToForm = (values) => {
|
|
const incrementNumber =
|
|
values.incrementMode === 'auto'
|
|
? transactionNumber(values.numberPrefix, values.nextNumber)
|
|
: values.manualTransactionNo;
|
|
|
|
const manually = values.incrementMode === 'auto' ? false : true;
|
|
|
|
return { incrementNumber, manually };
|
|
};
|