feat(Sales & Purchases ): add currency in header & entries.

This commit is contained in:
elforjani13
2022-02-23 14:47:12 +02:00
parent e6a7c7bc58
commit 22eb7a1cc1
17 changed files with 83 additions and 106 deletions

View File

@@ -9,24 +9,16 @@ import InvoiceFormHeaderFields from './InvoiceFormHeaderFields';
import { getEntriesTotal } from 'containers/Entries/utils';
import { PageFormBigNumber } from 'components';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { compose } from 'redux';
/**
* Invoice form header section.
*/
function InvoiceFormHeader({
// #withCurrentOrganization
organization: { base_currency },
}) {
const { values } = useFormikContext();
function InvoiceFormHeader() {
const {
values: { currency_code, entries },
} = useFormikContext();
// Calculate the total due amount of invoice entries.
const totalDueAmount = useMemo(
() => getEntriesTotal(values.entries),
[values.entries],
);
const totalDueAmount = useMemo(() => getEntriesTotal(entries), [entries]);
return (
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
@@ -34,9 +26,9 @@ function InvoiceFormHeader({
<PageFormBigNumber
label={intl.get('due_amount')}
amount={totalDueAmount}
currencyCode={base_currency}
currencyCode={currency_code}
/>
</div>
);
}
export default compose(withCurrentOrganization())(InvoiceFormHeader);
export default InvoiceFormHeader;