diff --git a/client/src/components/PageFormBigNumber.js b/client/src/components/PageFormBigNumber.js
index c8cbb1c29..c32f52b5c 100644
--- a/client/src/components/PageFormBigNumber.js
+++ b/client/src/components/PageFormBigNumber.js
@@ -10,9 +10,8 @@ export default function PageFormBigNumber({ label, amount, currencyCode }) {
diff --git a/client/src/containers/Entries/ItemsEntriesTable.js b/client/src/containers/Entries/ItemsEntriesTable.js
index 94732613d..6bf128c04 100644
--- a/client/src/containers/Entries/ItemsEntriesTable.js
+++ b/client/src/containers/Entries/ItemsEntriesTable.js
@@ -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';
diff --git a/client/src/containers/Expenses/ExpenseFormHeader.js b/client/src/containers/Expenses/ExpenseFormHeader.js
index 5c7ab8f6c..1e9122607 100644
--- a/client/src/containers/Expenses/ExpenseFormHeader.js
+++ b/client/src/containers/Expenses/ExpenseFormHeader.js
@@ -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 (
- )
-}
\ No newline at end of file
+ );
+}
diff --git a/client/src/containers/Purchases/Bill/BillFormHeader.js b/client/src/containers/Purchases/Bill/BillFormHeader.js
index 951c034fe..cae61d061 100644
--- a/client/src/containers/Purchases/Bill/BillFormHeader.js
+++ b/client/src/containers/Purchases/Bill/BillFormHeader.js
@@ -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 (
);
}
diff --git a/client/src/containers/Sales/Estimate/EstimateFormHeader.js b/client/src/containers/Sales/Estimate/EstimateFormHeader.js
index 8e97a427f..20b4d57f1 100644
--- a/client/src/containers/Sales/Estimate/EstimateFormHeader.js
+++ b/client/src/containers/Sales/Estimate/EstimateFormHeader.js
@@ -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 (
);
}
diff --git a/client/src/containers/Sales/Invoice/InvoiceForm.js b/client/src/containers/Sales/Invoice/InvoiceForm.js
index 646f0f05f..ae682266c 100644
--- a/client/src/containers/Sales/Invoice/InvoiceForm.js
+++ b/client/src/containers/Sales/Invoice/InvoiceForm.js
@@ -229,7 +229,7 @@ function InvoiceForm({
},
[changePageSubtitle],
);
-
+
return (
sumBy(values.entries, 'total'), [
+ values.entries,
+ ]);
+
return (
);
-}
\ No newline at end of file
+}
diff --git a/client/src/containers/Sales/Receipt/ReceiptFormHeader.js b/client/src/containers/Sales/Receipt/ReceiptFormHeader.js
index 694ec9244..5b1c9796d 100644
--- a/client/src/containers/Sales/Receipt/ReceiptFormHeader.js
+++ b/client/src/containers/Sales/Receipt/ReceiptFormHeader.js
@@ -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 (
);
}