mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat(Sales & Purchases ): add currency in header & entries.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -116,6 +116,7 @@ function InvoiceFormHeaderFields({
|
||||
onContactSelected={(customer) => {
|
||||
form.setFieldValue('customer_id', customer.id);
|
||||
form.setFieldValue('exchange_rate', '');
|
||||
form.setFieldValue('currency_code', customer?.currency_code);
|
||||
setSelectCustomer(customer);
|
||||
}}
|
||||
popoverFill={true}
|
||||
|
||||
@@ -91,6 +91,10 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
|
||||
!isEqual(selectCustomer?.currency_code, baseCurrency) &&
|
||||
!isUndefined(selectCustomer?.currency_code);
|
||||
|
||||
const currencyCode = isForeignCustomer
|
||||
? selectCustomer?.currency_code
|
||||
: baseCurrency;
|
||||
|
||||
const provider = {
|
||||
invoice,
|
||||
items,
|
||||
@@ -103,6 +107,7 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
|
||||
baseCurrency,
|
||||
branches,
|
||||
warehouses,
|
||||
currencyCode,
|
||||
|
||||
isInvoiceLoading,
|
||||
isItemsLoading,
|
||||
|
||||
Reference in New Issue
Block a user