mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
feat: fix journal.
This commit is contained in:
@@ -21,7 +21,7 @@ export default function BranchSuggestField({
|
|||||||
...suggestProps
|
...suggestProps
|
||||||
}) {
|
}) {
|
||||||
const initialBranch = React.useMemo(
|
const initialBranch = React.useMemo(
|
||||||
() => branches.some((b) => b.id === initialBranchId),
|
() => branches.find((b) => b.id === initialBranchId),
|
||||||
[initialBranchId, branches],
|
[initialBranchId, branches],
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -29,6 +29,15 @@ export default function BranchSuggestField({
|
|||||||
initialBranch || null,
|
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
|
* @param {*} branch
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default function BranchesListFieldCell({
|
|||||||
}) {
|
}) {
|
||||||
const handleBranchSelected = React.useCallback(
|
const handleBranchSelected = React.useCallback(
|
||||||
(branch) => {
|
(branch) => {
|
||||||
updateData(index, 'brnach_id', branch.id);
|
updateData(index, 'branch_id', branch.id);
|
||||||
},
|
},
|
||||||
[updateData, index],
|
[updateData, index],
|
||||||
);
|
);
|
||||||
@@ -33,7 +33,7 @@ export default function BranchesListFieldCell({
|
|||||||
<BranchSuggestField
|
<BranchSuggestField
|
||||||
branches={branches}
|
branches={branches}
|
||||||
onBranchSelected={handleBranchSelected}
|
onBranchSelected={handleBranchSelected}
|
||||||
selectedBranchId={original?.contact_id}
|
selectedBranchId={original?.branch_id}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ function MakeJournalEntriesForm({
|
|||||||
journalNumberPrefix,
|
journalNumberPrefix,
|
||||||
journalNextNumber,
|
journalNextNumber,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Form initial values.
|
// Form initial values.
|
||||||
const initialValues = useMemo(
|
const initialValues = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
@@ -69,7 +70,7 @@ function MakeJournalEntriesForm({
|
|||||||
: {
|
: {
|
||||||
...defaultManualJournal,
|
...defaultManualJournal,
|
||||||
...(journalAutoIncrement && {
|
...(journalAutoIncrement && {
|
||||||
journal_number: defaultTo(journalNumber, ''),
|
journal_number: journalNumber,
|
||||||
}),
|
}),
|
||||||
currency_code: base_currency,
|
currency_code: base_currency,
|
||||||
}),
|
}),
|
||||||
@@ -187,7 +188,7 @@ function MakeJournalEntriesForm({
|
|||||||
export default compose(
|
export default compose(
|
||||||
withMediaActions,
|
withMediaActions,
|
||||||
withSettings(({ manualJournalsSettings }) => ({
|
withSettings(({ manualJournalsSettings }) => ({
|
||||||
journalNextNumber: parseInt(manualJournalsSettings?.nextNumber, 10),
|
journalNextNumber: manualJournalsSettings?.nextNumber,
|
||||||
journalNumberPrefix: manualJournalsSettings?.numberPrefix,
|
journalNumberPrefix: manualJournalsSettings?.numberPrefix,
|
||||||
journalAutoIncrement: manualJournalsSettings?.autoIncrement,
|
journalAutoIncrement: manualJournalsSettings?.autoIncrement,
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -62,14 +62,14 @@ function MakeJournalEntriesHeader({
|
|||||||
|
|
||||||
// Handle journal number change.
|
// Handle journal number change.
|
||||||
const handleJournalNumberChange = () => {
|
const handleJournalNumberChange = () => {
|
||||||
openDialog('journal-number-form', {});
|
openDialog('journal-number-form');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle journal number blur.
|
// Handle journal number blur.
|
||||||
const handleJournalNoBlur = (form, field) => (event) => {
|
const handleJournalNoBlur = (form, field) => (event) => {
|
||||||
const newValue = event.target.value;
|
const newValue = event.target.value;
|
||||||
|
|
||||||
if (field.value !== newValue) {
|
if (field.value !== newValue && journalAutoIncrement) {
|
||||||
openDialog('journal-number-form', {
|
openDialog('journal-number-form', {
|
||||||
initialFormValues: {
|
initialFormValues: {
|
||||||
manualTransactionNo: newValue,
|
manualTransactionNo: newValue,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export const defaultEntry = {
|
|||||||
|
|
||||||
export const defaultManualJournal = {
|
export const defaultManualJournal = {
|
||||||
journal_number: '',
|
journal_number: '',
|
||||||
|
journal_number_manually: false,
|
||||||
journal_type: 'Journal',
|
journal_type: 'Journal',
|
||||||
date: moment(new Date()).format('YYYY-MM-DD'),
|
date: moment(new Date()).format('YYYY-MM-DD'),
|
||||||
description: '',
|
description: '',
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
|
import intl from 'react-intl-universal';
|
||||||
import { DialogContent } from 'components';
|
import { DialogContent } from 'components';
|
||||||
import { useSaveSettings, useSettingsManualJournals } from 'hooks/query';
|
import { useSaveSettings, useSettingsManualJournals } from 'hooks/query';
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ import {
|
|||||||
transformSettingsToForm,
|
transformSettingsToForm,
|
||||||
} from 'containers/JournalNumber/utils';
|
} from 'containers/JournalNumber/utils';
|
||||||
|
|
||||||
import 'style/pages/ManualJournal/JournalNumberDialog.scss'
|
import 'style/pages/ManualJournal/JournalNumberDialog.scss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Journal number dialog's content.
|
* Journal number dialog's content.
|
||||||
@@ -28,16 +29,14 @@ function JournalNumberDialogContent({
|
|||||||
|
|
||||||
// #ownProps
|
// #ownProps
|
||||||
onConfirm,
|
onConfirm,
|
||||||
initialValues
|
initialValues,
|
||||||
}) {
|
}) {
|
||||||
const { isLoading: isSettingsLoading } = useSettingsManualJournals();
|
const { isLoading: isSettingsLoading } = useSettingsManualJournals();
|
||||||
const { mutateAsync: saveSettingsMutate } = useSaveSettings();
|
const { mutateAsync: saveSettingsMutate } = useSaveSettings();
|
||||||
|
const [referenceFormValues, setReferenceFormValues] = React.useState(null);
|
||||||
|
|
||||||
// Handle the form submit.
|
// Handle the form submit.
|
||||||
const handleSubmitForm = (values, { setSubmitting }) => {
|
const handleSubmitForm = (values, { setSubmitting }) => {
|
||||||
// Transformes the form values to settings to save it.
|
|
||||||
const options = transformFormToSettings(values, 'manual_journals');
|
|
||||||
|
|
||||||
// Handle success.
|
// Handle success.
|
||||||
const handleSuccess = () => {
|
const handleSuccess = () => {
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
@@ -52,6 +51,9 @@ function JournalNumberDialogContent({
|
|||||||
handleSuccess();
|
handleSuccess();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Transformes the form values to settings to save it.
|
||||||
|
const options = transformFormToSettings(values, 'manual_journals');
|
||||||
|
|
||||||
saveSettingsMutate({ options }).then(handleSuccess).catch(handleErrors);
|
saveSettingsMutate({ options }).then(handleSuccess).catch(handleErrors);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -59,6 +61,17 @@ function JournalNumberDialogContent({
|
|||||||
closeDialog('journal-number-form');
|
closeDialog('journal-number-form');
|
||||||
}, [closeDialog]);
|
}, [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 (
|
return (
|
||||||
<DialogContent isLoading={isSettingsLoading}>
|
<DialogContent isLoading={isSettingsLoading}>
|
||||||
<ReferenceNumberForm
|
<ReferenceNumberForm
|
||||||
@@ -71,7 +84,9 @@ function JournalNumberDialogContent({
|
|||||||
...initialValues,
|
...initialValues,
|
||||||
}}
|
}}
|
||||||
onSubmit={handleSubmitForm}
|
onSubmit={handleSubmitForm}
|
||||||
|
description={description}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
);
|
);
|
||||||
@@ -84,4 +99,4 @@ export default compose(
|
|||||||
numberPrefix: manualJournalsSettings?.numberPrefix,
|
numberPrefix: manualJournalsSettings?.numberPrefix,
|
||||||
autoIncrement: manualJournalsSettings?.autoIncrement,
|
autoIncrement: manualJournalsSettings?.autoIncrement,
|
||||||
})),
|
})),
|
||||||
)(JournalNumberDialogContent);
|
)(JournalNumberDialogContent);
|
||||||
|
|||||||
@@ -1361,6 +1361,8 @@
|
|||||||
"item_entries.landed.hint": "يتيح لك هذه الخيار إمكانية إضافة تكلفة اضافية علي فاتورة الشراء متال علي ذلك تكاليف الشحن ، ثم تحديد هذه التكلفة لتحميلها علي فاتورة الشراء.",
|
"item_entries.landed.hint": "يتيح لك هذه الخيار إمكانية إضافة تكلفة اضافية علي فاتورة الشراء متال علي ذلك تكاليف الشحن ، ثم تحديد هذه التكلفة لتحميلها علي فاتورة الشراء.",
|
||||||
"invoice.auto_increment.auto": "يتم تعيين أرقام الفواتير على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟",
|
"invoice.auto_increment.auto": "يتم تعيين أرقام الفواتير على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟",
|
||||||
"invoice.auto_increment.manually": "يتم تعيين أرقام فواتيرك يدوياً. هل أنت متأكد من تغيير هذه الإعدادات؟",
|
"invoice.auto_increment.manually": "يتم تعيين أرقام فواتيرك يدوياً. هل أنت متأكد من تغيير هذه الإعدادات؟",
|
||||||
|
"manual_journals.auto_increment.auto": "يتم تعيين أرقام القيود على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟",
|
||||||
|
"manual_journals.auto_increment.manually": "يتم تعيين أرقام القيود يدوياً. هل أنت متأكد من تغيير هذه الإعدادات؟",
|
||||||
"estimate.auto_increment.auto": "يتم تعيين أرقام العروض على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟",
|
"estimate.auto_increment.auto": "يتم تعيين أرقام العروض على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟",
|
||||||
"estimate.auto_increment.manually": "يتم تعيين أرقام عروض الاسعار يدوياً. هل أنت متأكد من تغيير هذه الإعدادات؟",
|
"estimate.auto_increment.manually": "يتم تعيين أرقام عروض الاسعار يدوياً. هل أنت متأكد من تغيير هذه الإعدادات؟",
|
||||||
"receipt.auto_increment.auto": "يتم تعيين أرقام إيصالات على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟",
|
"receipt.auto_increment.auto": "يتم تعيين أرقام إيصالات على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟",
|
||||||
|
|||||||
@@ -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.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.",
|
"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.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.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.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.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.manually": "I will enter them manually each time",
|
||||||
"auto_increment.field.manual_this_transaction": "Manual entering for this transaction.",
|
"auto_increment.field.manual_this_transaction": "Manual entering for this transaction.",
|
||||||
"auto_increment.field.auto": "Auto-incrementing number.",
|
"auto_increment.field.auto": "Auto-incrementing number.",
|
||||||
|
|||||||
Reference in New Issue
Block a user