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]} /> )} +
-