mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
fix: (*): fix currency code.
This commit is contained in:
@@ -6,20 +6,23 @@ import { defaultExpenseEntry } from './utils';
|
||||
/**
|
||||
* Expense form entries field.
|
||||
*/
|
||||
export default function ExpenseFormEntriesField({
|
||||
linesNumber = 4,
|
||||
}) {
|
||||
export default function ExpenseFormEntriesField({ linesNumber = 4 }) {
|
||||
return (
|
||||
<FastField name={'categories'}>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
{({
|
||||
form: { values, setFieldValue },
|
||||
field: { value },
|
||||
meta: { error, touched },
|
||||
}) => (
|
||||
<ExpenseFormEntriesTable
|
||||
entries={value}
|
||||
error={error}
|
||||
onChange={(entries) => {
|
||||
form.setFieldValue('categories', entries);
|
||||
setFieldValue('categories', entries);
|
||||
}}
|
||||
defaultEntry={defaultExpenseEntry}
|
||||
linesNumber={linesNumber}
|
||||
currencyCode={values.currency_code}
|
||||
/>
|
||||
)}
|
||||
</FastField>
|
||||
|
||||
@@ -21,6 +21,7 @@ export default function ExpenseFormEntriesTable({
|
||||
defaultEntry,
|
||||
error,
|
||||
onChange,
|
||||
currencyCode,
|
||||
}) {
|
||||
// Expense form context.
|
||||
const { accounts } = useExpenseFormContext();
|
||||
@@ -69,6 +70,7 @@ export default function ExpenseFormEntriesTable({
|
||||
updateData: handleUpdateData,
|
||||
removeRow: handleRemoveRow,
|
||||
autoFocus: ['expense_account_id', 0],
|
||||
currencyCode
|
||||
}}
|
||||
footer={true}
|
||||
/>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import React from 'react';
|
||||
import { Button, Tooltip, Intent, Position } from '@blueprintjs/core';
|
||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||
import { FormattedMessage as T } from 'react-intl';
|
||||
import { Icon, Hint } from 'components';
|
||||
import { formatMessage } from 'services/intl';
|
||||
import {
|
||||
InputGroupCell,
|
||||
MoneyFieldCell,
|
||||
@@ -51,9 +52,16 @@ const ActionsCellRenderer = ({
|
||||
/**
|
||||
* Amount footer cell.
|
||||
*/
|
||||
function AmountFooterCell({ rows }) {
|
||||
function AmountFooterCell({ payload: { currencyCode }, rows }) {
|
||||
const total = safeSumBy(rows, 'original.amount');
|
||||
return <span>{formattedAmount(total, 'USD')}</span>;
|
||||
return <span>{formattedAmount(total, currencyCode)}</span>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expense amount header cell.
|
||||
*/
|
||||
export function ExpenseAmountHeaderCell({ payload: { currencyCode } }) {
|
||||
return formatMessage({ id: 'amount_currency' }, { currency: currencyCode });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +75,6 @@ function ExpenseAccountFooterCell() {
|
||||
* Retrieve expense form table entries columns.
|
||||
*/
|
||||
export function useExpenseFormTableColumns() {
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
return React.useMemo(
|
||||
() => [
|
||||
@@ -92,7 +99,7 @@ export function useExpenseFormTableColumns() {
|
||||
filterAccountsByRootTypes: ['expense'],
|
||||
},
|
||||
{
|
||||
Header: formatMessage({ id: 'amount_currency' }, { currency: 'USD' }),
|
||||
Header: ExpenseAmountHeaderCell,
|
||||
accessor: 'amount',
|
||||
Cell: MoneyFieldCell,
|
||||
Footer: AmountFooterCell,
|
||||
|
||||
Reference in New Issue
Block a user