feat(invoice): fix invoice currency tag.

This commit is contained in:
elforjani13
2022-02-14 12:06:58 +02:00
parent 9f466ba4df
commit bd63e35489
5 changed files with 89 additions and 66 deletions

View File

@@ -1,38 +1,18 @@
import React from 'react'; import React from 'react';
import * as R from 'ramda'; import * as R from 'ramda';
import styled from 'styled-components'; import styled from 'styled-components';
import { CurrencyTag } from 'components'; import { CurrencyTag } from 'components';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization'; import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
/** /**
* base currency sign. * base currecncy.
*/ */
function BaseCurrency({ function BaseCurrency({
// #withCurrentOrganization // #withCurrentOrganization
organization: { base_currency }, organization: { base_currency },
isForeignCustomer,
}) { }) {
return <CurrencyTag>{base_currency}</CurrencyTag>;
if (isForeignCustomer) {
return null;
}
return (
<BaseCurrencySign>
<CurrencyTag>{base_currency}</CurrencyTag>
</BaseCurrencySign>
);
} }
export default R.compose(withCurrentOrganization())(BaseCurrency); export default R.compose(withCurrentOrganization())(BaseCurrency);
const BaseCurrencySign = styled.div`
display: flex;
align-items: center;
font-size: 10px;
margin-left: 5px;
span {
background: #5c7080;
}
`;

View File

@@ -54,7 +54,8 @@ 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';
@@ -89,8 +90,8 @@ export * from './TextStatus';
export * from './Tags'; export * from './Tags';
export * from './CommercialDoc'; export * from './CommercialDoc';
export * from './Card'; export * from './Card';
export * from './Customers' export * from './Customers';
export * from './Vendors' export * from './Vendors';
export * from './Table'; export * from './Table';
export * from './Skeleton'; export * from './Skeleton';
export * from './FinancialStatement'; export * from './FinancialStatement';
@@ -162,6 +163,8 @@ export {
MoneyFieldCell, MoneyFieldCell,
ItemsMultiSelect, ItemsMultiSelect,
AvaterCell, AvaterCell,
BaseCurrency,
MoreMenuItems, MoreMenuItems,
CustomSelectList CustomSelectList,
}; };

View File

@@ -0,0 +1,32 @@
import React from 'react';
import styled from 'styled-components';
import { BaseCurrency } from 'components';
import { useInvoiceFormContext } from './InvoiceFormProvider';
/**
* Invoice form currency tag.
*/
export default function InvoiceFormCurrencyTag() {
const { isForeignCustomer } = useInvoiceFormContext();
if (!isForeignCustomer) {
return null;
}
return (
<BaseCurrencyTag>
<BaseCurrency />
</BaseCurrencyTag>
);
}
const BaseCurrencyTag = styled.div`
display: flex;
align-items: center;
font-size: 10px;
margin-left: 4px;
span {
background: #5c7080;
}
`;

View File

@@ -33,7 +33,7 @@ import { useInvoiceFormContext } from './InvoiceFormProvider';
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 { inputIntent, handleDateChange } from 'utils'; import { inputIntent, handleDateChange } from 'utils';
import BaseCurrency from './BaseCurrency'; import InvoiceCurrencyTag from './InvoiceFormCurrencyTag';
const Data = [ const Data = [
{ {
@@ -104,7 +104,7 @@ function InvoiceFormHeaderFields({
intent={inputIntent({ error, touched })} intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'customer_id'} />} helperText={<ErrorMessage name={'customer_id'} />}
> >
<ControlGroup> <ControlCustomerGroup>
<CustomerSelectField <CustomerSelectField
contacts={customers} contacts={customers}
selectedContactId={value} selectedContactId={value}
@@ -115,13 +115,14 @@ function InvoiceFormHeaderFields({
popoverFill={true} popoverFill={true}
allowCreate={true} allowCreate={true}
/> />
<BaseCurrency isForeignCustomer={isForeignCustomer} /> <InvoiceCurrencyTag isForeignCustomer={isForeignCustomer} />
</ControlGroup> </ControlCustomerGroup>
</FormGroup> </FormGroup>
)} )}
</FastField> </FastField>
{/* ----------- Exchange reate ----------- */} {/* ----------- Exchange reate ----------- */}
<If condition={isForeignCustomer}>
<ExchangeRateField> <ExchangeRateField>
<Field name={'exchange_rate'}> <Field name={'exchange_rate'}>
{({ {({
@@ -156,6 +157,7 @@ function InvoiceFormHeaderFields({
)} )}
</Field> </Field>
</ExchangeRateField> </ExchangeRateField>
</If>
<Row> <Row>
<Col xs={6}> <Col xs={6}>
@@ -325,3 +327,9 @@ const ExchangeRateTag = styled.div`
font-size: 10px; font-size: 10px;
line-height: 1.6; line-height: 1.6;
`; `;
const ControlCustomerGroup = styled(ControlGroup)`
display: flex;
align-items: center;
transform: none;
`;

View File

@@ -78,7 +78,7 @@ function InvoiceFormProvider({ invoiceId, ...props }) {
const isFeatureLoading = isWarehouesLoading || isBranchesLoading; const isFeatureLoading = isWarehouesLoading || isBranchesLoading;
// Determines whether the foreign customer. // Determines whether the foreign customer.
const isForeignCustomer = true; const isForeignCustomer = false;
// Provider payload. // Provider payload.
const provider = { const provider = {