From 27670d51ed4127a6fc7caf2e60d3bdb1a550ef5e Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Sun, 21 Mar 2021 18:20:48 +0200 Subject: [PATCH 1/6] fix(vendor): catch error message. --- .../Alerts/Vendors/VendorDeleteAlert.js | 19 +++++++++++-------- client/src/containers/Vendors/utils.js | 15 +++++++++++++++ client/src/lang/en/index.js | 1 + 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 client/src/containers/Vendors/utils.js diff --git a/client/src/containers/Alerts/Vendors/VendorDeleteAlert.js b/client/src/containers/Alerts/Vendors/VendorDeleteAlert.js index dfca9a55c..cf73a3616 100644 --- a/client/src/containers/Alerts/Vendors/VendorDeleteAlert.js +++ b/client/src/containers/Alerts/Vendors/VendorDeleteAlert.js @@ -6,7 +6,7 @@ import { } from 'react-intl'; import { Intent, Alert } from '@blueprintjs/core'; import { AppToaster } from 'components'; -import { transformErrors } from 'containers/Customers/utils'; +import { transformErrors } from 'containers/Vendors/utils'; import { useDeleteVendor } from 'hooks/query'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; @@ -28,10 +28,7 @@ function VendorDeleteAlert({ closeAlert, }) { const { formatMessage } = useIntl(); - const { - mutateAsync: deleteVendorMutate, - isLoading - } = useDeleteVendor(); + const { mutateAsync: deleteVendorMutate, isLoading } = useDeleteVendor(); // Handle cancel delete the vendor. const handleCancelDeleteAlert = () => { @@ -49,9 +46,15 @@ function VendorDeleteAlert({ intent: Intent.SUCCESS, }); }) - .catch((errors) => { - transformErrors(errors); - }) + .catch( + ({ + response: { + data: { errors }, + }, + }) => { + transformErrors(errors); + }, + ) .finally(() => { closeAlert(name); }); diff --git a/client/src/containers/Vendors/utils.js b/client/src/containers/Vendors/utils.js new file mode 100644 index 000000000..4d4d322e8 --- /dev/null +++ b/client/src/containers/Vendors/utils.js @@ -0,0 +1,15 @@ +import React from 'react'; +import { Intent } from '@blueprintjs/core'; +import { AppToaster } from 'components'; +import { formatMessage } from 'services/intl'; + +export const transformErrors = (errors) => { + if (errors.find((error) => error.type === 'VENDOR.HAS.ASSOCIATED.BILLS')) { + AppToaster.show({ + message: formatMessage({ + id: 'cannot_delete_vendor_that_has_associated_purchase_bills', + }), + intent: Intent.DANGER, + }); + } +}; diff --git a/client/src/lang/en/index.js b/client/src/lang/en/index.js index 4b15e129a..e83cbe24b 100644 --- a/client/src/lang/en/index.js +++ b/client/src/lang/en/index.js @@ -1020,4 +1020,5 @@ export default { cannot_change_item_type_to_inventory_with_item_has_associated_transactions: 'Cannot change item type to inventory with item has associated transactions.', work_phone: 'Work Phone', + cannot_delete_vendor_that_has_associated_purchase_bills:'Cannot delete vendor that has associated purchase bills.' }; From 09c295f62c6a8c82b3f7e56764c5c1a29a646480 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Mon, 22 Mar 2021 17:21:33 +0200 Subject: [PATCH 2/6] feat(accoutant) : accountant preference. --- .../Accountant/Accountant.schema.js | 6 +- .../Preferences/Accountant/AccountantForm.js | 114 +++++++++++++----- .../Accountant/AccountantFormPage.js | 76 ++++++++++-- .../Preferences/Accountant/utils.js | 37 ++++++ .../style/pages/Preferences/Accounting.scss | 21 ++-- client/src/utils.js | 5 +- 6 files changed, 213 insertions(+), 46 deletions(-) create mode 100644 client/src/containers/Preferences/Accountant/utils.js diff --git a/client/src/containers/Preferences/Accountant/Accountant.schema.js b/client/src/containers/Preferences/Accountant/Accountant.schema.js index 699c6bf0a..9e8cb63e8 100644 --- a/client/src/containers/Preferences/Accountant/Accountant.schema.js +++ b/client/src/containers/Preferences/Accountant/Accountant.schema.js @@ -3,8 +3,10 @@ import * as Yup from 'yup'; const Schema = Yup.object().shape({ accounting_basis: Yup.string().required(), account_code_required: Yup.boolean(), - customer_deposit_account: Yup.number().nullable(), - vendor_withdrawal_account: Yup.number().nullable(), + account_code_unique: Yup.boolean(), + deposit_account: Yup.number().nullable(), + withdrawal_account: Yup.number().nullable(), + advance_deposit: Yup.number().nullable(), }); export const AccountantSchema = Schema; \ No newline at end of file diff --git a/client/src/containers/Preferences/Accountant/AccountantForm.js b/client/src/containers/Preferences/Accountant/AccountantForm.js index 492f2b300..bdb8f28eb 100644 --- a/client/src/containers/Preferences/Accountant/AccountantForm.js +++ b/client/src/containers/Preferences/Accountant/AccountantForm.js @@ -1,5 +1,5 @@ import React from 'react'; -import { Form, FastField, Field } from 'formik'; +import { Form, FastField, useFormikContext } from 'formik'; import { FormGroup, RadioGroup, @@ -9,20 +9,20 @@ import { Intent, } from '@blueprintjs/core'; import { useHistory } from 'react-router-dom'; -import { AccountsSelectList } from 'components'; -import { FieldRequiredHint } from 'components'; +import { AccountsSelectList, FieldRequiredHint } from 'components'; import { FormattedMessage as T, useIntl } from 'react-intl'; -// import { } from 'common/accountTypes'; -import { handleStringChange, saveInvoke } from 'utils'; +import { ACCOUNT_PARENT_TYPE } from 'common/accountTypes'; +import { handleStringChange, inputIntent } from 'utils'; import { useAccountantFormContext } from './AccountantFormProvider'; - - export default function AccountantForm() { const history = useHistory(); + const { formatMessage } = useIntl(); + const { isSubmitting } = useFormikContext(); + const handleCloseClick = () => { history.go(-1); }; @@ -38,26 +38,60 @@ export default function AccountantForm() { } + className={'accounts-checkbox'} > - - + {/*------------ account code required -----------*/} + + {({ field }) => ( + + + + )} + + {/*------------ account code unique -----------*/} + + {({ field }) => ( + + + + )} + {/* ----------- Accounting basis ----------- */} - {({ form, field: { value }, meta: { error, touched } }) => ( + {({ + form: { setFieldValue }, + field: { value }, + meta: { error, touched }, + }) => ( } + intent={inputIntent({ error, touched })} label={ } > - + { + setFieldValue('accounting_basis', _value); + })} + > @@ -66,8 +100,12 @@ export default function AccountantForm() { {/* ----------- Deposit customer account ----------- */} - - {({ form, field: { value }, meta: { error, touched } }) => ( + + {({ + form: { values, setFieldValue }, + field: { value }, + meta: { error, touched }, + }) => ( @@ -78,20 +116,28 @@ export default function AccountantForm() { 'Select a preferred account to deposit into it after customer make payment.' } labelInfo={} + intent={inputIntent({ error, touched })} > { + setFieldValue('deposit_account', id); + }} + selectedAccountId={value} defaultSelectText={} - // filterByTypes={['current_asset']} + // filterByParentTypes={[ACCOUNT_PARENT_TYPE.CURRENT_ASSET]} /> )} - {/* ----------- Withdrawal customer account ----------- */} - - {({ form, field: { value }, meta: { error, touched } }) => ( + {/* ----------- Withdrawal vendor account ----------- */} + + {({ + form: { values, setFieldValue }, + field: { value }, + meta: { error, touched }, + }) => ( @@ -102,19 +148,27 @@ export default function AccountantForm() { 'Select a preferred account to deposit into it after customer make payment.' } labelInfo={} + intent={inputIntent({ error, touched })} > { + setFieldValue('withdrawal_account', id); + }} + selectedAccountId={value} defaultSelectText={} - // filterByTypes={['current_asset']} /> )} {/* ----------- Withdrawal customer account ----------- */} - - {({ form, field: { value }, meta: { error, touched } }) => ( + + {({ + form: { values, setFieldValue }, + field: { value }, + meta: { error, touched }, + }) => ( @@ -125,17 +179,23 @@ export default function AccountantForm() { 'Select a preferred account to deposit into it vendor advanced deposits.' } labelInfo={} + intent={inputIntent({ error, touched })} > { + setFieldValue('advance_deposit', id); + }} + selectedAccountId={value} defaultSelectText={} - // filterByTypes={['current_asset', 'other_current_asset']} + // filterByParentTypes={[ACCOUNT_PARENT_TYPE.CURRENT_ASSET]} /> )} +
- + +
+ + ); +} diff --git a/client/src/containers/Preferences/Item/ItemFormPage.js b/client/src/containers/Preferences/Item/ItemFormPage.js new file mode 100644 index 000000000..e9bbdcfc2 --- /dev/null +++ b/client/src/containers/Preferences/Item/ItemFormPage.js @@ -0,0 +1,79 @@ +import React, { useEffect } from 'react'; +import { Formik } from 'formik'; +import { Intent } from '@blueprintjs/core'; +import classNames from 'classnames'; +import { CLASSES } from 'common/classes'; +import { AppToaster } from 'components'; +import { useIntl } from 'react-intl'; +import { ItemPreferencesSchema } from './Item.schema'; +import ItemForm from './ItemForm'; + +import { useItemFormContext } from './ItemFormProvider'; +import withDashboardActions from 'containers/Dashboard/withDashboardActions'; +import withSettings from 'containers/Settings/withSettings'; +import { compose, optionsMapToArray, transformGeneralSettings } from 'utils'; + +import 'style/pages/Preferences/Accounting.scss'; + +// item form page preferences. +function ItemFormPage({ + // #withSettings + itemsSettings, + //# withDashboardActions + changePreferencesPageTitle, +}) { + const { formatMessage } = useIntl(); + const { saveSettingMutate } = useItemFormContext(); + + const initialValues = { + ...transformGeneralSettings(itemsSettings), + }; + + useEffect(() => { + changePreferencesPageTitle(formatMessage({ id: 'items' })); + }, [changePreferencesPageTitle]); + + const handleFormSubmit = (values, { setSubmitting, setErrors }) => { + const options = optionsMapToArray(values).map((option) => { + return { key: option.key, ...option, group: 'items' }; + }); + + const onSuccess = () => { + AppToaster.show({ + message: formatMessage({ + id: 'the_items_preferences_has_been_saved', + }), + intent: Intent.SUCCESS, + }); + setSubmitting(false); + }; + + const onError = (errors) => { + setSubmitting(false); + }; + saveSettingMutate({ options }).then(onSuccess).catch(onError); + }; + + return ( +
+
+ +
+
+ ); +} + +export default compose( + withSettings(({ itemsSettings }) => ({ itemsSettings })), + withDashboardActions, +)(ItemFormPage); diff --git a/client/src/containers/Preferences/Item/ItemFormProvider.js b/client/src/containers/Preferences/Item/ItemFormProvider.js new file mode 100644 index 000000000..a70f27c1a --- /dev/null +++ b/client/src/containers/Preferences/Item/ItemFormProvider.js @@ -0,0 +1,34 @@ +import React, { useContext, createContext } from 'react'; +import { LoadingIndicator } from 'components'; + +import { useAccounts, useSaveSettings } from 'hooks/query'; + +const ItemFormContext = createContext(); + +/** + * Item data provider. + */ + +function ItemFormProvider({ ...props }) { + // Fetches the accounts list. + const { isLoading: isAccountsLoading, data: accounts } = useAccounts(); + + // Save Organization Settings. + const { mutateAsync: saveSettingMutate } = useSaveSettings(); + + // Provider state. + const provider = { + accounts, + saveSettingMutate, + }; + + return ( + + + + ); +} + +const useItemFormContext = () => useContext(ItemFormContext); + +export { useItemFormContext, ItemFormProvider }; diff --git a/client/src/containers/Settings/withSettings.js b/client/src/containers/Settings/withSettings.js index d775e9c43..04f104343 100644 --- a/client/src/containers/Settings/withSettings.js +++ b/client/src/containers/Settings/withSettings.js @@ -5,13 +5,14 @@ export default (mapState) => { const mapped = { organizationSettings: state.settings.data.organization, manualJournalsSettings: state.settings.data.manualJournals, - billsettings: state.settings.data.bills, + billPaymentSettings: state.settings.data.billPayments, paymentReceiveSettings: state.settings.data.paymentReceives, estimatesSettings: state.settings.data.salesEstimates, receiptSettings: state.settings.data.salesReceipts, invoiceSettings: state.settings.data.salesInvoices, itemsSettings: state.settings.data.items, expenseSettings: state.settings.data.expenses, + accountsSettings: state.settings.data.accounts, }; return mapState ? mapState(mapped, state, props) : mapped; }; diff --git a/client/src/routes/preferences.js b/client/src/routes/preferences.js index 4a3b88418..e66835ad5 100644 --- a/client/src/routes/preferences.js +++ b/client/src/routes/preferences.js @@ -3,6 +3,7 @@ import Users from 'containers/Preferences/Users/Users'; import Accountant from 'containers/Preferences/Accountant/Accountant'; import Accounts from 'containers/Preferences/Accounts/Accounts'; import Currencies from 'containers/Preferences/Currencies/Currencies'; +import Item from 'containers/Preferences/Item/Item'; const BASE_URL = '/preferences'; @@ -27,4 +28,9 @@ export default [ component: Accountant, exact: true, }, + { + path: `${BASE_URL}/items`, + component: Item, + exact: true, + }, ]; diff --git a/server/src/data/options.js b/server/src/data/options.js index 970742436..f9860b162 100644 --- a/server/src/data/options.js +++ b/server/src/data/options.js @@ -4,7 +4,7 @@ export default { type: "string", }, base_currency: { - type: 'string', + type: "string", }, industry: { type: "string", @@ -13,50 +13,50 @@ export default { type: "string", }, fiscal_year: { - type: 'string', + type: "string", }, financial_date_start: { - type: 'string', + type: "string", }, language: { - type: 'string', + type: "string", }, time_zone: { - type: 'string', + type: "string", }, date_format: { - type: 'string', + type: "string", }, accounting_basis: { - type: 'string', - } + type: "string", + }, }, manual_journals: { next_number: { - type: 'string', + type: "string", }, number_prefix: { - type: 'string', + type: "string", }, auto_increment: { - type: 'boolean', - } + type: "boolean", + }, }, bill_payments: { withdrawal_account: { - type: 'string' + type: "number", }, }, sales_estimates: { next_number: { - type: 'string', + type: "string", }, number_prefix: { - type: 'string', + type: "string", }, auto_increment: { type: "boolean", - } + }, }, sales_receipts: { next_number: { @@ -70,7 +70,7 @@ export default { }, preferred_deposit_account: { type: "number", - } + }, }, sales_invoices: { next_number: { @@ -91,37 +91,37 @@ export default { type: "string", }, auto_increment: { - type: 'boolean', + type: "boolean", }, deposit_account: { - type: 'number', + type: "number", }, advance_deposit: { - type: 'number', - } + type: "number", + }, }, items: { sell_account: { - type: 'number', + type: "number", }, cost_account: { - type: 'number', + type: "number", }, inventory_account: { - type: 'number', + type: "number", }, }, expenses: { preferred_payment_account: { type: "number", - } + }, }, accounts: { account_code_required: { - type: 'boolean', + type: "boolean", }, account_code_unique: { - type: 'boolean', - } - } + type: "boolean", + }, + }, }; From 40806668df8ce94c8920ca8a8a78cf8305954b75 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Mon, 22 Mar 2021 18:00:37 +0200 Subject: [PATCH 4/6] feat:(customer & vendr) : catch message error. --- client/src/containers/Customers/utils.js | 9 +++++++++ client/src/containers/Vendors/utils.js | 9 +++++++++ client/src/lang/en/index.js | 20 ++++++++++++++++---- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/client/src/containers/Customers/utils.js b/client/src/containers/Customers/utils.js index e766e18a5..38361f58f 100644 --- a/client/src/containers/Customers/utils.js +++ b/client/src/containers/Customers/utils.js @@ -22,4 +22,13 @@ export const transformErrors = (errors) => { intent: Intent.DANGER, }); } + if (errors.find((error) => error.type === 'CUSTOMER_HAS_TRANSACTIONS')) { + AppToaster.show({ + message: formatMessage({ + id: + 'this_customer_cannot_be_deleted_as_it_is_associated_with_transactions', + }), + intent: Intent.DANGER, + }); + } }; diff --git a/client/src/containers/Vendors/utils.js b/client/src/containers/Vendors/utils.js index 4d4d322e8..c95f91654 100644 --- a/client/src/containers/Vendors/utils.js +++ b/client/src/containers/Vendors/utils.js @@ -12,4 +12,13 @@ export const transformErrors = (errors) => { intent: Intent.DANGER, }); } + if (errors.find((error) => error.type === 'VENDOR_HAS_TRANSACTIONS')) { + AppToaster.show({ + message: formatMessage({ + id: + 'this_vendor_cannot_be_deleted_as_it_is_associated_with_transactions', + }), + intent: Intent.DANGER, + }); + } }; diff --git a/client/src/lang/en/index.js b/client/src/lang/en/index.js index 3f6d47ffc..a87f81eba 100644 --- a/client/src/lang/en/index.js +++ b/client/src/lang/en/index.js @@ -821,7 +821,8 @@ export default { average_rate: 'Average rate', the_name_used_before: 'The name is already used.', the_item_has_associated_transactions: 'The item has associated transactions.', - customer_has_sales_invoices: 'Cannot delete customer has associated sales invoices.', + customer_has_sales_invoices: + 'Cannot delete customer has associated sales invoices.', account_name_is_already_used: 'Account name is already used.', vendors: 'Vendors', vendor_email: 'Vendor Email', @@ -1013,12 +1014,23 @@ export default { 'The payment amount bigger than invoice due amount.', accounting_basis_: 'Accounting Basis', deposit_customer_account: 'Deposit customer account', - withdrawal_customer_account: 'Withdrawal customer account', - vendor_advance_deposit: 'Vendor advance deposit', + withdrawal_vendor_account: 'Withdrawal vendor account', + customer_advance_deposit: 'Customer advance deposit', cannot_delete_bill_that_has_payment_transactions: 'Cannot delete bill that has associated payment transactions.', cannot_change_item_type_to_inventory_with_item_has_associated_transactions: 'Cannot change item type to inventory with item has associated transactions.', work_phone: 'Work Phone', - cannot_delete_vendor_that_has_associated_purchase_bills:'Cannot delete vendor that has associated purchase bills.' + cannot_delete_vendor_that_has_associated_purchase_bills: + 'Cannot delete vendor that has associated purchase bills.', + the_accountant_preferences_has_been_saved: + 'The accountant preferences has been saved.', + the_items_preferences_has_been_saved: 'The items preferences has been saved.', + preferred_sell_account: 'Preferred sell account', + preferred_cost_account: 'Preferred cost account', + preferred_inventory_account: 'Preferred inventory account', + this_customer_cannot_be_deleted_as_it_is_associated_with_transactions: + 'This customer cannot be deleted as it is associated with transactions.', + this_vendor_cannot_be_deleted_as_it_is_associated_with_transactions: + 'This vendor cannot be deleted as it is associated with transactions.', }; From b4408f5f27588539ba8ae3403443278cf7f2e0f2 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Mon, 22 Mar 2021 18:01:51 +0200 Subject: [PATCH 5/6] fix:(item & paymemt receive & made) : preferred values. --- client/src/containers/Items/ItemForm.js | 17 +++++++---------- .../PaymentMades/PaymentForm/PaymentMadeForm.js | 9 +++++++-- .../PaymentReceiveForm/PaymentReceiveForm.js | 7 +++++-- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/client/src/containers/Items/ItemForm.js b/client/src/containers/Items/ItemForm.js index 16decaf0f..420f1f31a 100644 --- a/client/src/containers/Items/ItemForm.js +++ b/client/src/containers/Items/ItemForm.js @@ -67,7 +67,7 @@ function ItemForm({ const history = useHistory(); const { formatMessage } = useIntl(); - + /** * Initial values in create and edit mode. */ @@ -122,10 +122,9 @@ function ItemForm({ AppToaster.show({ message: formatMessage( { - id: - isNewMode - ? 'the_item_has_been_created_successfully' - : 'the_item_has_been_edited_successfully', + id: isNewMode + ? 'the_item_has_been_created_successfully' + : 'the_item_has_been_edited_successfully', }, { number: itemId, @@ -181,10 +180,8 @@ function ItemForm({ export default compose( withSettings(({ itemsSettings }) => ({ - preferredCostAccount: parseInt(itemsSettings?.preferredCostAccount), - preferredSellAccount: parseInt(itemsSettings?.preferredSellAccount), - preferredInventoryAccount: parseInt( - itemsSettings?.preferredInventoryAccount, - ), + preferredCostAccount: parseInt(itemsSettings?.costAccount), + preferredSellAccount: parseInt(itemsSettings?.sellAccount), + preferredInventoryAccount: parseInt(itemsSettings?.inventoryAccount), })), )(ItemForm); diff --git a/client/src/containers/Purchases/PaymentMades/PaymentForm/PaymentMadeForm.js b/client/src/containers/Purchases/PaymentMades/PaymentForm/PaymentMadeForm.js index 385b03214..4f6a938c1 100644 --- a/client/src/containers/Purchases/PaymentMades/PaymentForm/PaymentMadeForm.js +++ b/client/src/containers/Purchases/PaymentMades/PaymentForm/PaymentMadeForm.js @@ -2,7 +2,7 @@ import React, { useMemo } from 'react'; import { Formik, Form } from 'formik'; import { Intent } from '@blueprintjs/core'; import { useIntl } from 'react-intl'; -import { sumBy, pick } from 'lodash'; +import { sumBy, pick, defaultTo } from 'lodash'; import classNames from 'classnames'; import { useHistory } from 'react-router-dom'; @@ -26,7 +26,10 @@ import { defaultPaymentMade, transformToEditForm, ERRORS } from './utils'; /** * Payment made form component. */ -function PaymentMadeForm() { +function PaymentMadeForm({ + // #withSettings + preferredPaymentAccount, +}) { const history = useHistory(); const { formatMessage } = useIntl(); @@ -50,6 +53,7 @@ function PaymentMadeForm() { } : { ...defaultPaymentMade, + payment_account_id: defaultTo(preferredPaymentAccount), entries: orderingLinesIndexes(defaultPaymentMade.entries), }), }), @@ -156,5 +160,6 @@ export default compose( withSettings(({ billPaymentSettings }) => ({ paymentNextNumber: billPaymentSettings?.next_number, paymentNumberPrefix: billPaymentSettings?.number_prefix, + preferredPaymentAccount: parseInt(billPaymentSettings?.withdrawalAccount), })), )(PaymentMadeForm); diff --git a/client/src/containers/Sales/PaymentReceives/PaymentReceiveForm/PaymentReceiveForm.js b/client/src/containers/Sales/PaymentReceives/PaymentReceiveForm/PaymentReceiveForm.js index 10dc6c84e..de9e3bdb6 100644 --- a/client/src/containers/Sales/PaymentReceives/PaymentReceiveForm/PaymentReceiveForm.js +++ b/client/src/containers/Sales/PaymentReceives/PaymentReceiveForm/PaymentReceiveForm.js @@ -1,7 +1,7 @@ import React, { useMemo } from 'react'; import { Formik, Form } from 'formik'; import { useIntl } from 'react-intl'; -import { omit, sumBy, pick, isEmpty } from 'lodash'; +import { omit, sumBy, pick, isEmpty, defaultTo } from 'lodash'; import { Intent } from '@blueprintjs/core'; import classNames from 'classnames'; import { useHistory } from 'react-router-dom'; @@ -33,6 +33,7 @@ import { defaultPaymentReceive, transformToEditForm } from './utils'; */ function PaymentReceiveForm({ // #withSettings + preferredDepositAccount, paymentReceiveNextNumber, paymentReceiveNumberPrefix, paymentReceiveAutoIncrement, @@ -65,6 +66,7 @@ function PaymentReceiveForm({ ...defaultPaymentReceive, ...(paymentReceiveAutoIncrement && { payment_receive_no: nextPaymentNumber, + deposit_account_id: defaultTo(preferredDepositAccount, ''), }), }), }), @@ -161,7 +163,6 @@ function PaymentReceiveForm({ createPaymentReceiveMutate(form).then(onSaved).catch(onError); } }; - return (
({ + paymentReceiveSettings, paymentReceiveNextNumber: paymentReceiveSettings?.nextNumber, paymentReceiveNumberPrefix: paymentReceiveSettings?.numberPrefix, paymentReceiveAutoIncrement: paymentReceiveSettings?.autoIncrement, + preferredDepositAccount: paymentReceiveSettings?.depositAccount, })), )(PaymentReceiveForm); From 8a9c9cf4983b9b4d5c4e2e0ddddec69d6431a6c1 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Mon, 22 Mar 2021 19:12:17 +0200 Subject: [PATCH 6/6] fix(accountant) : accountant schema. --- .../containers/Preferences/Accountant/Accountant.schema.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/containers/Preferences/Accountant/Accountant.schema.js b/client/src/containers/Preferences/Accountant/Accountant.schema.js index 9e8cb63e8..0c029efa5 100644 --- a/client/src/containers/Preferences/Accountant/Accountant.schema.js +++ b/client/src/containers/Preferences/Accountant/Accountant.schema.js @@ -2,11 +2,11 @@ import * as Yup from 'yup'; const Schema = Yup.object().shape({ accounting_basis: Yup.string().required(), - account_code_required: Yup.boolean(), - account_code_unique: Yup.boolean(), + account_code_required: Yup.boolean().nullable(), + account_code_unique: Yup.boolean().nullable(), deposit_account: Yup.number().nullable(), withdrawal_account: Yup.number().nullable(), advance_deposit: Yup.number().nullable(), }); -export const AccountantSchema = Schema; \ No newline at end of file +export const AccountantSchema = Schema;