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

@@ -7,10 +7,7 @@ import { CLASSES } from 'common/classes';
import { PageFormBigNumber } from 'components';
import ReceiptFormHeaderFields from './ReceiptFormHeaderFields';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { getEntriesTotal } from 'containers/Entries/utils';
import { compose } from 'redux';
/**
* Receipt form header section.
@@ -18,16 +15,13 @@ import { compose } from 'redux';
function ReceiptFormHeader({
// #ownProps
onReceiptNumberChanged,
// #withCurrentOrganization
organization: { base_currency },
}) {
const { values } = useFormikContext();
const {
values: { currency_code, entries },
} = useFormikContext();
// Calculate the total due amount of bill entries.
const totalDueAmount = useMemo(
() => getEntriesTotal(values.entries),
[values.entries],
);
const totalDueAmount = useMemo(() => getEntriesTotal(entries), [entries]);
return (
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
@@ -37,10 +31,10 @@ function ReceiptFormHeader({
<PageFormBigNumber
label={intl.get('due_amount')}
amount={totalDueAmount}
currencyCode={base_currency}
currencyCode={currency_code}
/>
</div>
);
}
export default compose(withCurrentOrganization())(ReceiptFormHeader);
export default ReceiptFormHeader;

View File

@@ -108,6 +108,7 @@ function ReceiptFormHeader({
onContactSelected={(customer) => {
form.setFieldValue('customer_id', customer.id);
form.setFieldValue('exchange_rate', '');
form.setFieldValue('currency_code', customer?.currency_code);
setSelectCustomer(customer);
}}
popoverFill={true}