diff --git a/src/components/BranchSuggestField.js b/src/components/BranchSuggestField.js
index a856a33e0..e10bae2e3 100644
--- a/src/components/BranchSuggestField.js
+++ b/src/components/BranchSuggestField.js
@@ -21,7 +21,7 @@ export default function BranchSuggestField({
...suggestProps
}) {
const initialBranch = React.useMemo(
- () => branches.some((b) => b.id === initialBranchId),
+ () => branches.find((b) => b.id === initialBranchId),
[initialBranchId, branches],
);
@@ -29,6 +29,15 @@ export default function BranchSuggestField({
initialBranch || null,
);
+ React.useEffect(() => {
+ if (typeof selectedBranchId !== 'undefined') {
+ const branch = selectedBranchId
+ ? branches.find((a) => a.id === selectedBranchId)
+ : null;
+ setSelectedBranch(branch);
+ }
+ }, [selectedBranchId, branches, setSelectedBranch]);
+
/**
*
* @param {*} branch
diff --git a/src/components/DataTableCells/BranchesListFieldCell.js b/src/components/DataTableCells/BranchesListFieldCell.js
index 2fb82ade6..263005c10 100644
--- a/src/components/DataTableCells/BranchesListFieldCell.js
+++ b/src/components/DataTableCells/BranchesListFieldCell.js
@@ -14,7 +14,7 @@ export default function BranchesListFieldCell({
}) {
const handleBranchSelected = React.useCallback(
(branch) => {
- updateData(index, 'brnach_id', branch.id);
+ updateData(index, 'branch_id', branch.id);
},
[updateData, index],
);
@@ -33,7 +33,7 @@ export default function BranchesListFieldCell({
);
diff --git a/src/containers/Accounting/MakeJournal/MakeJournalEntriesForm.js b/src/containers/Accounting/MakeJournal/MakeJournalEntriesForm.js
index b40085ba8..d6c867579 100644
--- a/src/containers/Accounting/MakeJournal/MakeJournalEntriesForm.js
+++ b/src/containers/Accounting/MakeJournal/MakeJournalEntriesForm.js
@@ -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,
})),
diff --git a/src/containers/Accounting/MakeJournal/MakeJournalEntriesHeaderFields.js b/src/containers/Accounting/MakeJournal/MakeJournalEntriesHeaderFields.js
index 148eba972..448ef9b67 100644
--- a/src/containers/Accounting/MakeJournal/MakeJournalEntriesHeaderFields.js
+++ b/src/containers/Accounting/MakeJournal/MakeJournalEntriesHeaderFields.js
@@ -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,
diff --git a/src/containers/Accounting/MakeJournal/utils.js b/src/containers/Accounting/MakeJournal/utils.js
index 3428b11ea..6ad3ff87f 100644
--- a/src/containers/Accounting/MakeJournal/utils.js
+++ b/src/containers/Accounting/MakeJournal/utils.js
@@ -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: '',
diff --git a/src/containers/Dialogs/JournalNumberDialog/JournalNumberDialogContent.js b/src/containers/Dialogs/JournalNumberDialog/JournalNumberDialogContent.js
index 6a7b4e6b9..fe4902065 100644
--- a/src/containers/Dialogs/JournalNumberDialog/JournalNumberDialogContent.js
+++ b/src/containers/Dialogs/JournalNumberDialog/JournalNumberDialogContent.js
@@ -1,4 +1,5 @@
import React, { useCallback } from 'react';
+import intl from 'react-intl-universal';
import { DialogContent } from 'components';
import { useSaveSettings, useSettingsManualJournals } from 'hooks/query';
@@ -12,7 +13,7 @@ import {
transformSettingsToForm,
} from 'containers/JournalNumber/utils';
-import 'style/pages/ManualJournal/JournalNumberDialog.scss'
+import 'style/pages/ManualJournal/JournalNumberDialog.scss';
/**
* Journal number dialog's content.
@@ -28,16 +29,14 @@ function JournalNumberDialogContent({
// #ownProps
onConfirm,
- initialValues
+ initialValues,
}) {
const { isLoading: isSettingsLoading } = useSettingsManualJournals();
const { mutateAsync: saveSettingsMutate } = useSaveSettings();
+ const [referenceFormValues, setReferenceFormValues] = React.useState(null);
- // Handle the form submit.
+ // Handle the form submit.
const handleSubmitForm = (values, { setSubmitting }) => {
- // Transformes the form values to settings to save it.
- const options = transformFormToSettings(values, 'manual_journals');
-
// Handle success.
const handleSuccess = () => {
setSubmitting(false);
@@ -52,6 +51,9 @@ function JournalNumberDialogContent({
handleSuccess();
return;
}
+ // Transformes the form values to settings to save it.
+ const options = transformFormToSettings(values, 'manual_journals');
+
saveSettingsMutate({ options }).then(handleSuccess).catch(handleErrors);
};
@@ -59,6 +61,17 @@ function JournalNumberDialogContent({
closeDialog('journal-number-form');
}, [closeDialog]);
+ // Handle form change.
+ const handleChange = (values) => {
+ setReferenceFormValues(values);
+ };
+
+ // Description.
+ const description =
+ referenceFormValues?.incrementMode === 'auto'
+ ? intl.get('manual_journals.auto_increment.auto')
+ : intl.get('manual_journals.auto_increment.manually');
+
return (
);
@@ -84,4 +99,4 @@ export default compose(
numberPrefix: manualJournalsSettings?.numberPrefix,
autoIncrement: manualJournalsSettings?.autoIncrement,
})),
-)(JournalNumberDialogContent);
\ No newline at end of file
+)(JournalNumberDialogContent);
diff --git a/src/lang/ar/index.json b/src/lang/ar/index.json
index 38a065316..1419a417f 100644
--- a/src/lang/ar/index.json
+++ b/src/lang/ar/index.json
@@ -1361,6 +1361,8 @@
"item_entries.landed.hint": "يتيح لك هذه الخيار إمكانية إضافة تكلفة اضافية علي فاتورة الشراء متال علي ذلك تكاليف الشحن ، ثم تحديد هذه التكلفة لتحميلها علي فاتورة الشراء.",
"invoice.auto_increment.auto": "يتم تعيين أرقام الفواتير على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟",
"invoice.auto_increment.manually": "يتم تعيين أرقام فواتيرك يدوياً. هل أنت متأكد من تغيير هذه الإعدادات؟",
+ "manual_journals.auto_increment.auto": "يتم تعيين أرقام القيود على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟",
+ "manual_journals.auto_increment.manually": "يتم تعيين أرقام القيود يدوياً. هل أنت متأكد من تغيير هذه الإعدادات؟",
"estimate.auto_increment.auto": "يتم تعيين أرقام العروض على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟",
"estimate.auto_increment.manually": "يتم تعيين أرقام عروض الاسعار يدوياً. هل أنت متأكد من تغيير هذه الإعدادات؟",
"receipt.auto_increment.auto": "يتم تعيين أرقام إيصالات على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟",
diff --git a/src/lang/en/index.json b/src/lang/en/index.json
index fba99b819..7dea2b787 100644
--- a/src/lang/en/index.json
+++ b/src/lang/en/index.json
@@ -1339,13 +1339,15 @@
"item_entries.products_services.hint": "Enter products or services you sell or buy to keep tracking what your sold or purchased.",
"item_entries.landed.hint": "This options allows you to be able to add additional cost eg. freight then allocate cost to the items in your bills.",
"invoice.auto_increment.auto": "Your invoice numbers are set on auto-increment mode. Are you sure changing this setting?",
- "invoice.auto_increment.manually": "Yor invoice numbers are set on manual mode. Are you sure chaning this settings?",
+ "invoice.auto_increment.manually": "Your invoice numbers are set on manual mode. Are you sure chaning this settings?",
+ "manual_journals.auto_increment.auto": "Your Jouranl numbers are set on auto-increment mode. Are you sure changing this setting?",
+ "manual_journals.auto_increment.manually": "Your Journal numbers are set on manual mode. Are you sure chaning this settings?",
"estimate.auto_increment.auto": "Your estimate numbers are set on auto-increment mode. Are you sure changing this setting?",
- "estimate.auto_increment.manually": "Yor estimate numbers are set on manual mode. Are you sure chaning this settings?",
+ "estimate.auto_increment.manually": "Your estimate numbers are set on manual mode. Are you sure chaning this settings?",
"receipt.auto_increment.auto": "Your receipt numbers are set on auto-increment mode. Are you sure changing this setting?",
- "receipt.auto_increment.manually": "Yor receipt numbers are set on manual mode. Are you sure chaning this settings?",
+ "receipt.auto_increment.manually": "Your receipt numbers are set on manual mode. Are you sure chaning this settings?",
"payment_receive.auto_increment.auto": "Your payment numbers are set on auto-increment mode. Are you sure changing this setting?",
- "payment_receive.auto_increment.manually": "Yor payment numbers are set on manual mode. Are you sure chaning this settings?",
+ "payment_receive.auto_increment.manually": "Your payment numbers are set on manual mode. Are you sure chaning this settings?",
"auto_increment.field.manually": "I will enter them manually each time",
"auto_increment.field.manual_this_transaction": "Manual entering for this transaction.",
"auto_increment.field.auto": "Auto-incrementing number.",