mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
feat(Sales & Purchases ): add currency tag.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
import { BaseCurrency, BaseCurrencyRoot } from 'components';
|
||||
import { useBillFormContext } from './BillFormProvider';
|
||||
|
||||
/**
|
||||
* Bill form currnecy tag.
|
||||
* @returns
|
||||
*/
|
||||
export default function BillFormCurrencyTag() {
|
||||
const { isForeignVendor, selectVendor } = useBillFormContext();
|
||||
|
||||
if (!isForeignVendor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<BaseCurrencyRoot>
|
||||
<BaseCurrency currency={selectVendor?.currency_code} />
|
||||
</BaseCurrencyRoot>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
import React from 'react';
|
||||
import { FormGroup, InputGroup, Position } from '@blueprintjs/core';
|
||||
import {
|
||||
FormGroup,
|
||||
InputGroup,
|
||||
Position,
|
||||
ControlGroup,
|
||||
} from '@blueprintjs/core';
|
||||
import { DateInput } from '@blueprintjs/datetime';
|
||||
import { FormattedMessage as T } from 'components';
|
||||
import { FastField, ErrorMessage } from 'formik';
|
||||
import classNames from 'classnames';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { CLASSES } from 'common/classes';
|
||||
import {
|
||||
@@ -16,6 +22,7 @@ import {
|
||||
import { vendorsFieldShouldUpdate } from './utils';
|
||||
|
||||
import { useBillFormContext } from './BillFormProvider';
|
||||
import BillFormCurrencyTag from './BillFormCurrencyTag';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import {
|
||||
momentFormatter,
|
||||
@@ -49,17 +56,20 @@ function BillFormHeader() {
|
||||
intent={inputIntent({ error, touched })}
|
||||
helperText={<ErrorMessage name={'vendor_id'} />}
|
||||
>
|
||||
<VendorSelectField
|
||||
contacts={vendors}
|
||||
selectedContactId={value}
|
||||
defaultSelectText={<T id={'select_vender_account'} />}
|
||||
onContactSelected={(contact) => {
|
||||
form.setFieldValue('vendor_id', contact.id);
|
||||
setSelectVendor(contact);
|
||||
}}
|
||||
popoverFill={true}
|
||||
allowCreate={true}
|
||||
/>
|
||||
<ControlVendorGroup>
|
||||
<VendorSelectField
|
||||
contacts={vendors}
|
||||
selectedContactId={value}
|
||||
defaultSelectText={<T id={'select_vender_account'} />}
|
||||
onContactSelected={(contact) => {
|
||||
form.setFieldValue('vendor_id', contact.id);
|
||||
setSelectVendor(contact);
|
||||
}}
|
||||
popoverFill={true}
|
||||
allowCreate={true}
|
||||
/>
|
||||
<BillFormCurrencyTag />
|
||||
</ControlVendorGroup>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
@@ -161,3 +171,9 @@ function BillFormHeader() {
|
||||
}
|
||||
|
||||
export default compose(withDialogActions)(BillFormHeader);
|
||||
|
||||
const ControlVendorGroup = styled(ControlGroup)`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
transform: none;
|
||||
`;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
import { BaseCurrency, BaseCurrencyRoot } from 'components';
|
||||
import { useVendorCreditNoteFormContext } from './VendorCreditNoteFormProvider';
|
||||
|
||||
/**
|
||||
* Vendor credit note currency tag.
|
||||
* @returns
|
||||
*/
|
||||
export default function VendorCreditNoteFormCurrencyTag() {
|
||||
const { isForeignVendor, selectVendor } = useVendorCreditNoteFormContext();
|
||||
|
||||
if (!isForeignVendor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<BaseCurrencyRoot>
|
||||
<BaseCurrency currency={selectVendor?.currency_code} />
|
||||
</BaseCurrencyRoot>
|
||||
);
|
||||
}
|
||||
@@ -9,6 +9,8 @@ import { DateInput } from '@blueprintjs/datetime';
|
||||
import { FastField, Field, ErrorMessage } from 'formik';
|
||||
import { CLASSES } from 'common/classes';
|
||||
import classNames from 'classnames';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import {
|
||||
VendorSelectField,
|
||||
FieldRequiredHint,
|
||||
@@ -24,7 +26,7 @@ import {
|
||||
} from './utils';
|
||||
|
||||
import { useVendorCreditNoteFormContext } from './VendorCreditNoteFormProvider';
|
||||
|
||||
import VendorCreditNoteFormCurrencyTag from './VendorCreditNoteFormCurrencyTag';
|
||||
import {
|
||||
momentFormatter,
|
||||
compose,
|
||||
@@ -93,17 +95,20 @@ function VendorCreditNoteFormHeaderFields({
|
||||
intent={inputIntent({ error, touched })}
|
||||
helperText={<ErrorMessage name={'vendor_id'} />}
|
||||
>
|
||||
<VendorSelectField
|
||||
contacts={vendors}
|
||||
selectedContactId={value}
|
||||
defaultSelectText={<T id={'select_vender_account'} />}
|
||||
onContactSelected={(contact) => {
|
||||
form.setFieldValue('vendor_id', contact.id);
|
||||
setSelectVendor(contact);
|
||||
}}
|
||||
popoverFill={true}
|
||||
allowCreate={true}
|
||||
/>
|
||||
<ControlVendorGroup>
|
||||
<VendorSelectField
|
||||
contacts={vendors}
|
||||
selectedContactId={value}
|
||||
defaultSelectText={<T id={'select_vender_account'} />}
|
||||
onContactSelected={(contact) => {
|
||||
form.setFieldValue('vendor_id', contact.id);
|
||||
setSelectVendor(contact);
|
||||
}}
|
||||
popoverFill={true}
|
||||
allowCreate={true}
|
||||
/>
|
||||
<VendorCreditNoteFormCurrencyTag />
|
||||
</ControlVendorGroup>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
@@ -210,3 +215,9 @@ export default compose(
|
||||
vendorcreditNumberPrefix: vendorsCreditNoteSetting?.numberPrefix,
|
||||
})),
|
||||
)(VendorCreditNoteFormHeaderFields);
|
||||
|
||||
const ControlVendorGroup = styled(ControlGroup)`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
transform: none;
|
||||
`;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
import { BaseCurrency, BaseCurrencyRoot } from 'components';
|
||||
import { usePaymentMadeFormContext } from './PaymentMadeFormProvider';
|
||||
|
||||
/**
|
||||
* Payment made form currency tag.
|
||||
* @returns
|
||||
*/
|
||||
export default function PaymentMadeFormCurrencyTag() {
|
||||
const { isForeignVendor, selectVendor } = usePaymentMadeFormContext();
|
||||
|
||||
if (!isForeignVendor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<BaseCurrencyRoot>
|
||||
<BaseCurrency currency={selectVendor?.currency_code} />
|
||||
</BaseCurrencyRoot>
|
||||
);
|
||||
}
|
||||
@@ -13,6 +13,8 @@ import { FormattedMessage as T } from 'components';
|
||||
import { toSafeInteger } from 'lodash';
|
||||
import classNames from 'classnames';
|
||||
import { CLASSES } from 'common/classes';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import {
|
||||
AccountsSelectList,
|
||||
VendorSelectField,
|
||||
@@ -28,6 +30,7 @@ import {
|
||||
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
|
||||
import { usePaymentMadeFormContext } from './PaymentMadeFormProvider';
|
||||
import { ACCOUNT_TYPE } from 'common/accountTypes';
|
||||
import PaymentMadeFormCurrencyTag from './PaymentMadeFormCurrencyTag';
|
||||
import {
|
||||
momentFormatter,
|
||||
tansformDateValue,
|
||||
@@ -98,19 +101,22 @@ function PaymentMadeFormHeaderFields({ organization: { base_currency } }) {
|
||||
intent={inputIntent({ error, touched })}
|
||||
helperText={<ErrorMessage name={'vendor_id'} />}
|
||||
>
|
||||
<VendorSelectField
|
||||
contacts={vendors}
|
||||
selectedContactId={value}
|
||||
defaultSelectText={<T id={'select_vender_account'} />}
|
||||
onContactSelected={(contact) => {
|
||||
form.setFieldValue('vendor_id', contact.id);
|
||||
setPaymentVendorId(contact.id);
|
||||
setSelectVendor(contact);
|
||||
}}
|
||||
disabled={!isNewMode}
|
||||
popoverFill={true}
|
||||
allowCreate={true}
|
||||
/>
|
||||
<ControlVendorGroup>
|
||||
<VendorSelectField
|
||||
contacts={vendors}
|
||||
selectedContactId={value}
|
||||
defaultSelectText={<T id={'select_vender_account'} />}
|
||||
onContactSelected={(contact) => {
|
||||
form.setFieldValue('vendor_id', contact.id);
|
||||
setPaymentVendorId(contact.id);
|
||||
setSelectVendor(contact);
|
||||
}}
|
||||
disabled={!isNewMode}
|
||||
popoverFill={true}
|
||||
allowCreate={true}
|
||||
/>
|
||||
<PaymentMadeFormCurrencyTag />
|
||||
</ControlVendorGroup>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
@@ -265,3 +271,9 @@ function PaymentMadeFormHeaderFields({ organization: { base_currency } }) {
|
||||
}
|
||||
|
||||
export default compose(withCurrentOrganization())(PaymentMadeFormHeaderFields);
|
||||
|
||||
const ControlVendorGroup = styled(ControlGroup)`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
transform: none;
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user