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); 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: '', diff --git a/client/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryForm.js b/client/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryForm.js index a95c0ae29..9bc21b0a0 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( @@ -73,7 +74,7 @@ export default function ItemCategoryForm({ {/* ----------- Parent Category ----------- */} - + {({ form, field: { value }, meta: { error, touched } }) => ( } @@ -106,7 +107,7 @@ export default function ItemCategoryForm({ {/* ----------- Description ----------- */} - + {({ field, field: { value }, meta: { error, touched } }) => ( } @@ -137,7 +138,7 @@ export default function ItemCategoryForm({ { - form.setFieldValue(account.id); + form.setFieldValue('cost_account_id', account.id); }} defaultSelectText={} selectedAccountId={value} @@ -203,7 +204,7 @@ export default function ItemCategoryForm({
- {/*----------- Active ----------*/} - + {({ field, field: { value } }) => ( } value="service" /> - } value="inventory" /> } value="non-inventory" /> + } value="inventory" /> )} @@ -179,5 +180,5 @@ export default compose( withItemCategories(({ categoriesList }) => ({ categoriesList, })), - withDashboardActions + withDashboardActions, )(ItemFormPrimarySection); diff --git a/client/src/containers/Purchases/Bill/BillForm.schema.js b/client/src/containers/Purchases/Bill/BillForm.schema.js index 2bffd5e94..1b3af549d 100644 --- a/client/src/containers/Purchases/Bill/BillForm.schema.js +++ b/client/src/containers/Purchases/Bill/BillForm.schema.js @@ -12,7 +12,6 @@ const BillFormSchema = Yup.object().shape({ .required() .label(formatMessage({ id: 'due_date_' })), bill_number: Yup.string() - .required() .label(formatMessage({ id: 'bill_number_' })), reference_no: Yup.string().nullable().min(1).max(255), note: Yup.string() diff --git a/client/src/containers/Sales/Estimate/EstimateForm.schema.js b/client/src/containers/Sales/Estimate/EstimateForm.schema.js index 74db33fc5..e72697a1f 100644 --- a/client/src/containers/Sales/Estimate/EstimateForm.schema.js +++ b/client/src/containers/Sales/Estimate/EstimateForm.schema.js @@ -12,10 +12,9 @@ const Schema = Yup.object().shape({ .required() .label(formatMessage({ id: 'expiration_date_' })), estimate_number: Yup.string() - .required() .nullable() .label(formatMessage({ id: 'estimate_number_' })), - reference: Yup.string().min(1).max(255), + reference: Yup.string().min(1).max(255).nullable(), note: Yup.string() .trim() .min(1) diff --git a/client/src/containers/Sales/Invoice/InvoiceForm.schema.js b/client/src/containers/Sales/Invoice/InvoiceForm.schema.js index d8e44b2d7..8a74ac522 100644 --- a/client/src/containers/Sales/Invoice/InvoiceForm.schema.js +++ b/client/src/containers/Sales/Invoice/InvoiceForm.schema.js @@ -11,7 +11,8 @@ const Schema = Yup.object().shape({ due_date: Yup.date() .required() .label(formatMessage({ id: 'due_date_' })), - invoice_no: Yup.string().label(formatMessage({ id: 'invoice_no_' })), + invoice_no: Yup.string() + .label(formatMessage({ id: 'invoice_no_' })), reference_no: Yup.string().min(1).max(255), status: Yup.string().required(), invoice_message: Yup.string() diff --git a/client/src/containers/Sales/Receipt/ReceiptForm.schema.js b/client/src/containers/Sales/Receipt/ReceiptForm.schema.js index a60536df4..17551830e 100644 --- a/client/src/containers/Sales/Receipt/ReceiptForm.schema.js +++ b/client/src/containers/Sales/Receipt/ReceiptForm.schema.js @@ -9,7 +9,6 @@ const Schema = Yup.object().shape({ .required() .label(formatMessage({ id: 'receipt_date_' })), receipt_number: Yup.string() - .required() .label(formatMessage({ id: 'receipt_no_' })), deposit_account_id: Yup.number() .required() 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})',