mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
feat(invoice detail): add exchange rate detail.
This commit is contained in:
@@ -1,33 +1,34 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { DetailItem } from 'components';
|
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
import * as R from 'ramda';
|
||||||
import { useSelector } from 'react-redux';
|
import { DetailItem } from 'components';
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
|
|
||||||
const organizationBaseCurrecy = createSelector(
|
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
|
||||||
(state) => {
|
|
||||||
const tenantId = state.authentication.tenantId;
|
|
||||||
return state.organizations.data[tenantId];
|
|
||||||
},
|
|
||||||
(organization) => organization?.base_currency,
|
|
||||||
);
|
|
||||||
|
|
||||||
export function ExchangeRateDetailItem({
|
/**
|
||||||
// #ownProps
|
* Detail exchange rate item.
|
||||||
|
* @param {*} param0
|
||||||
|
* @param {*} param1
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function DetailExchangeRate({
|
||||||
exchangeRate,
|
exchangeRate,
|
||||||
toCurrency,
|
toCurrency,
|
||||||
|
// #withCurrentOrganization
|
||||||
|
organization: { base_currency },
|
||||||
}) {
|
}) {
|
||||||
const fromCurrency = useSelector(organizationBaseCurrecy);
|
if (isEqual(base_currency, toCurrency)) {
|
||||||
|
|
||||||
if (isEqual(fromCurrency, toCurrency)) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DetailItem label={intl.get('invoice.details.exchange_rate')}>
|
<DetailItem label={intl.get('invoice.details.exchange_rate')}>
|
||||||
1 {fromCurrency} = {exchangeRate} {toCurrency}
|
1 {base_currency} = {exchangeRate} {toCurrency}
|
||||||
</DetailItem>
|
</DetailItem>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const ExchangeRateDetailItem = R.compose(withCurrentOrganization())(
|
||||||
|
DetailExchangeRate,
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user