From e1980d26987deb37892802c553d2971e80e44721 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Sat, 14 Nov 2020 14:02:04 +0200 Subject: [PATCH 1/9] Fix: translate item form fields --- client/src/containers/Items/ItemForm.js | 6 ++++-- client/src/lang/en/index.js | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/src/containers/Items/ItemForm.js b/client/src/containers/Items/ItemForm.js index 322df8080..97fd4a492 100644 --- a/client/src/containers/Items/ItemForm.js +++ b/client/src/containers/Items/ItemForm.js @@ -89,12 +89,14 @@ function ItemForm({ sku: Yup.string().trim(), cost_price: Yup.number().when(['purchasable'], { is: true, - then: Yup.number().required(), + then: Yup.number().required() + .label(formatMessage({ id: 'cost_price_' })), otherwise: Yup.number().nullable(true), }), sell_price: Yup.number().when(['sellable'], { is: true, - then: Yup.number().required(), + then: Yup.number().required() + .label(formatMessage({ id: 'sell_price_' })), otherwise: Yup.number().nullable(true), }), cost_account_id: Yup.number() diff --git a/client/src/lang/en/index.js b/client/src/lang/en/index.js index ac1620d2e..3db4b3599 100644 --- a/client/src/lang/en/index.js +++ b/client/src/lang/en/index.js @@ -107,6 +107,8 @@ export default { draft: 'Draft', published: 'Published', new_item: 'New Item', + cost_price_: 'Cost price', + sell_price_: 'Sell price', table_views: 'Table Views', delete: 'Delete', delete_count: 'Delete ({count})', From dcd5988a8ed029470f134485b39f7eb0e761fb07 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Sat, 14 Nov 2020 14:13:32 +0200 Subject: [PATCH 2/9] fix: initial values numeric fields for account form --- .../Dialogs/AccountFormDialog/AccountFormDialogContent.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/containers/Dialogs/AccountFormDialog/AccountFormDialogContent.js b/client/src/containers/Dialogs/AccountFormDialog/AccountFormDialogContent.js index d00d7defe..f23a17af5 100644 --- a/client/src/containers/Dialogs/AccountFormDialog/AccountFormDialogContent.js +++ b/client/src/containers/Dialogs/AccountFormDialog/AccountFormDialogContent.js @@ -68,7 +68,7 @@ function AccountFormDialogContent({ .max(255) .label(formatMessage({ id: 'account_name_' })), code: Yup.string().digits().min(3).max(6), - account_type_id: Yup.number() + account_type_id: Yup.number().nullable() .required() .label(formatMessage({ id: 'account_type_id' })), description: Yup.string().min(3).max(512).nullable().trim(), @@ -76,7 +76,7 @@ function AccountFormDialogContent({ }); const initialValues = useMemo( () => ({ - account_type_id: null, + account_type_id: '', name: '', code: '', description: '', From b3dbc0d3b9f05224293ad386e4bef703ef9bf281 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Sat, 14 Nov 2020 14:30:52 +0200 Subject: [PATCH 3/9] fix : cancel button in item Category dialog. --- .../Dialogs/ItemCategoryDialog/ItemCategoryForm.js | 3 ++- .../ItemCategoryDialog/ItemCategoryFormDialogContent.js | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/client/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryForm.js b/client/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryForm.js index a95c0ae29..82ef2ec21 100644 --- a/client/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryForm.js +++ b/client/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryForm.js @@ -24,6 +24,7 @@ export default function ItemCategoryForm({ accountsList, categoriesList, isSubmitting, + onClose }) { // Filters Item Categories list. const filterItemCategories = useCallback( @@ -203,7 +204,7 @@ export default function ItemCategoryForm({
- {/*----------- Active ----------*/} - + {({ field, field: { value } }) => ( Date: Sun, 15 Nov 2020 19:03:26 +0200 Subject: [PATCH 9/9] fix :default currency in make journal form. --- .../Accounting/MakeJournalEntriesForm.js | 5 ++- .../Accounting/MakeJournalEntriesHeader.js | 45 +++++++++++++++++-- .../Accounting/MakeJournalEntriesPage.js | 15 +++++-- 3 files changed, 56 insertions(+), 9 deletions(-) diff --git a/client/src/containers/Accounting/MakeJournalEntriesForm.js b/client/src/containers/Accounting/MakeJournalEntriesForm.js index aa8f86fe8..dec6f8304 100644 --- a/client/src/containers/Accounting/MakeJournalEntriesForm.js +++ b/client/src/containers/Accounting/MakeJournalEntriesForm.js @@ -126,6 +126,7 @@ function MakeJournalEntriesForm({ date: Yup.date() .required() .label(formatMessage({ id: 'date' })), + currency_code: Yup.string(), reference: Yup.string().min(1).max(255), description: Yup.string().min(1).max(1024), entries: Yup.array().of( @@ -172,6 +173,7 @@ function MakeJournalEntriesForm({ date: moment(new Date()).format('YYYY-MM-DD'), description: '', reference: '', + currency_code: '', entries: [...repeatValue(defaultEntry, 4)], }), [defaultEntry, journalNumber], @@ -442,11 +444,12 @@ function MakeJournalEntriesForm({ }, [changePageSubtitle], ); - + console.log(values, 'Val'); return (
{ const formatted = moment(date).format('YYYY-MM-DD'); @@ -57,6 +68,19 @@ function MakeJournalEntriesHeader({ saveInvoke(onJournalNumberChanged, event.currentTarget.value); }; + const onItemsSelect = useCallback( + (filedName) => { + return (filed) => { + setSelectedItems({ + ...selectedItems, + [filedName]: filed, + }); + setFieldValue(filedName, filed.currency_code); + }; + }, + [setFieldValue, selectedItems], + ); + return (
@@ -197,7 +221,12 @@ function MakeJournalEntriesHeader({ CLASSES.FILL, )} > - + @@ -205,4 +234,12 @@ function MakeJournalEntriesHeader({ ); } -export default compose(withDialogActions)(MakeJournalEntriesHeader); +export default compose( + withDialogActions, + withSettings(({ organizationSettings }) => ({ + baseCurrency: organizationSettings?.baseCurrency, + })), + withCurrencies(({ currenciesList }) => ({ + currenciesList, + })), +)(MakeJournalEntriesHeader); diff --git a/client/src/containers/Accounting/MakeJournalEntriesPage.js b/client/src/containers/Accounting/MakeJournalEntriesPage.js index 5faeb3317..387d0d301 100644 --- a/client/src/containers/Accounting/MakeJournalEntriesPage.js +++ b/client/src/containers/Accounting/MakeJournalEntriesPage.js @@ -8,6 +8,7 @@ import DashboardInsider from 'components/Dashboard/DashboardInsider'; import withCustomersActions from 'containers/Customers/withCustomersActions'; import withAccountsActions from 'containers/Accounts/withAccountsActions'; import withManualJournalsActions from 'containers/Accounting/withManualJournalsActions'; +import withCurrenciesActions from 'containers/Currencies/withCurrenciesActions'; import withSettingsActions from 'containers/Settings/withSettingsActions'; import { compose } from 'utils'; @@ -22,6 +23,9 @@ function MakeJournalEntriesPage({ // #withManualJournalActions requestFetchManualJournal, + // #wihtCurrenciesActions + requestFetchCurrencies, + // #withSettingsActions requestFetchOptions, }) { @@ -36,11 +40,12 @@ function MakeJournalEntriesPage({ requestFetchCustomers(), ); - const fetchSettings = useQuery( - ['settings'], - () => requestFetchOptions({}), + const fetchCurrencies = useQuery('currencies', () => + requestFetchCurrencies(), ); + const fetchSettings = useQuery(['settings'], () => requestFetchOptions({})); + const fetchJournal = useQuery( ['manual-journal', id], (key, journalId) => requestFetchManualJournal(journalId), @@ -63,6 +68,7 @@ function MakeJournalEntriesPage({ loading={ fetchJournal.isFetching || fetchAccounts.isFetching || + fetchCurrencies.isFetching || fetchCustomers.isFetching } name={'make-journal-page'} @@ -80,5 +86,6 @@ export default compose( withAccountsActions, withCustomersActions, withManualJournalsActions, - withSettingsActions + withCurrenciesActions, + withSettingsActions, )(MakeJournalEntriesPage);