mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: calculate total amount of form entries.
This commit is contained in:
@@ -10,9 +10,8 @@ export default function PageFormBigNumber({ label, amount, currencyCode }) {
|
||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER_BIG_NUMBERS)}>
|
||||
<div class="big-amount">
|
||||
<span class="big-amount__label">{ label }</span>
|
||||
|
||||
<h1 class="big-amount__number">
|
||||
<Money amount={0} currency={'LYD'} />
|
||||
<Money amount={amount} currency={currencyCode} />
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { useState, useMemo, useEffect, useCallback } from 'react';
|
||||
import { omit } from 'lodash';
|
||||
import { Button, Intent, Position, Tooltip } from '@blueprintjs/core';
|
||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||
import classNames from 'classnames';
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { sumBy } from 'lodash';
|
||||
import { useFormikContext } from 'formik';
|
||||
|
||||
import { CLASSES } from 'common/classes';
|
||||
|
||||
@@ -8,15 +10,21 @@ import { PageFormBigNumber } from 'components';
|
||||
|
||||
// Expense form header.
|
||||
export default function ExpenseFormHeader() {
|
||||
const { values } = useFormikContext();
|
||||
|
||||
// Calculates the expense entries amount.
|
||||
const totalExpenseAmount = useMemo(() => sumBy(values.categories, 'amount'), [
|
||||
values.categories,
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
|
||||
<ExpenseFormHeaderFields />
|
||||
|
||||
<PageFormBigNumber
|
||||
label={'Expense Amount'}
|
||||
amount={0}
|
||||
amount={totalExpenseAmount}
|
||||
currencyCode={'LYD'}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { sumBy } from 'lodash';
|
||||
import { useFormikContext } from 'formik';
|
||||
|
||||
import { CLASSES } from 'common/classes';
|
||||
|
||||
@@ -10,11 +12,21 @@ import { PageFormBigNumber } from 'components';
|
||||
* Fill form header.
|
||||
*/
|
||||
export default function BillFormHeader({ onBillNumberChanged }) {
|
||||
const { values } = useFormikContext();
|
||||
|
||||
// Calculate the total due amount of bill entries.
|
||||
const totalDueAmount = useMemo(() => sumBy(values.entries, 'total'), [
|
||||
values.entries,
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
|
||||
<BillFormHeaderFields onBillNumberChanged={onBillNumberChanged} />
|
||||
|
||||
<PageFormBigNumber label={'Due Amount'} amount={0} currencyCode={'LYD'} />
|
||||
<PageFormBigNumber
|
||||
label={'Due Amount'}
|
||||
amount={totalDueAmount}
|
||||
currencyCode={'LYD'}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import { compose } from 'utils';
|
||||
import classNames from 'classnames';
|
||||
import { sumBy } from 'lodash';
|
||||
import { useFormikContext } from 'formik';
|
||||
|
||||
import { CLASSES } from 'common/classes';
|
||||
|
||||
import { PageFormBigNumber } from 'components';
|
||||
@@ -10,17 +13,28 @@ import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
|
||||
import EstimateFormHeaderFields from './EstimateFormHeaderFields';
|
||||
|
||||
// Estimate form top header.
|
||||
function EstimateFormHeader({
|
||||
// #ownProps
|
||||
onEstimateNumberChanged,
|
||||
}) {
|
||||
const { values } = useFormikContext();
|
||||
|
||||
// Calculate the total due amount of bill entries.
|
||||
const totalDueAmount = useMemo(() => sumBy(values.entries, 'total'), [
|
||||
values.entries,
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
|
||||
<EstimateFormHeaderFields
|
||||
onEstimateNumberChanged={onEstimateNumberChanged}
|
||||
/>
|
||||
|
||||
<PageFormBigNumber label={'Amount'} amount={0} currencyCode={'LYD'} />
|
||||
<PageFormBigNumber
|
||||
label={'Amount'}
|
||||
amount={totalDueAmount}
|
||||
currencyCode={'LYD'}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ function InvoiceForm({
|
||||
},
|
||||
[changePageSubtitle],
|
||||
);
|
||||
|
||||
|
||||
return (
|
||||
<div className={classNames(
|
||||
CLASSES.PAGE_FORM,
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { sumBy } from 'lodash';
|
||||
import { useFormikContext } from 'formik';
|
||||
|
||||
import { CLASSES } from 'common/classes';
|
||||
|
||||
import InvoiceFormHeaderFields from './InvoiceFormHeaderFields';
|
||||
@@ -12,17 +15,23 @@ export default function InvoiceFormHeader({
|
||||
// #ownProps
|
||||
onInvoiceNumberChanged,
|
||||
}) {
|
||||
const { values } = useFormikContext();
|
||||
|
||||
// Calculate the total due amount of invoice entries.
|
||||
const totalDueAmount = useMemo(() => sumBy(values.entries, 'total'), [
|
||||
values.entries,
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
|
||||
<InvoiceFormHeaderFields
|
||||
onInvoiceNumberChanged={onInvoiceNumberChanged}
|
||||
/>
|
||||
|
||||
<PageFormBigNumber
|
||||
label={'Due Amount'}
|
||||
amount={0}
|
||||
amount={totalDueAmount}
|
||||
currencyCode={'LYD'}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,34 @@
|
||||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { sumBy } from 'lodash';
|
||||
import { useFormikContext } from 'formik';
|
||||
|
||||
import { Money } from 'components';
|
||||
import { CLASSES } from 'common/classes';
|
||||
import ReceiptFormHeaderFields from './ReceiptFormHeaderFields';
|
||||
|
||||
import { PageFormBigNumber } from 'components';
|
||||
|
||||
export default function ReceiptFormHeader({
|
||||
// #ownProps
|
||||
onReceiptNumberChanged,
|
||||
}) {
|
||||
const { values } = useFormikContext();
|
||||
|
||||
// Calculate the total due amount of bill entries.
|
||||
const totalDueAmount = useMemo(() => sumBy(values.entries, 'total'), [
|
||||
values.entries,
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
|
||||
<ReceiptFormHeaderFields
|
||||
onReceiptNumberChanged={onReceiptNumberChanged}
|
||||
/>
|
||||
|
||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER_BIG_NUMBERS)}>
|
||||
<div class="big-amount">
|
||||
<span class="big-amount__label">Due Amount</span>
|
||||
<h1 class="big-amount__number">
|
||||
<Money amount={0} currency={'LYD'} />
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
<PageFormBigNumber
|
||||
label={'Due Amount'}
|
||||
amount={totalDueAmount}
|
||||
currencyCode={'LYD'}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user