mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
fix: (*): fix currency code.
This commit is contained in:
@@ -12,15 +12,16 @@ export default function MakeJournalEntriesField() {
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
|
||||
<FastField name={'entries'}>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
{({ form:{values ,setFieldValue}, field: { value }, meta: { error, touched } }) => (
|
||||
<MakeJournalEntriesTable
|
||||
onChange={(entries) => {
|
||||
form.setFieldValue('entries', entries);
|
||||
setFieldValue('entries', entries);
|
||||
}}
|
||||
entries={value}
|
||||
defaultEntry={defaultEntry}
|
||||
initialLinesNumber={MIN_LINES_NUMBER}
|
||||
error={error}
|
||||
currencyCode={values.currency_code}
|
||||
/>
|
||||
)}
|
||||
</FastField>
|
||||
|
||||
@@ -65,10 +65,10 @@ function MakeJournalEntriesForm({
|
||||
}
|
||||
: {
|
||||
...defaultManualJournal,
|
||||
...(journalAutoIncrement) && ({
|
||||
...(journalAutoIncrement && {
|
||||
journal_number: defaultTo(journalNumber, ''),
|
||||
}),
|
||||
currency_code: defaultTo(baseCurrency, ''),
|
||||
currency_code: baseCurrency,
|
||||
entries: orderingLinesIndexes(defaultManualJournal.entries),
|
||||
}),
|
||||
}),
|
||||
@@ -111,7 +111,7 @@ function MakeJournalEntriesForm({
|
||||
}
|
||||
const form = {
|
||||
...omit(values, ['journal_number', 'journal_number_manually']),
|
||||
...(values.journal_number_manually) && ({
|
||||
...(values.journal_number_manually && {
|
||||
journal_number: values.journal_number,
|
||||
}),
|
||||
entries,
|
||||
|
||||
@@ -2,12 +2,14 @@ import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { CLASSES } from 'common/classes';
|
||||
import MakeJournalEntriesHeaderFields from "./MakeJournalEntriesHeaderFields";
|
||||
import MakeJournalEntriesHeaderFields from './MakeJournalEntriesHeaderFields';
|
||||
import { PageFormBigNumber } from 'components';
|
||||
import { safeSumBy } from 'utils';
|
||||
|
||||
export default function MakeJournalEntriesHeader() {
|
||||
const { values: { entries } } = useFormikContext();
|
||||
const {
|
||||
values: { entries, currency_code },
|
||||
} = useFormikContext();
|
||||
const totalCredit = safeSumBy(entries, 'credit');
|
||||
const totalDebit = safeSumBy(entries, 'debit');
|
||||
|
||||
@@ -20,8 +22,8 @@ export default function MakeJournalEntriesHeader() {
|
||||
<PageFormBigNumber
|
||||
label={'Due Amount'}
|
||||
amount={total}
|
||||
currencyCode={'USD'}
|
||||
currencyCode={currency_code}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ export default function MakeJournalEntriesTable({
|
||||
error,
|
||||
initialLinesNumber = 4,
|
||||
minLinesNumber = 4,
|
||||
currencyCode,
|
||||
}) {
|
||||
const { accounts, customers } = useMakeJournalFormContext();
|
||||
|
||||
@@ -72,7 +73,8 @@ export default function MakeJournalEntriesTable({
|
||||
contact_type: 'customer',
|
||||
})),
|
||||
autoFocus: ['account_id', 0],
|
||||
currencyCode,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import React from 'react';
|
||||
import { Intent, Position, Button, Tooltip } from '@blueprintjs/core';
|
||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||
import { FormattedMessage as T } from 'react-intl';
|
||||
import { Icon, Money, Hint } from 'components';
|
||||
import { formatMessage } from 'services/intl';
|
||||
import {
|
||||
AccountsListFieldCell,
|
||||
MoneyFieldCell,
|
||||
@@ -25,22 +26,36 @@ export function ContactHeaderCell() {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Credit header cell.
|
||||
*/
|
||||
export function CreditHeaderCell({ payload: { currencyCode } }) {
|
||||
return formatMessage({ id: 'credit_currency' }, { currency: currencyCode });
|
||||
}
|
||||
|
||||
/**
|
||||
* debit header cell.
|
||||
*/
|
||||
export function DebitHeaderCell({ payload: { currencyCode } }) {
|
||||
return formatMessage({ id: 'debit_currency' }, { currency: currencyCode });
|
||||
}
|
||||
|
||||
/**
|
||||
* Account footer cell.
|
||||
*/
|
||||
function AccountFooterCell() {
|
||||
return <span>{'Total USD'}</span>;
|
||||
function AccountFooterCell({ payload: { currencyCode } }) {
|
||||
return <span>{`Total ${currencyCode} `}</span>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Total credit table footer cell.
|
||||
*/
|
||||
function TotalCreditFooterCell({ rows }) {
|
||||
function TotalCreditFooterCell({ payload: { currencyCode }, rows }) {
|
||||
const credit = safeSumBy(rows, 'original.credit');
|
||||
|
||||
return (
|
||||
<span>
|
||||
<Money amount={credit} currency={'USD'} />
|
||||
<Money amount={credit} currency={currencyCode} />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -48,12 +63,12 @@ function TotalCreditFooterCell({ rows }) {
|
||||
/**
|
||||
* Total debit table footer cell.
|
||||
*/
|
||||
function TotalDebitFooterCell({ rows }) {
|
||||
function TotalDebitFooterCell({ payload: { currencyCode }, rows }) {
|
||||
const debit = safeSumBy(rows, 'original.debit');
|
||||
|
||||
return (
|
||||
<span>
|
||||
<Money amount={debit} currency={'USD'} />
|
||||
<Money amount={debit} currency={currencyCode} />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -88,8 +103,6 @@ export const ActionsCellRenderer = ({
|
||||
* Retrieve columns of make journal entries table.
|
||||
*/
|
||||
export const useJournalTableEntriesColumns = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
return React.useMemo(
|
||||
() => [
|
||||
{
|
||||
@@ -113,7 +126,7 @@ export const useJournalTableEntriesColumns = () => {
|
||||
width: 160,
|
||||
},
|
||||
{
|
||||
Header: formatMessage({ id: 'credit_currency' }, { currency: 'USD' }),
|
||||
Header: CreditHeaderCell,
|
||||
accessor: 'credit',
|
||||
Cell: MoneyFieldCell,
|
||||
Footer: TotalCreditFooterCell,
|
||||
@@ -122,7 +135,7 @@ export const useJournalTableEntriesColumns = () => {
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
Header: formatMessage({ id: 'debit_currency' }, { currency: 'USD' }),
|
||||
Header: DebitHeaderCell,
|
||||
accessor: 'debit',
|
||||
Cell: MoneyFieldCell,
|
||||
Footer: TotalDebitFooterCell,
|
||||
|
||||
Reference in New Issue
Block a user