mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
feat(Sales & Purchases ): add setfieldvalue exchange rate.
This commit is contained in:
@@ -13,13 +13,12 @@ const Schema = Yup.object().shape({
|
||||
.min(1)
|
||||
.max(DATATYPES_LENGTH.STRING)
|
||||
.label(intl.get('journal_type')),
|
||||
date: Yup.date()
|
||||
.required()
|
||||
.label(intl.get('date')),
|
||||
date: Yup.date().required().label(intl.get('date')),
|
||||
currency_code: Yup.string().max(3),
|
||||
publish: Yup.boolean(),
|
||||
reference: Yup.string().nullable().min(1).max(DATATYPES_LENGTH.STRING),
|
||||
description: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
||||
exchange_rate: Yup.number(),
|
||||
entries: Yup.array().of(
|
||||
Yup.object().shape({
|
||||
credit: Yup.number().nullable(),
|
||||
|
||||
@@ -56,6 +56,7 @@ function MakeJournalEntriesHeader({
|
||||
currencies,
|
||||
isForeignJournal,
|
||||
baseCurrency,
|
||||
selectJournalCurrency,
|
||||
setSelactJournalCurrency,
|
||||
} = useMakeJournalFormContext();
|
||||
|
||||
@@ -195,39 +196,37 @@ function MakeJournalEntriesHeader({
|
||||
|
||||
{/*------------ Currency -----------*/}
|
||||
{/* <FeatureCan feature={Features.ManualJournal}> */}
|
||||
<FastField
|
||||
name={'currency_code'}
|
||||
currencies={currencies}
|
||||
shouldUpdate={currenciesFieldShouldUpdate}
|
||||
>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={<T id={'currency'} />}
|
||||
className={classNames('form-group--currency', CLASSES.FILL)}
|
||||
inline={true}
|
||||
>
|
||||
<CurrencySelectList
|
||||
currenciesList={currencies}
|
||||
selectedCurrencyCode={value}
|
||||
onCurrencySelected={(currencyItem) => {
|
||||
form.setFieldValue(
|
||||
'currency_code',
|
||||
currencyItem.currency_code,
|
||||
);
|
||||
setSelactJournalCurrency(currencyItem);
|
||||
}}
|
||||
defaultSelectText={value}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
<FastField
|
||||
name={'currency_code'}
|
||||
currencies={currencies}
|
||||
shouldUpdate={currenciesFieldShouldUpdate}
|
||||
>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={<T id={'currency'} />}
|
||||
className={classNames('form-group--currency', CLASSES.FILL)}
|
||||
inline={true}
|
||||
>
|
||||
<CurrencySelectList
|
||||
currenciesList={currencies}
|
||||
selectedCurrencyCode={value}
|
||||
onCurrencySelected={(currencyItem) => {
|
||||
form.setFieldValue('currency_code', currencyItem.currency_code);
|
||||
form.setFieldValue('exchange_rate', '');
|
||||
setSelactJournalCurrency(currencyItem);
|
||||
}}
|
||||
defaultSelectText={value}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
{/* </FeatureCan> */}
|
||||
|
||||
{/* ----------- Exchange rate ----------- */}
|
||||
<If condition={isForeignJournal}>
|
||||
<ExchangeRateInputGroup
|
||||
fromCurrency={'USD'}
|
||||
toCurrency={'LYD'}
|
||||
fromCurrency={baseCurrency}
|
||||
toCurrency={selectJournalCurrency?.currency_code}
|
||||
name={'exchange_rate'}
|
||||
formGroupProps={{ label: ' ', inline: true }}
|
||||
/>
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
repeatValue,
|
||||
transformToForm,
|
||||
defaultFastFieldShouldUpdate,
|
||||
ensureEntriesHasEmptyLine
|
||||
ensureEntriesHasEmptyLine,
|
||||
} from 'utils';
|
||||
import { AppToaster } from 'components';
|
||||
import intl from 'react-intl-universal';
|
||||
@@ -44,6 +44,7 @@ export const defaultManualJournal = {
|
||||
reference: '',
|
||||
currency_code: '',
|
||||
publish: '',
|
||||
exchange_rate: '',
|
||||
entries: [...repeatValue(defaultEntry, 4)],
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user