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