mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
chrone: sperate client and server to different repos.
This commit is contained in:
36
src/containers/JournalNumber/utils.js
Normal file
36
src/containers/JournalNumber/utils.js
Normal file
@@ -0,0 +1,36 @@
|
||||
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 };
|
||||
};
|
||||
Reference in New Issue
Block a user