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

@@ -8,23 +8,17 @@ import VendorCreditNoteFormHeaderFields from './VendorCreditNoteFormHeaderFields
import { getEntriesTotal } from 'containers/Entries/utils';
import { PageFormBigNumber } from 'components';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { compose } from 'utils';
/**
* Vendor Credit note header.
*/
function VendorCreditNoteFormHeader({
// #withCurrentOrganization
organization: { base_currency },
}) {
const { values } = useFormikContext();
function VendorCreditNoteFormHeader() {
const { values:{entries ,currency_code} } = useFormikContext();
// Calculate the total amount.
const totalAmount = React.useMemo(
() => getEntriesTotal(values.entries),
[values.entries],
() => getEntriesTotal(entries),
[entries],
);
return (
@@ -33,10 +27,10 @@ function VendorCreditNoteFormHeader({
<PageFormBigNumber
label={intl.get('vendor_credits.label.amount_to_credit')}
amount={totalAmount}
currencyCode={base_currency}
currencyCode={currency_code}
/>
</div>
);
}
export default compose(withCurrentOrganization())(VendorCreditNoteFormHeader);
export default VendorCreditNoteFormHeader;

View File

@@ -108,6 +108,7 @@ function VendorCreditNoteFormHeaderFields({
onContactSelected={(contact) => {
form.setFieldValue('vendor_id', contact.id);
form.setFieldValue('exchange_rate', '');
form.setFieldValue('currency_code', contact?.currency_code);
setSelectVendor(contact);
}}
popoverFill={true}