mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
feat (invoice detail): deatil exhange rate item.
This commit is contained in:
33
src/components/DetailExchangeRate.js
Normal file
33
src/components/DetailExchangeRate.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import React from 'react';
|
||||
import { DetailItem } from 'components';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import { useSelector } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
const organizationBaseCurrecy = createSelector(
|
||||
(state) => {
|
||||
const tenantId = state.authentication.tenantId;
|
||||
return state.organizations.data[tenantId];
|
||||
},
|
||||
(organization) => organization?.base_currency,
|
||||
);
|
||||
|
||||
export function ExchangeRateDetailItem({
|
||||
// #ownProps
|
||||
exchangeRate,
|
||||
toCurrency,
|
||||
}) {
|
||||
const fromCurrency = useSelector(organizationBaseCurrecy);
|
||||
|
||||
if (isEqual(fromCurrency, toCurrency)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<DetailItem label={intl.get('invoice.details.exchange_rate')}>
|
||||
1 {fromCurrency} = {exchangeRate} {toCurrency}
|
||||
</DetailItem>
|
||||
);
|
||||
}
|
||||
@@ -55,6 +55,7 @@ import AvaterCell from './AvaterCell';
|
||||
import { ItemsMultiSelect } from './Items';
|
||||
import MoreMenuItems from './MoreMenutItems';
|
||||
import CustomSelectList from './CustomSelectList';
|
||||
import { ExchangeRateDetailItem } from './DetailExchangeRate';
|
||||
|
||||
export * from './Dialog';
|
||||
export * from './Menu';
|
||||
@@ -169,4 +170,5 @@ export {
|
||||
AvaterCell,
|
||||
MoreMenuItems,
|
||||
CustomSelectList,
|
||||
ExchangeRateDetailItem,
|
||||
};
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
CommercialDocHeader,
|
||||
CommercialDocTopHeader,
|
||||
CustomerDrawerLink,
|
||||
// DetailExchangeRate,
|
||||
ExchangeRateDetailItem,
|
||||
} from 'components';
|
||||
import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider';
|
||||
import { InvoiceDetailsStatus } from './utils';
|
||||
@@ -59,6 +61,10 @@ export default function InvoiceDetailHeader() {
|
||||
<DetailItem label={intl.get('invoice.details.invoice_no')}>
|
||||
{invoice.invoice_no}
|
||||
</DetailItem>
|
||||
<ExchangeRateDetailItem
|
||||
exchangeRate={invoice?.exchange_rate}
|
||||
toCurrency={invoice?.currency_code}
|
||||
/>
|
||||
</DetailsMenu>
|
||||
</Col>
|
||||
|
||||
|
||||
@@ -1222,6 +1222,7 @@
|
||||
"invoice.details.payment_amount": "Payment amount",
|
||||
"invoice.details.invoice_message": "Invoice Message",
|
||||
"invoice.details.invoice_no": "Invoice #",
|
||||
"invoice.details.exchange_rate": "Exchange rate",
|
||||
"bill.drawer.title": "Bill details {number}",
|
||||
"bill.details.reference": "Reference #",
|
||||
"bill.details.bill_number": "Bill #",
|
||||
|
||||
Reference in New Issue
Block a user