mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
feat(Sales & Purchases ): add currency tag.
This commit is contained in:
10
src/components/Currencies/BaseCurrency.js
Normal file
10
src/components/Currencies/BaseCurrency.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { CurrencyTag } from 'components';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* base currecncy.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function BaseCurrency({ currency }) {
|
||||||
|
return <CurrencyTag>{currency}</CurrencyTag>;
|
||||||
|
}
|
||||||
@@ -1 +1,2 @@
|
|||||||
export * from './CurrencySelect'
|
export * from './CurrencySelect';
|
||||||
|
export * from './BaseCurrency';
|
||||||
|
|||||||
@@ -9,3 +9,13 @@ export const CurrencyTag = styled.span`
|
|||||||
line-height: 1;
|
line-height: 1;
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const BaseCurrencyRoot = styled.div`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 10px;
|
||||||
|
margin-left: 4px;
|
||||||
|
> span {
|
||||||
|
background: #5c7080;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ import AvaterCell from './AvaterCell';
|
|||||||
import { ItemsMultiSelect } from './Items';
|
import { ItemsMultiSelect } from './Items';
|
||||||
import MoreMenuItems from './MoreMenutItems';
|
import MoreMenuItems from './MoreMenutItems';
|
||||||
import CustomSelectList from './CustomSelectList';
|
import CustomSelectList from './CustomSelectList';
|
||||||
import BaseCurrency from './BaseCurrency';
|
|
||||||
|
|
||||||
export * from './Dialog';
|
export * from './Dialog';
|
||||||
export * from './Menu';
|
export * from './Menu';
|
||||||
@@ -168,7 +167,6 @@ export {
|
|||||||
MoneyFieldCell,
|
MoneyFieldCell,
|
||||||
ItemsMultiSelect,
|
ItemsMultiSelect,
|
||||||
AvaterCell,
|
AvaterCell,
|
||||||
BaseCurrency,
|
|
||||||
MoreMenuItems,
|
MoreMenuItems,
|
||||||
CustomSelectList,
|
CustomSelectList,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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 React from 'react';
|
||||||
import { FormGroup, InputGroup, Position } from '@blueprintjs/core';
|
import {
|
||||||
|
FormGroup,
|
||||||
|
InputGroup,
|
||||||
|
Position,
|
||||||
|
ControlGroup,
|
||||||
|
} from '@blueprintjs/core';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { FormattedMessage as T } from 'components';
|
import { FormattedMessage as T } from 'components';
|
||||||
import { FastField, ErrorMessage } from 'formik';
|
import { FastField, ErrorMessage } from 'formik';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import {
|
import {
|
||||||
@@ -16,6 +22,7 @@ import {
|
|||||||
import { vendorsFieldShouldUpdate } from './utils';
|
import { vendorsFieldShouldUpdate } from './utils';
|
||||||
|
|
||||||
import { useBillFormContext } from './BillFormProvider';
|
import { useBillFormContext } from './BillFormProvider';
|
||||||
|
import BillFormCurrencyTag from './BillFormCurrencyTag';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
import {
|
import {
|
||||||
momentFormatter,
|
momentFormatter,
|
||||||
@@ -49,17 +56,20 @@ function BillFormHeader() {
|
|||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
helperText={<ErrorMessage name={'vendor_id'} />}
|
helperText={<ErrorMessage name={'vendor_id'} />}
|
||||||
>
|
>
|
||||||
<VendorSelectField
|
<ControlVendorGroup>
|
||||||
contacts={vendors}
|
<VendorSelectField
|
||||||
selectedContactId={value}
|
contacts={vendors}
|
||||||
defaultSelectText={<T id={'select_vender_account'} />}
|
selectedContactId={value}
|
||||||
onContactSelected={(contact) => {
|
defaultSelectText={<T id={'select_vender_account'} />}
|
||||||
form.setFieldValue('vendor_id', contact.id);
|
onContactSelected={(contact) => {
|
||||||
setSelectVendor(contact);
|
form.setFieldValue('vendor_id', contact.id);
|
||||||
}}
|
setSelectVendor(contact);
|
||||||
popoverFill={true}
|
}}
|
||||||
allowCreate={true}
|
popoverFill={true}
|
||||||
/>
|
allowCreate={true}
|
||||||
|
/>
|
||||||
|
<BillFormCurrencyTag />
|
||||||
|
</ControlVendorGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
@@ -161,3 +171,9 @@ function BillFormHeader() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default compose(withDialogActions)(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 { FastField, Field, ErrorMessage } from 'formik';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
VendorSelectField,
|
VendorSelectField,
|
||||||
FieldRequiredHint,
|
FieldRequiredHint,
|
||||||
@@ -24,7 +26,7 @@ import {
|
|||||||
} from './utils';
|
} from './utils';
|
||||||
|
|
||||||
import { useVendorCreditNoteFormContext } from './VendorCreditNoteFormProvider';
|
import { useVendorCreditNoteFormContext } from './VendorCreditNoteFormProvider';
|
||||||
|
import VendorCreditNoteFormCurrencyTag from './VendorCreditNoteFormCurrencyTag';
|
||||||
import {
|
import {
|
||||||
momentFormatter,
|
momentFormatter,
|
||||||
compose,
|
compose,
|
||||||
@@ -93,17 +95,20 @@ function VendorCreditNoteFormHeaderFields({
|
|||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
helperText={<ErrorMessage name={'vendor_id'} />}
|
helperText={<ErrorMessage name={'vendor_id'} />}
|
||||||
>
|
>
|
||||||
<VendorSelectField
|
<ControlVendorGroup>
|
||||||
contacts={vendors}
|
<VendorSelectField
|
||||||
selectedContactId={value}
|
contacts={vendors}
|
||||||
defaultSelectText={<T id={'select_vender_account'} />}
|
selectedContactId={value}
|
||||||
onContactSelected={(contact) => {
|
defaultSelectText={<T id={'select_vender_account'} />}
|
||||||
form.setFieldValue('vendor_id', contact.id);
|
onContactSelected={(contact) => {
|
||||||
setSelectVendor(contact);
|
form.setFieldValue('vendor_id', contact.id);
|
||||||
}}
|
setSelectVendor(contact);
|
||||||
popoverFill={true}
|
}}
|
||||||
allowCreate={true}
|
popoverFill={true}
|
||||||
/>
|
allowCreate={true}
|
||||||
|
/>
|
||||||
|
<VendorCreditNoteFormCurrencyTag />
|
||||||
|
</ControlVendorGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
@@ -210,3 +215,9 @@ export default compose(
|
|||||||
vendorcreditNumberPrefix: vendorsCreditNoteSetting?.numberPrefix,
|
vendorcreditNumberPrefix: vendorsCreditNoteSetting?.numberPrefix,
|
||||||
})),
|
})),
|
||||||
)(VendorCreditNoteFormHeaderFields);
|
)(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 { toSafeInteger } from 'lodash';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AccountsSelectList,
|
AccountsSelectList,
|
||||||
VendorSelectField,
|
VendorSelectField,
|
||||||
@@ -28,6 +30,7 @@ import {
|
|||||||
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
|
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
|
||||||
import { usePaymentMadeFormContext } from './PaymentMadeFormProvider';
|
import { usePaymentMadeFormContext } from './PaymentMadeFormProvider';
|
||||||
import { ACCOUNT_TYPE } from 'common/accountTypes';
|
import { ACCOUNT_TYPE } from 'common/accountTypes';
|
||||||
|
import PaymentMadeFormCurrencyTag from './PaymentMadeFormCurrencyTag';
|
||||||
import {
|
import {
|
||||||
momentFormatter,
|
momentFormatter,
|
||||||
tansformDateValue,
|
tansformDateValue,
|
||||||
@@ -98,19 +101,22 @@ function PaymentMadeFormHeaderFields({ organization: { base_currency } }) {
|
|||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
helperText={<ErrorMessage name={'vendor_id'} />}
|
helperText={<ErrorMessage name={'vendor_id'} />}
|
||||||
>
|
>
|
||||||
<VendorSelectField
|
<ControlVendorGroup>
|
||||||
contacts={vendors}
|
<VendorSelectField
|
||||||
selectedContactId={value}
|
contacts={vendors}
|
||||||
defaultSelectText={<T id={'select_vender_account'} />}
|
selectedContactId={value}
|
||||||
onContactSelected={(contact) => {
|
defaultSelectText={<T id={'select_vender_account'} />}
|
||||||
form.setFieldValue('vendor_id', contact.id);
|
onContactSelected={(contact) => {
|
||||||
setPaymentVendorId(contact.id);
|
form.setFieldValue('vendor_id', contact.id);
|
||||||
setSelectVendor(contact);
|
setPaymentVendorId(contact.id);
|
||||||
}}
|
setSelectVendor(contact);
|
||||||
disabled={!isNewMode}
|
}}
|
||||||
popoverFill={true}
|
disabled={!isNewMode}
|
||||||
allowCreate={true}
|
popoverFill={true}
|
||||||
/>
|
allowCreate={true}
|
||||||
|
/>
|
||||||
|
<PaymentMadeFormCurrencyTag />
|
||||||
|
</ControlVendorGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
@@ -265,3 +271,9 @@ function PaymentMadeFormHeaderFields({ organization: { base_currency } }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default compose(withCurrentOrganization())(PaymentMadeFormHeaderFields);
|
export default compose(withCurrentOrganization())(PaymentMadeFormHeaderFields);
|
||||||
|
|
||||||
|
const ControlVendorGroup = styled(ControlGroup)`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
transform: none;
|
||||||
|
`;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { DateInput } from '@blueprintjs/datetime';
|
|||||||
import { FastField, Field, ErrorMessage } from 'formik';
|
import { FastField, Field, ErrorMessage } from 'formik';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import styled from 'styled-components';
|
||||||
import {
|
import {
|
||||||
CustomerSelectField,
|
CustomerSelectField,
|
||||||
FieldRequiredHint,
|
FieldRequiredHint,
|
||||||
@@ -26,7 +27,7 @@ import {
|
|||||||
import { useCreditNoteFormContext } from './CreditNoteFormProvider';
|
import { useCreditNoteFormContext } from './CreditNoteFormProvider';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
import CreditNotetFormCurrencyTag from './CreditNotetFormCurrencyTag';
|
||||||
import {
|
import {
|
||||||
momentFormatter,
|
momentFormatter,
|
||||||
compose,
|
compose,
|
||||||
@@ -94,17 +95,20 @@ function CreditNoteFormHeaderFields({
|
|||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
helperText={<ErrorMessage name={'customer_id'} />}
|
helperText={<ErrorMessage name={'customer_id'} />}
|
||||||
>
|
>
|
||||||
<CustomerSelectField
|
<ControlCustomerGroup>
|
||||||
contacts={customers}
|
<CustomerSelectField
|
||||||
selectedContactId={value}
|
contacts={customers}
|
||||||
defaultSelectText={<T id={'select_customer_account'} />}
|
selectedContactId={value}
|
||||||
onContactSelected={(customer) => {
|
defaultSelectText={<T id={'select_customer_account'} />}
|
||||||
form.setFieldValue('customer_id', customer.id);
|
onContactSelected={(customer) => {
|
||||||
setSelectCustomer(customer);
|
form.setFieldValue('customer_id', customer.id);
|
||||||
}}
|
setSelectCustomer(customer);
|
||||||
popoverFill={true}
|
}}
|
||||||
allowCreate={true}
|
popoverFill={true}
|
||||||
/>
|
allowCreate={true}
|
||||||
|
/>
|
||||||
|
<CreditNotetFormCurrencyTag />
|
||||||
|
</ControlCustomerGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
@@ -207,3 +211,9 @@ export default compose(
|
|||||||
creditNumberPrefix: creditNoteSettings?.numberPrefix,
|
creditNumberPrefix: creditNoteSettings?.numberPrefix,
|
||||||
})),
|
})),
|
||||||
)(CreditNoteFormHeaderFields);
|
)(CreditNoteFormHeaderFields);
|
||||||
|
|
||||||
|
const ControlCustomerGroup = styled(ControlGroup)`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
transform: none;
|
||||||
|
`;
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { BaseCurrency, BaseCurrencyRoot } from 'components';
|
||||||
|
import { useCreditNoteFormContext } from './CreditNoteFormProvider';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Credit note from currency tag.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export default function CreditNotetFormCurrencyTag() {
|
||||||
|
const { isForeignCustomer, selectCustomer } = useCreditNoteFormContext();
|
||||||
|
|
||||||
|
if (!isForeignCustomer) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseCurrencyRoot>
|
||||||
|
<BaseCurrency currency={selectCustomer?.currency_code} />
|
||||||
|
</BaseCurrencyRoot>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { BaseCurrency, BaseCurrencyRoot } from 'components';
|
||||||
|
import { useEstimateFormContext } from './EstimateFormProvider';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Estimate form currency tag.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export default function EstimateFromCurrencyTag() {
|
||||||
|
const { isForeignCustomer, selectCustomer } = useEstimateFormContext();
|
||||||
|
|
||||||
|
if (!isForeignCustomer) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseCurrencyRoot>
|
||||||
|
<BaseCurrency currency={selectCustomer?.currency_code} />
|
||||||
|
</BaseCurrencyRoot>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -8,6 +8,8 @@ import {
|
|||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { FormattedMessage as T } from 'components';
|
import { FormattedMessage as T } from 'components';
|
||||||
import { FastField, Field, ErrorMessage } from 'formik';
|
import { FastField, Field, ErrorMessage } from 'formik';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
momentFormatter,
|
momentFormatter,
|
||||||
compose,
|
compose,
|
||||||
@@ -29,7 +31,7 @@ import {
|
|||||||
|
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
|
import EstimateFormCurrencyTag from './EstimateFormCurrencyTag';
|
||||||
import { useObserveEstimateNoSettings } from './utils';
|
import { useObserveEstimateNoSettings } from './utils';
|
||||||
import { useEstimateFormContext } from './EstimateFormProvider';
|
import { useEstimateFormContext } from './EstimateFormProvider';
|
||||||
|
|
||||||
@@ -85,18 +87,21 @@ function EstimateFormHeader({
|
|||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
helperText={<ErrorMessage name={'customer_id'} />}
|
helperText={<ErrorMessage name={'customer_id'} />}
|
||||||
>
|
>
|
||||||
<CustomerSelectField
|
<ControlCustomerGroup>
|
||||||
contacts={customers}
|
<CustomerSelectField
|
||||||
selectedContactId={value}
|
contacts={customers}
|
||||||
defaultSelectText={<T id={'select_customer_account'} />}
|
selectedContactId={value}
|
||||||
onContactSelected={(customer) => {
|
defaultSelectText={<T id={'select_customer_account'} />}
|
||||||
form.setFieldValue('customer_id', customer.id);
|
onContactSelected={(customer) => {
|
||||||
setSelectCustomer(customer);
|
form.setFieldValue('customer_id', customer.id);
|
||||||
}}
|
setSelectCustomer(customer);
|
||||||
popoverFill={true}
|
}}
|
||||||
intent={inputIntent({ error, touched })}
|
popoverFill={true}
|
||||||
allowCreate={true}
|
intent={inputIntent({ error, touched })}
|
||||||
/>
|
allowCreate={true}
|
||||||
|
/>
|
||||||
|
<EstimateFormCurrencyTag />
|
||||||
|
</ControlCustomerGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
@@ -229,3 +234,9 @@ export default compose(
|
|||||||
estimateAutoIncrement: estimatesSettings?.autoIncrement,
|
estimateAutoIncrement: estimatesSettings?.autoIncrement,
|
||||||
})),
|
})),
|
||||||
)(EstimateFormHeader);
|
)(EstimateFormHeader);
|
||||||
|
|
||||||
|
const ControlCustomerGroup = styled(ControlGroup)`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
transform: none;
|
||||||
|
`;
|
||||||
|
|||||||
@@ -1,32 +1,20 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import { BaseCurrency, BaseCurrencyRoot } from 'components';
|
||||||
|
|
||||||
import { BaseCurrency } from 'components';
|
|
||||||
import { useInvoiceFormContext } from './InvoiceFormProvider';
|
import { useInvoiceFormContext } from './InvoiceFormProvider';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoice form currency tag.
|
* Invoice form currency tag.
|
||||||
*/
|
*/
|
||||||
export default function InvoiceFormCurrencyTag() {
|
export default function InvoiceFormCurrencyTag() {
|
||||||
const { isForeignCustomer } = useInvoiceFormContext();
|
const { isForeignCustomer, selectCustomer } = useInvoiceFormContext();
|
||||||
|
|
||||||
if (!isForeignCustomer) {
|
if (!isForeignCustomer) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseCurrencyTag>
|
<BaseCurrencyRoot>
|
||||||
<BaseCurrency />
|
<BaseCurrency currency={selectCustomer?.currency_code} />
|
||||||
</BaseCurrencyTag>
|
</BaseCurrencyRoot>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const BaseCurrencyTag = styled.div`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
font-size: 10px;
|
|
||||||
margin-left: 4px;
|
|
||||||
span {
|
|
||||||
background: #5c7080;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function InvoiceFormHeaderFields({
|
|||||||
invoiceNextNumber,
|
invoiceNextNumber,
|
||||||
}) {
|
}) {
|
||||||
// Invoice form context.
|
// Invoice form context.
|
||||||
const { customers, isForeignCustomer, setSelectCustomer } =
|
const { customers, isForeignCustomer,selectCustomer ,setSelectCustomer } =
|
||||||
useInvoiceFormContext();
|
useInvoiceFormContext();
|
||||||
|
|
||||||
// Handle invoice number changing.
|
// Handle invoice number changing.
|
||||||
@@ -115,7 +115,7 @@ function InvoiceFormHeaderFields({
|
|||||||
popoverFill={true}
|
popoverFill={true}
|
||||||
allowCreate={true}
|
allowCreate={true}
|
||||||
/>
|
/>
|
||||||
<InvoiceCurrencyTag isForeignCustomer={isForeignCustomer} />
|
<InvoiceCurrencyTag />
|
||||||
</ControlCustomerGroup>
|
</ControlCustomerGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { BaseCurrency, BaseCurrencyRoot } from 'components';
|
||||||
|
import { usePaymentReceiveFormContext } from './PaymentReceiveFormProvider';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Payment reecevie form currnecy tag.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export default function PaymentReceiveFormCurrencyTag() {
|
||||||
|
const { isForeignCustomer, selectCustomer } = usePaymentReceiveFormContext();
|
||||||
|
|
||||||
|
if (!isForeignCustomer) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseCurrencyRoot>
|
||||||
|
<BaseCurrency currency={selectCustomer?.currency_code} />
|
||||||
|
</BaseCurrencyRoot>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import { FastField, Field, useFormikContext, ErrorMessage } from 'formik';
|
|||||||
import { useAutofocus } from 'hooks';
|
import { useAutofocus } from 'hooks';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import styled from 'styled-components';
|
||||||
import {
|
import {
|
||||||
compose,
|
compose,
|
||||||
safeSumBy,
|
safeSumBy,
|
||||||
@@ -35,6 +36,7 @@ import {
|
|||||||
} from 'components';
|
} from 'components';
|
||||||
import { usePaymentReceiveFormContext } from './PaymentReceiveFormProvider';
|
import { usePaymentReceiveFormContext } from './PaymentReceiveFormProvider';
|
||||||
import { ACCOUNT_TYPE } from 'common/accountTypes';
|
import { ACCOUNT_TYPE } from 'common/accountTypes';
|
||||||
|
import PaymentReceiveFormCurrencyTag from './PaymentReceiveFormCurrencyTag';
|
||||||
|
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
@@ -142,22 +144,25 @@ function PaymentReceiveHeaderFields({
|
|||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
helperText={<ErrorMessage name={'customer_id'} />}
|
helperText={<ErrorMessage name={'customer_id'} />}
|
||||||
>
|
>
|
||||||
<CustomerSelectField
|
<ControlCustomerGroup>
|
||||||
contacts={customers}
|
<CustomerSelectField
|
||||||
selectedContactId={value}
|
contacts={customers}
|
||||||
defaultSelectText={<T id={'select_customer_account'} />}
|
selectedContactId={value}
|
||||||
onContactSelected={(customer) => {
|
defaultSelectText={<T id={'select_customer_account'} />}
|
||||||
form.setFieldValue('customer_id', customer.id);
|
onContactSelected={(customer) => {
|
||||||
form.setFieldValue('full_amount', '');
|
form.setFieldValue('customer_id', customer.id);
|
||||||
setSelectCustomer(customer);
|
form.setFieldValue('full_amount', '');
|
||||||
}}
|
setSelectCustomer(customer);
|
||||||
popoverFill={true}
|
}}
|
||||||
disabled={!isNewMode}
|
popoverFill={true}
|
||||||
buttonProps={{
|
disabled={!isNewMode}
|
||||||
elementRef: (ref) => (customerFieldRef.current = ref),
|
buttonProps={{
|
||||||
}}
|
elementRef: (ref) => (customerFieldRef.current = ref),
|
||||||
allowCreate={true}
|
}}
|
||||||
/>
|
allowCreate={true}
|
||||||
|
/>
|
||||||
|
<PaymentReceiveFormCurrencyTag />
|
||||||
|
</ControlCustomerGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
@@ -344,3 +349,9 @@ export default compose(
|
|||||||
withDialogActions,
|
withDialogActions,
|
||||||
withCurrentOrganization(),
|
withCurrentOrganization(),
|
||||||
)(PaymentReceiveHeaderFields);
|
)(PaymentReceiveHeaderFields);
|
||||||
|
|
||||||
|
const ControlCustomerGroup = styled(ControlGroup)`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
transform: none;
|
||||||
|
`;
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { BaseCurrency, BaseCurrencyRoot } from 'components';
|
||||||
|
import { useReceiptFormContext } from './ReceiptFormProvider';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receipt form currency tag.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export default function ReceiptFormCurrencyTag() {
|
||||||
|
const { isForeignCustomer, selectCustomer } = useReceiptFormContext();
|
||||||
|
|
||||||
|
if (!isForeignCustomer) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseCurrencyRoot>
|
||||||
|
<BaseCurrency currency={selectCustomer?.currency_code} />
|
||||||
|
</BaseCurrencyRoot>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@ import { FormattedMessage as T } from 'components';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { FastField, ErrorMessage } from 'formik';
|
import { FastField, ErrorMessage } from 'formik';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AccountsSelectList,
|
AccountsSelectList,
|
||||||
CustomerSelectField,
|
CustomerSelectField,
|
||||||
@@ -29,6 +31,7 @@ import {
|
|||||||
handleDateChange,
|
handleDateChange,
|
||||||
inputIntent,
|
inputIntent,
|
||||||
} from 'utils';
|
} from 'utils';
|
||||||
|
import ReceiptFormCurrencyTag from './ReceiptFormCurrencyTag';
|
||||||
import { useReceiptFormContext } from './ReceiptFormProvider';
|
import { useReceiptFormContext } from './ReceiptFormProvider';
|
||||||
import {
|
import {
|
||||||
accountsFieldShouldUpdate,
|
accountsFieldShouldUpdate,
|
||||||
@@ -91,17 +94,20 @@ function ReceiptFormHeader({
|
|||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
helperText={<ErrorMessage name={'customer_id'} />}
|
helperText={<ErrorMessage name={'customer_id'} />}
|
||||||
>
|
>
|
||||||
<CustomerSelectField
|
<ControlCustomerGroup>
|
||||||
contacts={customers}
|
<CustomerSelectField
|
||||||
selectedContactId={value}
|
contacts={customers}
|
||||||
defaultSelectText={<T id={'select_customer_account'} />}
|
selectedContactId={value}
|
||||||
onContactSelected={(customer) => {
|
defaultSelectText={<T id={'select_customer_account'} />}
|
||||||
form.setFieldValue('customer_id', customer.id);
|
onContactSelected={(customer) => {
|
||||||
setSelectCustomer(customer);
|
form.setFieldValue('customer_id', customer.id);
|
||||||
}}
|
setSelectCustomer(customer);
|
||||||
popoverFill={true}
|
}}
|
||||||
allowCreate={true}
|
popoverFill={true}
|
||||||
/>
|
allowCreate={true}
|
||||||
|
/>
|
||||||
|
<ReceiptFormCurrencyTag />
|
||||||
|
</ControlCustomerGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
@@ -242,3 +248,9 @@ export default compose(
|
|||||||
receiptNumberPrefix: receiptSettings?.numberPrefix,
|
receiptNumberPrefix: receiptSettings?.numberPrefix,
|
||||||
})),
|
})),
|
||||||
)(ReceiptFormHeader);
|
)(ReceiptFormHeader);
|
||||||
|
|
||||||
|
const ControlCustomerGroup = styled(ControlGroup)`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
transform: none;
|
||||||
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user