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]}
/>
)}
+
-
@@ -41,4 +86,19 @@ function AccountantFormPage({ changePreferencesPageTitle }) {
);
}
-export default compose(withDashboardActions)(AccountantFormPage);
+export default compose(
+ withSettings(
+ ({
+ organizationSettings,
+ paymentReceiveSettings,
+ accountsSettings,
+ billPaymentSettings,
+ }) => ({
+ organizationSettings,
+ paymentReceiveSettings,
+ accountsSettings,
+ billPaymentSettings,
+ }),
+ ),
+ withDashboardActions,
+)(AccountantFormPage);
diff --git a/client/src/containers/Preferences/Accountant/utils.js b/client/src/containers/Preferences/Accountant/utils.js
new file mode 100644
index 000000000..22f838ba4
--- /dev/null
+++ b/client/src/containers/Preferences/Accountant/utils.js
@@ -0,0 +1,37 @@
+export const transformToOptions = (option) => {
+ return [
+ {
+ key: 'accounting_basis',
+ value: option.accounting_basis,
+ group: 'organization',
+ },
+ {
+ key: 'withdrawal_account',
+ value: option.withdrawal_account,
+ group: 'bill_payments',
+ },
+ {
+ key: 'deposit_account',
+ value: option.deposit_account,
+ group: 'payment_receives',
+ },
+ {
+ key: 'advance_deposit',
+ value: option.advance_deposit,
+ group: 'payment_receives',
+ },
+ {
+ key: 'account_code_required',
+ value: option.account_code_required,
+ group: 'accounts',
+ },
+ {
+
+ key: 'account_code_unique',
+ value: option.account_code_unique,
+ group: 'accounts',
+ },
+ ];
+};
+
+
diff --git a/client/src/style/pages/Preferences/Accounting.scss b/client/src/style/pages/Preferences/Accounting.scss
index ae6e1ef1d..1b38e4db3 100644
--- a/client/src/style/pages/Preferences/Accounting.scss
+++ b/client/src/style/pages/Preferences/Accounting.scss
@@ -1,4 +1,3 @@
-
// Accountant.
// ---------------------------------
.preferences-page__inside-content--accountant {
@@ -13,22 +12,20 @@
.bp3-button {
min-width: 60px;
- + .bp3-button{
+ + .bp3-button {
margin-left: 10px;
}
}
}
}
- .form-group--select-list{
-
- button{
+ .form-group--select-list {
+ button {
min-width: 250px;
}
}
.bp3-form-group {
-
- .bp3-form-helper-text{
+ .bp3-form-helper-text {
margin-top: 7px;
}
@@ -36,4 +33,12 @@
margin-bottom: 7px;
}
}
-}
\ No newline at end of file
+ .bp3-form-group.accounts-checkbox {
+ .bp3-form-group.bp3-inline {
+ margin-bottom: 7px;
+ }
+ .bp3-control.bp3-inline {
+ margin-bottom: 0;
+ }
+ }
+}
diff --git a/client/src/utils.js b/client/src/utils.js
index f6deeee19..937cabf89 100644
--- a/client/src/utils.js
+++ b/client/src/utils.js
@@ -616,4 +616,7 @@ export const updateTableRow = (rowIndex, columnId, value) => (old) => {
}
return row;
});
-};
\ No newline at end of file
+};
+export const transformGeneralSettings = (data) => {
+ return _.mapKeys(data, (value, key) => _.snakeCase(key));
+};