diff --git a/src/containers/FinancialStatements/PurchasesByItems/PurchasesByItems.js b/src/containers/FinancialStatements/PurchasesByItems/PurchasesByItems.js
index f411f2040..79ff403f7 100644
--- a/src/containers/FinancialStatements/PurchasesByItems/PurchasesByItems.js
+++ b/src/containers/FinancialStatements/PurchasesByItems/PurchasesByItems.js
@@ -3,31 +3,30 @@ import moment from 'moment';
import 'style/pages/FinancialStatements/SalesAndPurchasesSheet.scss';
+import { FinancialStatement } from 'components';
+
import { PurchasesByItemsProvider } from './PurchasesByItemsProvider';
import PurchasesByItemsActionsBar from './PurchasesByItemsActionsBar';
import PurchasesByItemsHeader from './PurchasesByItemsHeader';
-import PurchasesByItemsTable from './PurchasesByItemsTable';
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
import { PurchasesByItemsLoadingBar } from './components';
+import { PurchasesByItemsBody } from './PurchasesByItemsBody';
import withPurchasesByItemsActions from './withPurchasesByItemsActions';
-import withCurrentOrganization from '../../../containers/Organization/withCurrentOrganization';
+
+import { getDefaultPurchasesByItemsQuery } from './utils';
import { compose } from 'utils';
/**
* Purchases by items.
*/
function PurchasesByItems({
- // #withPreferences
- organizationName,
// #withPurchasesByItemsActions
togglePurchasesByItemsFilterDrawer,
}) {
const [filter, setFilter] = useState({
- fromDate: moment().startOf('year').format('YYYY-MM-DD'),
- toDate: moment().endOf('year').format('YYYY-MM-DD'),
- filterByOption: 'with-transactions',
+ ...getDefaultPurchasesByItemsQuery(),
});
// Handle filter form submit.
@@ -68,23 +67,16 @@ function PurchasesByItems({
-
-
+
+
);
}
-export default compose(
- withPurchasesByItemsActions,
- withCurrentOrganization(({ organization }) => ({
- organizationName: organization.name,
- })),
-)(PurchasesByItems);
+export default compose(withPurchasesByItemsActions)(PurchasesByItems);
diff --git a/src/containers/FinancialStatements/PurchasesByItems/PurchasesByItemsBody.js b/src/containers/FinancialStatements/PurchasesByItems/PurchasesByItemsBody.js
new file mode 100644
index 000000000..f46b95096
--- /dev/null
+++ b/src/containers/FinancialStatements/PurchasesByItems/PurchasesByItemsBody.js
@@ -0,0 +1,37 @@
+import React from 'react';
+import * as R from 'ramda';
+
+import { FinancialReportBody } from '../FinancialReportPage';
+import { FinancialSheetSkeleton } from '../../../components/FinancialSheet';
+import PurchasesByItemsTable from './PurchasesByItemsTable';
+
+import { usePurchaseByItemsContext } from './PurchasesByItemsProvider';
+
+import withCurrentOrganization from '../../../containers/Organization/withCurrentOrganization';
+
+/**
+ * Purchases by items.
+ * @returns {JSX.Element}
+ */
+function PurchasesByItemsBodyJSX({
+ // #withPreferences
+ organizationName,
+}) {
+ const { isLoading } = usePurchaseByItemsContext();
+
+ return (
+
+ {isLoading ? (
+
+ ) : (
+
+ )}
+
+ );
+}
+
+export const PurchasesByItemsBody = R.compose(
+ withCurrentOrganization(({ organization }) => ({
+ organizationName: organization.name,
+ })),
+)(PurchasesByItemsBodyJSX);
diff --git a/src/containers/FinancialStatements/PurchasesByItems/PurchasesByItemsTable.js b/src/containers/FinancialStatements/PurchasesByItems/PurchasesByItemsTable.js
index f251a9960..51a818201 100644
--- a/src/containers/FinancialStatements/PurchasesByItems/PurchasesByItemsTable.js
+++ b/src/containers/FinancialStatements/PurchasesByItems/PurchasesByItemsTable.js
@@ -1,13 +1,17 @@
import React from 'react';
import intl from 'react-intl-universal';
+import styled from 'styled-components';
import { DataTable, FinancialSheet } from 'components';
import { usePurchaseByItemsContext } from './PurchasesByItemsProvider';
import { usePurchasesByItemsTableColumns } from './components';
+import { tableRowTypesToClassnames } from 'utils';
+import { TableStyle } from 'common';
+
/**
- * purchases by items data table.
+ * Purchases by items data table.
*/
export default function PurchasesByItemsTable({ companyName }) {
// Purchases by items context.
@@ -19,20 +23,6 @@ export default function PurchasesByItemsTable({ companyName }) {
// Purchases by items table columns.
const columns = usePurchasesByItemsTableColumns();
- const rowClassNames = (row) => {
- const { original } = row;
- const rowTypes = Array.isArray(original.rowType)
- ? original.rowType
- : [original.rowType];
-
- return {
- ...rowTypes.reduce((acc, rowType) => {
- acc[`row_type--${rowType}`] = rowType;
- return acc;
- }, {}),
- };
- };
-
return (
-
);
}
+
+const PurchasesByItemsDataTable = styled(DataTable)`
+ .table {
+ .tbody {
+ .tr .td {
+ border-bottom: 0;
+ padding-top: 0.4rem;
+ padding-bottom: 0.4rem;
+ }
+ .tr.row_type--total .td {
+ border-top: 1px solid #bbb;
+ font-weight: 500;
+ border-bottom: 3px double #000;
+ }
+ }
+ }
+`;
diff --git a/src/containers/FinancialStatements/PurchasesByItems/components.js b/src/containers/FinancialStatements/PurchasesByItems/components.js
index 9f1bc3264..080ad6fcf 100644
--- a/src/containers/FinancialStatements/PurchasesByItems/components.js
+++ b/src/containers/FinancialStatements/PurchasesByItems/components.js
@@ -1,18 +1,17 @@
import React from 'react';
import intl from 'react-intl-universal';
-import { Button } from '@blueprintjs/core';
-import { getColumnWidth } from 'utils';
-import { If, Icon } from 'components';
+
+import { If } from 'components';
import { CellTextSpan } from 'components/Datatable/Cells';
import { usePurchaseByItemsContext } from './PurchasesByItemsProvider';
import FinancialLoadingBar from '../FinancialLoadingBar';
+import { getColumnWidth } from 'utils';
+
/**
* Retrieve purchases by items table columns.
*/
export const usePurchasesByItemsTableColumns = () => {
-
-
// purchases by items context.
const {
purchaseByItems: { tableRows },
diff --git a/src/containers/FinancialStatements/PurchasesByItems/utils.js b/src/containers/FinancialStatements/PurchasesByItems/utils.js
new file mode 100644
index 000000000..2bed8630f
--- /dev/null
+++ b/src/containers/FinancialStatements/PurchasesByItems/utils.js
@@ -0,0 +1,10 @@
+import moment from 'moment';
+
+
+export const getDefaultPurchasesByItemsQuery = () => {
+ return {
+ fromDate: moment().startOf('year').format('YYYY-MM-DD'),
+ toDate: moment().endOf('year').format('YYYY-MM-DD'),
+ filterByOption: 'with-transactions',
+ }
+}
\ No newline at end of file
diff --git a/src/containers/FinancialStatements/TrialBalanceSheet/TrialBalanceSheet.js b/src/containers/FinancialStatements/TrialBalanceSheet/TrialBalanceSheet.js
index 4a3b3346a..891b8e925 100644
--- a/src/containers/FinancialStatements/TrialBalanceSheet/TrialBalanceSheet.js
+++ b/src/containers/FinancialStatements/TrialBalanceSheet/TrialBalanceSheet.js
@@ -1,8 +1,6 @@
import React, { useCallback, useEffect, useState } from 'react';
import moment from 'moment';
-import 'style/pages/FinancialStatements/TrialBalanceSheet.scss';
-
import { FinancialStatement } from 'components';
import { TrialBalanceSheetProvider } from './TrialBalanceProvider';
import TrialBalanceActionsBar from './TrialBalanceActionsBar';