fix(ManualJournal): manual journal auto-increment dialog.

This commit is contained in:
a.bouhuolia
2021-03-18 18:26:03 +02:00
parent 671377f2c7
commit 357f1d9173
7 changed files with 108 additions and 39 deletions

View File

@@ -1,11 +1,17 @@
import React from 'react';
import { Intent } from '@blueprintjs/core';
import { sumBy, setWith, toSafeInteger, get } from 'lodash';
import { sumBy, setWith, toSafeInteger, get, values } from 'lodash';
import moment from 'moment';
import { updateTableRow, repeatValue, transformToForm } from 'utils';
import {
transactionNumber,
updateTableRow,
repeatValue,
transformToForm,
} from 'utils';
import { AppToaster } from 'components';
import { formatMessage } from 'services/intl';
import { useFormikContext } from 'formik';
const ERROR = {
JOURNAL_NUMBER_ALREADY_EXISTS: 'JOURNAL.NUMBER.ALREADY.EXISTS',
@@ -153,3 +159,12 @@ export const transformErrors = (resErrors, { setErrors, errors }) => {
});
}
};
export const useObserveJournalNoSettings = (prefix, nextNumber) => {
const { setFieldValue } = useFormikContext();
React.useEffect(() => {
const journalNo = transactionNumber(prefix, nextNumber);
setFieldValue('journal_number', journalNo);
}, [setFieldValue, prefix, nextNumber]);
};