mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
feat(cashflow): add ExchangeRateMutedField.
This commit is contained in:
@@ -35,7 +35,7 @@ const branchItemRenderer = (branch, { handleClick, modifiers, query }) => {
|
|||||||
<MenuItem
|
<MenuItem
|
||||||
active={modifiers.active}
|
active={modifiers.active}
|
||||||
disabled={modifiers.disabled}
|
disabled={modifiers.disabled}
|
||||||
label={branch.code.toString()}
|
label={branch.code}
|
||||||
key={branch.id}
|
key={branch.id}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
text={text}
|
text={text}
|
||||||
|
|||||||
84
src/components/ExchangeRate/ExchangeRateMutedField.js
Normal file
84
src/components/ExchangeRate/ExchangeRateMutedField.js
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import moment from 'moment';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import intl from 'react-intl-universal';
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Popover,
|
||||||
|
PopoverInteractionKind,
|
||||||
|
FormGroup,
|
||||||
|
Position,
|
||||||
|
Menu,
|
||||||
|
Classes,
|
||||||
|
} from '@blueprintjs/core';
|
||||||
|
import {
|
||||||
|
If,
|
||||||
|
ExchangeRateInputGroup,
|
||||||
|
Icon,
|
||||||
|
FormattedMessage as T,
|
||||||
|
} from 'components';
|
||||||
|
import { isEqual, isUndefined } from 'lodash';
|
||||||
|
|
||||||
|
export function ExchangeRateMutedField({
|
||||||
|
name,
|
||||||
|
toCurrency,
|
||||||
|
fromCurrency,
|
||||||
|
exchangeRate,
|
||||||
|
...ExchangeRateprops
|
||||||
|
}) {
|
||||||
|
if (isEqual(toCurrency, fromCurrency) && !isUndefined(toCurrency)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const content = (
|
||||||
|
<Menu>
|
||||||
|
<ExchangeRateInputGroup
|
||||||
|
name={name}
|
||||||
|
fromCurrency={fromCurrency}
|
||||||
|
toCurrency={toCurrency}
|
||||||
|
{...ExchangeRateprops}
|
||||||
|
/>
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ExchangeRateFormGroup
|
||||||
|
label={`As on ${moment(new Date()).format('YYYY-MM-DD')},`}
|
||||||
|
>
|
||||||
|
<Popover
|
||||||
|
content={content}
|
||||||
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
|
position={Position.RIGHT_TOP}
|
||||||
|
modifiers={{
|
||||||
|
offset: { offset: '0, 4' },
|
||||||
|
}}
|
||||||
|
minimal={true}
|
||||||
|
>
|
||||||
|
<ExchangeRateButton
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
rightIcon={<Icon icon="pen-18" />}
|
||||||
|
>
|
||||||
|
1 {fromCurrency} = {exchangeRate} {toCurrency}
|
||||||
|
</ExchangeRateButton>
|
||||||
|
</Popover>
|
||||||
|
</ExchangeRateFormGroup>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ExchangeRateFormGroup = styled(FormGroup)`
|
||||||
|
.bp3-label {
|
||||||
|
font-size: 12px !important;
|
||||||
|
opacity: 0.7;
|
||||||
|
line-height: 0.1rem;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ExchangeRateButton = styled(Button)`
|
||||||
|
.bp3-button-text {
|
||||||
|
display: flex;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #0d244a;
|
||||||
|
}
|
||||||
|
padding: 0;
|
||||||
|
`;
|
||||||
@@ -1 +1,2 @@
|
|||||||
export * from './ExchangeRateInput';
|
export * from './ExchangeRateInput';
|
||||||
|
export * from './ExchangeRateMutedField'
|
||||||
@@ -40,7 +40,7 @@ const warehouseItemRenderer = (
|
|||||||
<MenuItem
|
<MenuItem
|
||||||
active={modifiers.active}
|
active={modifiers.active}
|
||||||
disabled={modifiers.disabled}
|
disabled={modifiers.disabled}
|
||||||
label={warehouse.name.toString()}
|
label={warehouse.code}
|
||||||
key={warehouse.id}
|
key={warehouse.id}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
text={text}
|
text={text}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import {
|
|||||||
useCashflowAccounts,
|
useCashflowAccounts,
|
||||||
useSettingCashFlow,
|
useSettingCashFlow,
|
||||||
} from 'hooks/query';
|
} from 'hooks/query';
|
||||||
import { isEqual, isUndefined } from 'lodash';
|
|
||||||
|
|
||||||
const MoneyInDialogContent = React.createContext();
|
const MoneyInDialogContent = React.createContext();
|
||||||
|
|
||||||
@@ -49,10 +48,6 @@ function MoneyInDialogProvider({
|
|||||||
// Submit payload.
|
// Submit payload.
|
||||||
const [submitPayload, setSubmitPayload] = React.useState({});
|
const [submitPayload, setSubmitPayload] = React.useState({});
|
||||||
|
|
||||||
// Determines whether the foreign currency.
|
|
||||||
const isForeignCurrency = (toCurrency, fromCurrency) =>
|
|
||||||
!isEqual(toCurrency, fromCurrency) && !isUndefined(toCurrency);
|
|
||||||
|
|
||||||
// provider.
|
// provider.
|
||||||
const provider = {
|
const provider = {
|
||||||
accounts,
|
accounts,
|
||||||
@@ -70,7 +65,6 @@ function MoneyInDialogProvider({
|
|||||||
|
|
||||||
createCashflowTransactionMutate,
|
createCashflowTransactionMutate,
|
||||||
setSubmitPayload,
|
setSubmitPayload,
|
||||||
isForeignCurrency,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ function MoneyInFloatingActions({
|
|||||||
>
|
>
|
||||||
<T id={'close'} />
|
<T id={'close'} />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
{/* <Button
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
loading={isSubmitting && !submitPayload.publish}
|
loading={isSubmitting && !submitPayload.publish}
|
||||||
style={{ minWidth: '75px' }}
|
style={{ minWidth: '75px' }}
|
||||||
@@ -56,7 +56,7 @@ function MoneyInFloatingActions({
|
|||||||
onClick={handleSubmitDraftBtnClick}
|
onClick={handleSubmitDraftBtnClick}
|
||||||
>
|
>
|
||||||
{<T id={'save_as_draft'} />}
|
{<T id={'save_as_draft'} />}
|
||||||
</Button>
|
</Button> */}
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ const defaultInitialValues = {
|
|||||||
description: '',
|
description: '',
|
||||||
branch_id: '',
|
branch_id: '',
|
||||||
publish: '',
|
publish: '',
|
||||||
|
exchange_rate: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
function MoneyInForm({
|
function MoneyInForm({
|
||||||
@@ -69,7 +70,6 @@ function MoneyInForm({
|
|||||||
transaction_number: transactionNo,
|
transaction_number: transactionNo,
|
||||||
}),
|
}),
|
||||||
cashflow_account_id: accountId,
|
cashflow_account_id: accountId,
|
||||||
exchange_rate: 1,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handles the form submit.
|
// Handles the form submit.
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ const Schema = Yup.object().shape({
|
|||||||
credit_account_id: Yup.number().required(),
|
credit_account_id: Yup.number().required(),
|
||||||
cashflow_account_id: Yup.string().required(),
|
cashflow_account_id: Yup.string().required(),
|
||||||
branch_id: Yup.string(),
|
branch_id: Yup.string(),
|
||||||
|
exchange_rate: Yup.number(),
|
||||||
|
|
||||||
description: Yup.string()
|
description: Yup.string()
|
||||||
.min(3)
|
.min(3)
|
||||||
.max(DATATYPES_LENGTH.TEXT)
|
.max(DATATYPES_LENGTH.TEXT)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FastField, Field, ErrorMessage } from 'formik';
|
import { FastField, Field, ErrorMessage, useFormikContext } from 'formik';
|
||||||
import {
|
import {
|
||||||
Classes,
|
Classes,
|
||||||
FormGroup,
|
FormGroup,
|
||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
TextArea,
|
TextArea,
|
||||||
Position,
|
Position,
|
||||||
ControlGroup,
|
ControlGroup,
|
||||||
|
Button,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import {
|
import {
|
||||||
@@ -18,7 +19,11 @@ import {
|
|||||||
Icon,
|
Icon,
|
||||||
Col,
|
Col,
|
||||||
Row,
|
Row,
|
||||||
|
FeatureCan,
|
||||||
|
BranchSelect,
|
||||||
|
BranchSelectButton,
|
||||||
InputPrependButton,
|
InputPrependButton,
|
||||||
|
ExchangeRateMutedField,
|
||||||
} from 'components';
|
} from 'components';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { useAutofocus } from 'hooks';
|
import { useAutofocus } from 'hooks';
|
||||||
@@ -32,8 +37,13 @@ import {
|
|||||||
compose,
|
compose,
|
||||||
} from 'utils';
|
} from 'utils';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
|
import { Features } from 'common';
|
||||||
import { useMoneyInDailogContext } from '../MoneyInDialogProvider';
|
import { useMoneyInDailogContext } from '../MoneyInDialogProvider';
|
||||||
import { useObserveTransactionNoSettings } from '../utils';
|
import {
|
||||||
|
useObserveTransactionNoSettings,
|
||||||
|
useSetPrimaryBranchToForm,
|
||||||
|
BranchRowDivider,
|
||||||
|
} from '../utils';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
@@ -50,7 +60,9 @@ function OtherIncomeFormFields({
|
|||||||
transactionNextNumber,
|
transactionNextNumber,
|
||||||
}) {
|
}) {
|
||||||
// Money in dialog context.
|
// Money in dialog context.
|
||||||
const { accounts } = useMoneyInDailogContext();
|
const { accounts, account, branches } = useMoneyInDailogContext();
|
||||||
|
|
||||||
|
const { values } = useFormikContext();
|
||||||
|
|
||||||
const amountFieldRef = useAutofocus();
|
const amountFieldRef = useAutofocus();
|
||||||
|
|
||||||
@@ -79,8 +91,30 @@ function OtherIncomeFormFields({
|
|||||||
transactionNextNumber,
|
transactionNextNumber,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Sets the primary branch to form.
|
||||||
|
useSetPrimaryBranchToForm();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
<FeatureCan feature={Features.Branches}>
|
||||||
|
<Row>
|
||||||
|
<Col xs={5}>
|
||||||
|
<FormGroup
|
||||||
|
label={<T id={'branch'} />}
|
||||||
|
className={classNames('form-group--select-list', Classes.FILL)}
|
||||||
|
>
|
||||||
|
<BranchSelect
|
||||||
|
name={'branch_id'}
|
||||||
|
branches={branches}
|
||||||
|
input={BranchSelectButton}
|
||||||
|
popoverProps={{ minimal: true }}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</FeatureCan>
|
||||||
|
<BranchRowDivider />
|
||||||
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
{/*------------ Date -----------*/}
|
{/*------------ Date -----------*/}
|
||||||
@@ -181,6 +215,14 @@ function OtherIncomeFormFields({
|
|||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
|
|
||||||
|
{/*------------ exchange rate -----------*/}
|
||||||
|
<ExchangeRateMutedField
|
||||||
|
name={'exchange_rate'}
|
||||||
|
fromCurrency={values?.currency_code}
|
||||||
|
toCurrency={account?.currency_code}
|
||||||
|
formGroupProps={{ label: '', inline: false }}
|
||||||
|
exchangeRate={values.exchange_rate}
|
||||||
|
/>
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
{/*------------ other income account -----------*/}
|
{/*------------ other income account -----------*/}
|
||||||
|
|||||||
@@ -7,10 +7,9 @@ import {
|
|||||||
TextArea,
|
TextArea,
|
||||||
Position,
|
Position,
|
||||||
ControlGroup,
|
ControlGroup,
|
||||||
Button,
|
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import styled from 'styled-components';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
AccountsSuggestField,
|
AccountsSuggestField,
|
||||||
@@ -20,10 +19,10 @@ import {
|
|||||||
Icon,
|
Icon,
|
||||||
Col,
|
Col,
|
||||||
Row,
|
Row,
|
||||||
If,
|
|
||||||
InputPrependButton,
|
InputPrependButton,
|
||||||
ExchangeRateInputGroup,
|
ExchangeRateMutedField,
|
||||||
BranchSelect,
|
BranchSelect,
|
||||||
|
BranchSelectButton,
|
||||||
FeatureCan,
|
FeatureCan,
|
||||||
} from 'components';
|
} from 'components';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
@@ -42,6 +41,7 @@ import { useMoneyInDailogContext } from '../MoneyInDialogProvider';
|
|||||||
import {
|
import {
|
||||||
useObserveTransactionNoSettings,
|
useObserveTransactionNoSettings,
|
||||||
useSetPrimaryBranchToForm,
|
useSetPrimaryBranchToForm,
|
||||||
|
BranchRowDivider,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
@@ -60,8 +60,7 @@ function OwnerContributionFormFields({
|
|||||||
transactionNextNumber,
|
transactionNextNumber,
|
||||||
}) {
|
}) {
|
||||||
// Money in dialog context.
|
// Money in dialog context.
|
||||||
const { accounts, account, branches, isForeignCurrency } =
|
const { accounts, account, branches } = useMoneyInDailogContext();
|
||||||
useMoneyInDailogContext();
|
|
||||||
|
|
||||||
const { values } = useFormikContext();
|
const { values } = useFormikContext();
|
||||||
|
|
||||||
@@ -98,7 +97,7 @@ function OwnerContributionFormFields({
|
|||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<FeatureCan feature={Features.Branches}>
|
<FeatureCan feature={Features.Branches}>
|
||||||
<BranchFieldsRow>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={<T id={'branch'} />}
|
label={<T id={'branch'} />}
|
||||||
@@ -112,8 +111,9 @@ function OwnerContributionFormFields({
|
|||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</Col>
|
</Col>
|
||||||
</BranchFieldsRow>
|
</Row>
|
||||||
</FeatureCan>
|
</FeatureCan>
|
||||||
|
<BranchRowDivider />
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
{/*------------ Date -----------*/}
|
{/*------------ Date -----------*/}
|
||||||
@@ -213,20 +213,16 @@ function OwnerContributionFormFields({
|
|||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
{/*------------ exchange rate -----------*/}
|
{/*------------ exchange rate -----------*/}
|
||||||
{/* <If
|
<ExchangeRateMutedField
|
||||||
condition={isForeignCurrency(
|
name={'exchange_rate'}
|
||||||
account?.currency_code,
|
|
||||||
values?.currency_code,
|
|
||||||
)}
|
|
||||||
> */}
|
|
||||||
<ExchangeRateInputGroup
|
|
||||||
fromCurrency={values?.currency_code}
|
fromCurrency={values?.currency_code}
|
||||||
toCurrency={account?.currency_code}
|
toCurrency={account?.currency_code}
|
||||||
name={'exchange_rate'}
|
formGroupProps={{ label: '', inline: false }}
|
||||||
formGroupProps={{ label: ' ', inline: false }}
|
exchangeRate={values.exchange_rate}
|
||||||
/>
|
/>
|
||||||
{/* </If> */}
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
{/*------------ equity account -----------*/}
|
{/*------------ equity account -----------*/}
|
||||||
@@ -303,12 +299,3 @@ export default compose(
|
|||||||
transactionNumberPrefix: cashflowSetting?.numberPrefix,
|
transactionNumberPrefix: cashflowSetting?.numberPrefix,
|
||||||
})),
|
})),
|
||||||
)(OwnerContributionFormFields);
|
)(OwnerContributionFormFields);
|
||||||
|
|
||||||
function BranchSelectButton({ label }) {
|
|
||||||
return <Button text={label} minimal={false} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
const BranchFieldsRow = styled(Row)`
|
|
||||||
margin-bottom: 10px;
|
|
||||||
border-bottom: 1px solid #e9e9e9;
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FastField, Field, ErrorMessage } from 'formik';
|
import { FastField, Field, ErrorMessage, useFormikContext } from 'formik';
|
||||||
import {
|
import {
|
||||||
Classes,
|
Classes,
|
||||||
FormGroup,
|
FormGroup,
|
||||||
@@ -19,7 +19,12 @@ import {
|
|||||||
Col,
|
Col,
|
||||||
Row,
|
Row,
|
||||||
InputPrependButton,
|
InputPrependButton,
|
||||||
|
ExchangeRateMutedField,
|
||||||
|
FeatureCan,
|
||||||
|
BranchSelect,
|
||||||
|
BranchSelectButton,
|
||||||
} from 'components';
|
} from 'components';
|
||||||
|
import { Features } from 'common';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { useAutofocus } from 'hooks';
|
import { useAutofocus } from 'hooks';
|
||||||
import { ACCOUNT_TYPE } from 'common/accountTypes';
|
import { ACCOUNT_TYPE } from 'common/accountTypes';
|
||||||
@@ -33,7 +38,11 @@ import {
|
|||||||
} from 'utils';
|
} from 'utils';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import { useMoneyInDailogContext } from '../MoneyInDialogProvider';
|
import { useMoneyInDailogContext } from '../MoneyInDialogProvider';
|
||||||
import { useObserveTransactionNoSettings } from '../utils';
|
import {
|
||||||
|
useObserveTransactionNoSettings,
|
||||||
|
useSetPrimaryBranchToForm,
|
||||||
|
BranchRowDivider,
|
||||||
|
} from '../utils';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
@@ -50,10 +59,12 @@ function TransferFromAccountFormFields({
|
|||||||
transactionNextNumber,
|
transactionNextNumber,
|
||||||
}) {
|
}) {
|
||||||
// Money in dialog context.
|
// Money in dialog context.
|
||||||
const { accounts } = useMoneyInDailogContext();
|
const { accounts, account, branches } = useMoneyInDailogContext();
|
||||||
|
|
||||||
const amountFieldRef = useAutofocus();
|
const amountFieldRef = useAutofocus();
|
||||||
|
|
||||||
|
const { values } = useFormikContext();
|
||||||
|
|
||||||
// Handle tranaction number changing.
|
// Handle tranaction number changing.
|
||||||
const handleTransactionNumberChange = () => {
|
const handleTransactionNumberChange = () => {
|
||||||
openDialog('transaction-number-form');
|
openDialog('transaction-number-form');
|
||||||
@@ -73,6 +84,9 @@ function TransferFromAccountFormFields({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Sets the primary branch to form.
|
||||||
|
useSetPrimaryBranchToForm();
|
||||||
|
|
||||||
// Syncs transaction number settings with form.
|
// Syncs transaction number settings with form.
|
||||||
useObserveTransactionNoSettings(
|
useObserveTransactionNoSettings(
|
||||||
transactionNumberPrefix,
|
transactionNumberPrefix,
|
||||||
@@ -80,6 +94,24 @@ function TransferFromAccountFormFields({
|
|||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
<FeatureCan feature={Features.Branches}>
|
||||||
|
<Row>
|
||||||
|
<Col xs={5}>
|
||||||
|
<FormGroup
|
||||||
|
label={<T id={'branch'} />}
|
||||||
|
className={classNames('form-group--select-list', Classes.FILL)}
|
||||||
|
>
|
||||||
|
<BranchSelect
|
||||||
|
name={'branch_id'}
|
||||||
|
branches={branches}
|
||||||
|
input={BranchSelectButton}
|
||||||
|
popoverProps={{ minimal: true }}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</FeatureCan>
|
||||||
|
<BranchRowDivider />
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
{/*------------ Date -----------*/}
|
{/*------------ Date -----------*/}
|
||||||
@@ -180,6 +212,15 @@ function TransferFromAccountFormFields({
|
|||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
|
|
||||||
|
{/*------------ exchange rate -----------*/}
|
||||||
|
<ExchangeRateMutedField
|
||||||
|
name={'exchange_rate'}
|
||||||
|
fromCurrency={values?.currency_code}
|
||||||
|
toCurrency={account?.currency_code}
|
||||||
|
formGroupProps={{ label: '', inline: false }}
|
||||||
|
exchangeRate={values.exchange_rate}
|
||||||
|
/>
|
||||||
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
{/*------------ transfer from account -----------*/}
|
{/*------------ transfer from account -----------*/}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import { transactionNumber } from 'utils';
|
import { transactionNumber } from 'utils';
|
||||||
import { sumBy, setWith, toSafeInteger, get, first } from 'lodash';
|
import { sumBy, setWith, toSafeInteger, get, first } from 'lodash';
|
||||||
@@ -28,3 +29,9 @@ export const useSetPrimaryBranchToForm = () => {
|
|||||||
}
|
}
|
||||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
}, [isBranchesSuccess, setFieldValue, branches]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const BranchRowDivider = styled.div`
|
||||||
|
height: 1px;
|
||||||
|
background: #ebf1f6;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
`;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import React from 'react';
|
|||||||
import { DialogContent } from 'components';
|
import { DialogContent } from 'components';
|
||||||
import {
|
import {
|
||||||
useAccounts,
|
useAccounts,
|
||||||
|
useAccount,
|
||||||
|
useBranches,
|
||||||
useCreateCashflowTransaction,
|
useCreateCashflowTransaction,
|
||||||
useCashflowAccounts,
|
useCashflowAccounts,
|
||||||
useSettingCashFlow,
|
useSettingCashFlow,
|
||||||
@@ -16,6 +18,17 @@ function MoneyOutProvider({ accountId, accountType, dialogName, ...props }) {
|
|||||||
// Fetches accounts list.
|
// Fetches accounts list.
|
||||||
const { isLoading: isAccountsLoading, data: accounts } = useAccounts();
|
const { isLoading: isAccountsLoading, data: accounts } = useAccounts();
|
||||||
|
|
||||||
|
// Fetches the specific account details.
|
||||||
|
const { data: account, isLoading: isAccountLoading } = useAccount(accountId, {
|
||||||
|
enabled: !!accountId,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fetches the branches list.
|
||||||
|
const {
|
||||||
|
data: branches,
|
||||||
|
isLoading: isBranchesLoading,
|
||||||
|
isSuccess: isBranchesSuccess,
|
||||||
|
} = useBranches();
|
||||||
// Fetch cash flow list .
|
// Fetch cash flow list .
|
||||||
const { data: cashflowAccounts, isLoading: isCashFlowAccountsLoading } =
|
const { data: cashflowAccounts, isLoading: isCashFlowAccountsLoading } =
|
||||||
useCashflowAccounts({}, { keepPreviousData: true });
|
useCashflowAccounts({}, { keepPreviousData: true });
|
||||||
@@ -32,9 +45,12 @@ function MoneyOutProvider({ accountId, accountType, dialogName, ...props }) {
|
|||||||
// provider.
|
// provider.
|
||||||
const provider = {
|
const provider = {
|
||||||
accounts,
|
accounts,
|
||||||
|
account,
|
||||||
accountId,
|
accountId,
|
||||||
accountType,
|
accountType,
|
||||||
|
branches,
|
||||||
isAccountsLoading,
|
isAccountsLoading,
|
||||||
|
isBranchesSuccess,
|
||||||
|
|
||||||
cashflowAccounts,
|
cashflowAccounts,
|
||||||
|
|
||||||
@@ -48,7 +64,10 @@ function MoneyOutProvider({ accountId, accountType, dialogName, ...props }) {
|
|||||||
return (
|
return (
|
||||||
<DialogContent
|
<DialogContent
|
||||||
isLoading={
|
isLoading={
|
||||||
isAccountsLoading || isCashFlowAccountsLoading || isSettingsLoading
|
isAccountsLoading ||
|
||||||
|
isCashFlowAccountsLoading ||
|
||||||
|
isBranchesLoading ||
|
||||||
|
isSettingsLoading
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<MoneyInDialogContent.Provider value={provider} {...props} />
|
<MoneyInDialogContent.Provider value={provider} {...props} />
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ function MoneyOutFloatingActions({
|
|||||||
>
|
>
|
||||||
<T id={'close'} />
|
<T id={'close'} />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
{/* <Button
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
loading={isSubmitting && !submitPayload.publish}
|
loading={isSubmitting && !submitPayload.publish}
|
||||||
style={{ minWidth: '75px' }}
|
style={{ minWidth: '75px' }}
|
||||||
@@ -58,7 +58,7 @@ function MoneyOutFloatingActions({
|
|||||||
onClick={handleSubmitDraftBtnClick}
|
onClick={handleSubmitDraftBtnClick}
|
||||||
>
|
>
|
||||||
{<T id={'save_as_draft'} />}
|
{<T id={'save_as_draft'} />}
|
||||||
</Button>
|
</Button> */}
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ const defaultInitialValues = {
|
|||||||
credit_account_id: '',
|
credit_account_id: '',
|
||||||
description: '',
|
description: '',
|
||||||
publish: '',
|
publish: '',
|
||||||
|
exchange_rate: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
function MoneyOutForm({
|
function MoneyOutForm({
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ const Schema = Yup.object().shape({
|
|||||||
reference_no: Yup.string(),
|
reference_no: Yup.string(),
|
||||||
credit_account_id: Yup.number().required(),
|
credit_account_id: Yup.number().required(),
|
||||||
cashflow_account_id: Yup.string().required(),
|
cashflow_account_id: Yup.string().required(),
|
||||||
|
branch_id: Yup.string(),
|
||||||
|
exchange_rate: Yup.number(),
|
||||||
description: Yup.string()
|
description: Yup.string()
|
||||||
.min(3)
|
.min(3)
|
||||||
.max(DATATYPES_LENGTH.TEXT)
|
.max(DATATYPES_LENGTH.TEXT)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FastField, Field, ErrorMessage } from 'formik';
|
import { FastField, Field, ErrorMessage, useFormikContext } from 'formik';
|
||||||
import {
|
import {
|
||||||
Classes,
|
Classes,
|
||||||
FormGroup,
|
FormGroup,
|
||||||
@@ -19,10 +19,15 @@ import {
|
|||||||
Col,
|
Col,
|
||||||
Row,
|
Row,
|
||||||
InputPrependButton,
|
InputPrependButton,
|
||||||
|
FeatureCan,
|
||||||
|
BranchSelect,
|
||||||
|
BranchSelectButton,
|
||||||
|
ExchangeRateMutedField,
|
||||||
} from 'components';
|
} from 'components';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { useAutofocus } from 'hooks';
|
import { useAutofocus } from 'hooks';
|
||||||
import { ACCOUNT_TYPE } from 'common/accountTypes';
|
import { ACCOUNT_TYPE } from 'common/accountTypes';
|
||||||
|
import { Features } from 'common';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
inputIntent,
|
inputIntent,
|
||||||
@@ -33,7 +38,11 @@ import {
|
|||||||
} from 'utils';
|
} from 'utils';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import { useMoneyOutDialogContext } from '../MoneyOutDialogProvider';
|
import { useMoneyOutDialogContext } from '../MoneyOutDialogProvider';
|
||||||
import { useObserveTransactionNoSettings } from '../utils';
|
import {
|
||||||
|
useObserveTransactionNoSettings,
|
||||||
|
useSetPrimaryBranchToForm,
|
||||||
|
BranchRowDivider,
|
||||||
|
} from '../utils';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
@@ -50,7 +59,9 @@ function OtherExpnseFormFields({
|
|||||||
transactionNextNumber,
|
transactionNextNumber,
|
||||||
}) {
|
}) {
|
||||||
// Money in dialog context.
|
// Money in dialog context.
|
||||||
const { accounts } = useMoneyOutDialogContext();
|
const { accounts, account, branches } = useMoneyOutDialogContext();
|
||||||
|
|
||||||
|
const { values } = useFormikContext();
|
||||||
|
|
||||||
const amountFieldRef = useAutofocus();
|
const amountFieldRef = useAutofocus();
|
||||||
|
|
||||||
@@ -79,8 +90,29 @@ function OtherExpnseFormFields({
|
|||||||
transactionNextNumber,
|
transactionNextNumber,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Sets the primary branch to form.
|
||||||
|
useSetPrimaryBranchToForm();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
<FeatureCan feature={Features.Branches}>
|
||||||
|
<Row>
|
||||||
|
<Col xs={5}>
|
||||||
|
<FormGroup
|
||||||
|
label={<T id={'branch'} />}
|
||||||
|
className={classNames('form-group--select-list', Classes.FILL)}
|
||||||
|
>
|
||||||
|
<BranchSelect
|
||||||
|
name={'branch_id'}
|
||||||
|
branches={branches}
|
||||||
|
input={BranchSelectButton}
|
||||||
|
popoverProps={{ minimal: true }}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</FeatureCan>
|
||||||
|
<BranchRowDivider />
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
{/*------------ Date -----------*/}
|
{/*------------ Date -----------*/}
|
||||||
@@ -181,6 +213,15 @@ function OtherExpnseFormFields({
|
|||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
|
|
||||||
|
{/*------------ exchange rate -----------*/}
|
||||||
|
<ExchangeRateMutedField
|
||||||
|
name={'exchange_rate'}
|
||||||
|
fromCurrency={values?.currency_code}
|
||||||
|
toCurrency={account?.currency_code}
|
||||||
|
formGroupProps={{ label: '', inline: false }}
|
||||||
|
exchangeRate={values.exchange_rate}
|
||||||
|
/>
|
||||||
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
{/*------------ other expense account -----------*/}
|
{/*------------ other expense account -----------*/}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FastField, Field, ErrorMessage } from 'formik';
|
import { FastField, Field, ErrorMessage, useFormikContext } from 'formik';
|
||||||
import {
|
import {
|
||||||
Classes,
|
Classes,
|
||||||
FormGroup,
|
FormGroup,
|
||||||
@@ -19,10 +19,15 @@ import {
|
|||||||
Icon,
|
Icon,
|
||||||
Col,
|
Col,
|
||||||
Row,
|
Row,
|
||||||
|
FeatureCan,
|
||||||
|
BranchSelect,
|
||||||
|
BranchSelectButton,
|
||||||
|
ExchangeRateMutedField,
|
||||||
} from 'components';
|
} from 'components';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { useAutofocus } from 'hooks';
|
import { useAutofocus } from 'hooks';
|
||||||
import { ACCOUNT_TYPE } from 'common/accountTypes';
|
import { ACCOUNT_TYPE } from 'common/accountTypes';
|
||||||
|
import { Features } from 'common';
|
||||||
import {
|
import {
|
||||||
inputIntent,
|
inputIntent,
|
||||||
momentFormatter,
|
momentFormatter,
|
||||||
@@ -32,7 +37,11 @@ import {
|
|||||||
} from 'utils';
|
} from 'utils';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import { useMoneyOutDialogContext } from '../MoneyOutDialogProvider';
|
import { useMoneyOutDialogContext } from '../MoneyOutDialogProvider';
|
||||||
import { useObserveTransactionNoSettings } from '../utils';
|
import {
|
||||||
|
useObserveTransactionNoSettings,
|
||||||
|
useSetPrimaryBranchToForm,
|
||||||
|
BranchRowDivider,
|
||||||
|
} from '../utils';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
@@ -49,7 +58,8 @@ function OwnerDrawingsFormFields({
|
|||||||
transactionNextNumber,
|
transactionNextNumber,
|
||||||
}) {
|
}) {
|
||||||
// Money out dialog context.
|
// Money out dialog context.
|
||||||
const { accounts } = useMoneyOutDialogContext();
|
const { accounts, account, branches } = useMoneyOutDialogContext();
|
||||||
|
const { values } = useFormikContext();
|
||||||
|
|
||||||
const amountFieldRef = useAutofocus();
|
const amountFieldRef = useAutofocus();
|
||||||
|
|
||||||
@@ -78,8 +88,29 @@ function OwnerDrawingsFormFields({
|
|||||||
transactionNextNumber,
|
transactionNextNumber,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Sets the primary branch to form.
|
||||||
|
useSetPrimaryBranchToForm();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
<FeatureCan feature={Features.Branches}>
|
||||||
|
<Row>
|
||||||
|
<Col xs={5}>
|
||||||
|
<FormGroup
|
||||||
|
label={<T id={'branch'} />}
|
||||||
|
className={classNames('form-group--select-list', Classes.FILL)}
|
||||||
|
>
|
||||||
|
<BranchSelect
|
||||||
|
name={'branch_id'}
|
||||||
|
branches={branches}
|
||||||
|
input={BranchSelectButton}
|
||||||
|
popoverProps={{ minimal: true }}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</FeatureCan>
|
||||||
|
<BranchRowDivider />
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
{/*------------ Date -----------*/}
|
{/*------------ Date -----------*/}
|
||||||
@@ -180,6 +211,14 @@ function OwnerDrawingsFormFields({
|
|||||||
)}
|
)}
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
|
{/*------------ exchange rate -----------*/}
|
||||||
|
<ExchangeRateMutedField
|
||||||
|
name={'exchange_rate'}
|
||||||
|
fromCurrency={values?.currency_code}
|
||||||
|
toCurrency={account?.currency_code}
|
||||||
|
formGroupProps={{ label: '', inline: false }}
|
||||||
|
exchangeRate={values.exchange_rate}
|
||||||
|
/>
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
{/*------------ equitty account -----------*/}
|
{/*------------ equitty account -----------*/}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FastField, Field, ErrorMessage } from 'formik';
|
import { FastField, Field, ErrorMessage, useFormikContext } from 'formik';
|
||||||
import {
|
import {
|
||||||
Classes,
|
Classes,
|
||||||
FormGroup,
|
FormGroup,
|
||||||
@@ -19,6 +19,10 @@ import {
|
|||||||
Col,
|
Col,
|
||||||
Row,
|
Row,
|
||||||
InputPrependButton,
|
InputPrependButton,
|
||||||
|
FeatureCan,
|
||||||
|
BranchSelect,
|
||||||
|
BranchSelectButton,
|
||||||
|
ExchangeRateMutedField,
|
||||||
} from 'components';
|
} from 'components';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { useAutofocus } from 'hooks';
|
import { useAutofocus } from 'hooks';
|
||||||
@@ -31,9 +35,14 @@ import {
|
|||||||
handleDateChange,
|
handleDateChange,
|
||||||
compose,
|
compose,
|
||||||
} from 'utils';
|
} from 'utils';
|
||||||
|
import { Features } from 'common';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import { useMoneyOutDialogContext } from '../MoneyOutDialogProvider';
|
import { useMoneyOutDialogContext } from '../MoneyOutDialogProvider';
|
||||||
import { useObserveTransactionNoSettings } from '../utils';
|
import {
|
||||||
|
useObserveTransactionNoSettings,
|
||||||
|
useSetPrimaryBranchToForm,
|
||||||
|
BranchRowDivider,
|
||||||
|
} from '../utils';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
@@ -50,7 +59,8 @@ function TransferToAccountFormFields({
|
|||||||
transactionNextNumber,
|
transactionNextNumber,
|
||||||
}) {
|
}) {
|
||||||
// Money in dialog context.
|
// Money in dialog context.
|
||||||
const { accounts } = useMoneyOutDialogContext();
|
const { accounts, account, branches } = useMoneyOutDialogContext();
|
||||||
|
const { values } = useFormikContext();
|
||||||
|
|
||||||
const accountRef = useAutofocus();
|
const accountRef = useAutofocus();
|
||||||
|
|
||||||
@@ -79,8 +89,29 @@ function TransferToAccountFormFields({
|
|||||||
transactionNextNumber,
|
transactionNextNumber,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Sets the primary branch to form.
|
||||||
|
useSetPrimaryBranchToForm();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
<FeatureCan feature={Features.Branches}>
|
||||||
|
<Row>
|
||||||
|
<Col xs={5}>
|
||||||
|
<FormGroup
|
||||||
|
label={<T id={'branch'} />}
|
||||||
|
className={classNames('form-group--select-list', Classes.FILL)}
|
||||||
|
>
|
||||||
|
<BranchSelect
|
||||||
|
name={'branch_id'}
|
||||||
|
branches={branches}
|
||||||
|
input={BranchSelectButton}
|
||||||
|
popoverProps={{ minimal: true }}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</FeatureCan>
|
||||||
|
<BranchRowDivider />
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
{/*------------ Date -----------*/}
|
{/*------------ Date -----------*/}
|
||||||
@@ -181,6 +212,15 @@ function TransferToAccountFormFields({
|
|||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
|
|
||||||
|
{/*------------ exchange rate -----------*/}
|
||||||
|
<ExchangeRateMutedField
|
||||||
|
name={'exchange_rate'}
|
||||||
|
fromCurrency={values?.currency_code}
|
||||||
|
toCurrency={account?.currency_code}
|
||||||
|
formGroupProps={{ label: '', inline: false }}
|
||||||
|
exchangeRate={values.exchange_rate}
|
||||||
|
/>
|
||||||
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={5}>
|
<Col xs={5}>
|
||||||
{/*------------ transfer from account -----------*/}
|
{/*------------ transfer from account -----------*/}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import { transactionNumber } from 'utils';
|
import { transactionNumber } from 'utils';
|
||||||
|
import { first } from 'lodash';
|
||||||
|
|
||||||
|
import { useMoneyOutDialogContext } from './MoneyOutDialogProvider';
|
||||||
|
|
||||||
export const useObserveTransactionNoSettings = (prefix, nextNumber) => {
|
export const useObserveTransactionNoSettings = (prefix, nextNumber) => {
|
||||||
const { setFieldValue } = useFormikContext();
|
const { setFieldValue } = useFormikContext();
|
||||||
@@ -10,3 +14,23 @@ export const useObserveTransactionNoSettings = (prefix, nextNumber) => {
|
|||||||
setFieldValue('transacttion_numner', TransactionNo);
|
setFieldValue('transacttion_numner', TransactionNo);
|
||||||
}, [setFieldValue, prefix, nextNumber]);
|
}, [setFieldValue, prefix, nextNumber]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useSetPrimaryBranchToForm = () => {
|
||||||
|
const { setFieldValue } = useFormikContext();
|
||||||
|
const { branches, isBranchesSuccess } = useMoneyOutDialogContext();
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (isBranchesSuccess) {
|
||||||
|
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
||||||
|
|
||||||
|
if (primaryBranch) {
|
||||||
|
setFieldValue('branch_id', primaryBranch.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [isBranchesSuccess, setFieldValue, branches]);
|
||||||
|
};
|
||||||
|
export const BranchRowDivider = styled.div`
|
||||||
|
height: 1px;
|
||||||
|
background: #ebf1f6;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user