feat: fix journal.

This commit is contained in:
elforjani13
2022-03-17 17:31:40 +02:00
parent b0407168a0
commit 888c3a11e0
8 changed files with 48 additions and 18 deletions

View File

@@ -59,6 +59,7 @@ function MakeJournalEntriesForm({
journalNumberPrefix,
journalNextNumber,
);
// Form initial values.
const initialValues = useMemo(
() => ({
@@ -69,7 +70,7 @@ function MakeJournalEntriesForm({
: {
...defaultManualJournal,
...(journalAutoIncrement && {
journal_number: defaultTo(journalNumber, ''),
journal_number: journalNumber,
}),
currency_code: base_currency,
}),
@@ -187,7 +188,7 @@ function MakeJournalEntriesForm({
export default compose(
withMediaActions,
withSettings(({ manualJournalsSettings }) => ({
journalNextNumber: parseInt(manualJournalsSettings?.nextNumber, 10),
journalNextNumber: manualJournalsSettings?.nextNumber,
journalNumberPrefix: manualJournalsSettings?.numberPrefix,
journalAutoIncrement: manualJournalsSettings?.autoIncrement,
})),

View File

@@ -62,14 +62,14 @@ function MakeJournalEntriesHeader({
// Handle journal number change.
const handleJournalNumberChange = () => {
openDialog('journal-number-form', {});
openDialog('journal-number-form');
};
// Handle journal number blur.
const handleJournalNoBlur = (form, field) => (event) => {
const newValue = event.target.value;
if (field.value !== newValue) {
if (field.value !== newValue && journalAutoIncrement) {
openDialog('journal-number-form', {
initialFormValues: {
manualTransactionNo: newValue,

View File

@@ -40,6 +40,7 @@ export const defaultEntry = {
export const defaultManualJournal = {
journal_number: '',
journal_number_manually: false,
journal_type: 'Journal',
date: moment(new Date()).format('YYYY-MM-DD'),
description: '',