mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
refactor: re-structure financial reports components.
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
import React, { useState, useCallback, useEffect } from 'react';
|
import React, { useState, useCallback, useEffect } from 'react';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
import 'style/pages/FinancialStatements/APAgingSummary.scss';
|
import { getDefaultAPAgingSummaryQuery } from './common';
|
||||||
|
|
||||||
import { FinancialStatement } from 'components';
|
import { FinancialStatement } from 'components';
|
||||||
|
|
||||||
import APAgingSummaryHeader from './APAgingSummaryHeader';
|
import APAgingSummaryHeader from './APAgingSummaryHeader';
|
||||||
@@ -12,8 +11,8 @@ import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
|||||||
import { APAgingSummaryProvider } from './APAgingSummaryProvider';
|
import { APAgingSummaryProvider } from './APAgingSummaryProvider';
|
||||||
import { APAgingSummarySheetLoadingBar } from './components';
|
import { APAgingSummarySheetLoadingBar } from './components';
|
||||||
|
|
||||||
import withCurrentOrganization from '../../Organization/withCurrentOrganization';
|
|
||||||
import withAPAgingSummaryActions from './withAPAgingSummaryActions';
|
import withAPAgingSummaryActions from './withAPAgingSummaryActions';
|
||||||
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,11 +26,7 @@ function APAgingSummary({
|
|||||||
toggleAPAgingSummaryFilterDrawer: toggleDisplayFilterDrawer,
|
toggleAPAgingSummaryFilterDrawer: toggleDisplayFilterDrawer,
|
||||||
}) {
|
}) {
|
||||||
const [filter, setFilter] = useState({
|
const [filter, setFilter] = useState({
|
||||||
asDate: moment().endOf('day').format('YYYY-MM-DD'),
|
...getDefaultAPAgingSummaryQuery(),
|
||||||
agingDaysBefore: 30,
|
|
||||||
agingPeriods: 3,
|
|
||||||
vendorsIds: [],
|
|
||||||
filterByOption: 'without-zero-balance',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle filter submit.
|
// Handle filter submit.
|
||||||
@@ -50,7 +45,6 @@ function APAgingSummary({
|
|||||||
numberFormat,
|
numberFormat,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Hide the report filter drawer once the page unmount.
|
// Hide the report filter drawer once the page unmount.
|
||||||
useEffect(
|
useEffect(
|
||||||
() => () => {
|
() => () => {
|
||||||
@@ -73,18 +67,11 @@ function APAgingSummary({
|
|||||||
pageFilter={filter}
|
pageFilter={filter}
|
||||||
onSubmitFilter={handleFilterSubmit}
|
onSubmitFilter={handleFilterSubmit}
|
||||||
/>
|
/>
|
||||||
<div className={'financial-statement__body'}>
|
<APAgingSummaryTable organizationName={organizationName} />
|
||||||
<APAgingSummaryTable organizationName={organizationName} />
|
|
||||||
</div>
|
|
||||||
</FinancialStatement>
|
</FinancialStatement>
|
||||||
</DashboardPageContent>
|
</DashboardPageContent>
|
||||||
</APAgingSummaryProvider>
|
</APAgingSummaryProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(withAPAgingSummaryActions)(APAgingSummary);
|
||||||
withCurrentOrganization(({ organization }) => ({
|
|
||||||
organizationName: organization?.name,
|
|
||||||
})),
|
|
||||||
withAPAgingSummaryActions,
|
|
||||||
)(APAgingSummary);
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import * as R from 'ramda';
|
||||||
|
|
||||||
|
import { FinancialReportBody } from '../FinancialReportPage';
|
||||||
|
import APAgingSummaryTable from './APAgingSummaryTable';
|
||||||
|
import { FinancialSheetSkeleton } from '../../../components/FinancialSheet';
|
||||||
|
|
||||||
|
import withCurrentOrganization from '../../Organization/withCurrentOrganization';
|
||||||
|
|
||||||
|
import { useAPAgingSummaryContext } from './APAgingSummaryProvider';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AP aging summary body.
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
|
function APAgingSummaryBodyJSX({
|
||||||
|
// #withCurrentOrganization
|
||||||
|
organizationName,
|
||||||
|
}) {
|
||||||
|
const { isLoading } = useAPAgingSummaryContext();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FinancialReportBody>
|
||||||
|
{isLoading ? (
|
||||||
|
<FinancialSheetSkeleton />
|
||||||
|
) : (
|
||||||
|
<APAgingSummaryTable organizationName={organizationName} />
|
||||||
|
)}
|
||||||
|
</FinancialReportBody>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const APAgingSummaryBody = R.compose(
|
||||||
|
withCurrentOrganization(({ organization }) => ({
|
||||||
|
organizationName: organization?.name,
|
||||||
|
})),
|
||||||
|
)(APAgingSummaryBodyJSX);
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import { DataTable, FinancialSheet } from 'components';
|
import { DataTable, FinancialSheet } from 'components';
|
||||||
|
import { TableStyle } from 'common';
|
||||||
|
|
||||||
import { useAPAgingSummaryContext } from './APAgingSummaryProvider';
|
import { useAPAgingSummaryContext } from './APAgingSummaryProvider';
|
||||||
import { useAPAgingSummaryColumns } from './components';
|
import { useAPAgingSummaryColumns } from './components';
|
||||||
@@ -32,14 +34,26 @@ export default function APAgingSummaryTable({
|
|||||||
asDate={new Date()}
|
asDate={new Date()}
|
||||||
loading={isAPAgingLoading}
|
loading={isAPAgingLoading}
|
||||||
>
|
>
|
||||||
<DataTable
|
<APAgingSummaryDataTable
|
||||||
className={'bigcapital-datatable--financial-report'}
|
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={tableRows}
|
data={tableRows}
|
||||||
rowClassNames={rowClassNames}
|
rowClassNames={rowClassNames}
|
||||||
noInitialFetch={true}
|
noInitialFetch={true}
|
||||||
sticky={true}
|
sticky={true}
|
||||||
|
styleName={TableStyle.Constrant}
|
||||||
/>
|
/>
|
||||||
</FinancialSheet>
|
</FinancialSheet>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const APAgingSummaryDataTable = styled(DataTable)`
|
||||||
|
.table {
|
||||||
|
.tbody .tr {
|
||||||
|
.td {
|
||||||
|
border-bottom: 0;
|
||||||
|
padding-top: 0.32rem;
|
||||||
|
padding-bottom: 0.32rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
|
import moment from 'moment';
|
||||||
import { transformToCamelCase, flatObject } from 'utils';
|
import { transformToCamelCase, flatObject } from 'utils';
|
||||||
|
|
||||||
export const transformFilterFormToQuery = (form) => {
|
export const transformFilterFormToQuery = (form) => {
|
||||||
return flatObject(transformToCamelCase(form));
|
return flatObject(transformToCamelCase(form));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getDefaultAPAgingSummaryQuery = () => {
|
||||||
|
return {
|
||||||
|
asDate: moment().endOf('day').format('YYYY-MM-DD'),
|
||||||
|
agingDaysBefore: 30,
|
||||||
|
agingPeriods: 3,
|
||||||
|
vendorsIds: [],
|
||||||
|
filterByOption: 'without-zero-balance',
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,38 +1,31 @@
|
|||||||
import React, { useState, useCallback, useEffect } from 'react';
|
import React, { useState, useCallback, useEffect } from 'react';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
import 'style/pages/FinancialStatements/ARAgingSummary.scss';
|
// import 'style/pages/FinancialStatements/ARAgingSummary.scss';
|
||||||
|
|
||||||
import { FinancialStatement } from 'components';
|
import { FinancialStatement } from 'components';
|
||||||
|
|
||||||
import ARAgingSummaryHeader from './ARAgingSummaryHeader';
|
import ARAgingSummaryHeader from './ARAgingSummaryHeader';
|
||||||
import ARAgingSummaryActionsBar from './ARAgingSummaryActionsBar';
|
import ARAgingSummaryActionsBar from './ARAgingSummaryActionsBar';
|
||||||
import ARAgingSummaryTable from './ARAgingSummaryTable';
|
|
||||||
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
||||||
import { ARAgingSummaryProvider } from './ARAgingSummaryProvider';
|
import { ARAgingSummaryProvider } from './ARAgingSummaryProvider';
|
||||||
import { ARAgingSummarySheetLoadingBar } from './components';
|
import { ARAgingSummarySheetLoadingBar } from './components';
|
||||||
|
import { ARAgingSummaryBody } from './ARAgingSummaryBody';
|
||||||
|
|
||||||
import withARAgingSummaryActions from './withARAgingSummaryActions'
|
import withARAgingSummaryActions from './withARAgingSummaryActions';
|
||||||
import withCurrentOrganization from '../../../containers/Organization/withCurrentOrganization';
|
|
||||||
|
|
||||||
|
import { getDefaultARAgingSummaryQuery } from './common';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A/R aging summary report.
|
* A/R aging summary report.
|
||||||
*/
|
*/
|
||||||
function ReceivableAgingSummarySheet({
|
function ReceivableAgingSummarySheet({
|
||||||
// #withSettings
|
|
||||||
organizationName,
|
|
||||||
|
|
||||||
// #withARAgingSummaryActions
|
// #withARAgingSummaryActions
|
||||||
toggleARAgingSummaryFilterDrawer: toggleDisplayFilterDrawer
|
toggleARAgingSummaryFilterDrawer: toggleDisplayFilterDrawer,
|
||||||
}) {
|
}) {
|
||||||
const [filter, setFilter] = useState({
|
const [filter, setFilter] = useState({
|
||||||
asDate: moment().endOf('day').format('YYYY-MM-DD'),
|
...getDefaultARAgingSummaryQuery(),
|
||||||
agingDaysBefore: 30,
|
|
||||||
agingPeriods: 3,
|
|
||||||
customersIds: [],
|
|
||||||
filterByOption: 'without-zero-balance',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle filter submit.
|
// Handle filter submit.
|
||||||
@@ -48,11 +41,13 @@ function ReceivableAgingSummarySheet({
|
|||||||
const handleNumberFormatSubmit = (numberFormat) => {
|
const handleNumberFormatSubmit = (numberFormat) => {
|
||||||
setFilter({ ...filter, numberFormat });
|
setFilter({ ...filter, numberFormat });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Hide the filter drawer once the page unmount.
|
// Hide the filter drawer once the page unmount.
|
||||||
useEffect(() => () => {
|
useEffect(
|
||||||
toggleDisplayFilterDrawer(false);
|
() => () => {
|
||||||
}, [toggleDisplayFilterDrawer]);
|
toggleDisplayFilterDrawer(false);
|
||||||
|
},
|
||||||
|
[toggleDisplayFilterDrawer],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ARAgingSummaryProvider filter={filter}>
|
<ARAgingSummaryProvider filter={filter}>
|
||||||
@@ -68,18 +63,11 @@ function ReceivableAgingSummarySheet({
|
|||||||
pageFilter={filter}
|
pageFilter={filter}
|
||||||
onSubmitFilter={handleFilterSubmit}
|
onSubmitFilter={handleFilterSubmit}
|
||||||
/>
|
/>
|
||||||
<div class="financial-statement__body">
|
<ARAgingSummaryBody />
|
||||||
<ARAgingSummaryTable organizationName={organizationName} />
|
|
||||||
</div>
|
|
||||||
</FinancialStatement>
|
</FinancialStatement>
|
||||||
</DashboardPageContent>
|
</DashboardPageContent>
|
||||||
</ARAgingSummaryProvider>
|
</ARAgingSummaryProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(withARAgingSummaryActions)(ReceivableAgingSummarySheet);
|
||||||
withCurrentOrganization(({ organization }) => ({
|
|
||||||
organizationName: organization.name,
|
|
||||||
})),
|
|
||||||
withARAgingSummaryActions
|
|
||||||
)(ReceivableAgingSummarySheet);
|
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import * as R from 'ramda';
|
||||||
|
|
||||||
|
import ARAgingSummaryTable from './ARAgingSummaryTable';
|
||||||
|
import {
|
||||||
|
FinancialReportBody,
|
||||||
|
FinancialSheetSkeleton,
|
||||||
|
} from '../../../components';
|
||||||
|
|
||||||
|
import withCurrentOrganization from '../../../containers/Organization/withCurrentOrganization';
|
||||||
|
import { useARAgingSummaryContext } from './ARAgingSummaryProvider';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A/R Aging summary body.
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
|
function ARAgingSummaryBodyJSX({
|
||||||
|
// #withCurrentOrganization
|
||||||
|
organizationName,
|
||||||
|
}) {
|
||||||
|
const { isARAgingLoading } = useARAgingSummaryContext();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FinancialReportBody>
|
||||||
|
{isARAgingLoading ? (
|
||||||
|
<FinancialSheetSkeleton />
|
||||||
|
) : (
|
||||||
|
<ARAgingSummaryTable organizationName={organizationName} />
|
||||||
|
)}
|
||||||
|
</FinancialReportBody>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ARAgingSummaryBody = R.compose(
|
||||||
|
withCurrentOrganization(({ organization }) => ({
|
||||||
|
organizationName: organization.name,
|
||||||
|
})),
|
||||||
|
)(ARAgingSummaryBodyJSX);
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import { DataTable, FinancialSheet } from 'components';
|
import { DataTable, FinancialSheet } from 'components';
|
||||||
|
import { TableStyle } from 'common';
|
||||||
|
|
||||||
import { useARAgingSummaryContext } from './ARAgingSummaryProvider';
|
import { useARAgingSummaryContext } from './ARAgingSummaryProvider';
|
||||||
import { useARAgingSummaryColumns } from './components';
|
import { useARAgingSummaryColumns } from './components';
|
||||||
@@ -29,14 +31,26 @@ export default function ReceivableAgingSummaryTable({
|
|||||||
asDate={new Date()}
|
asDate={new Date()}
|
||||||
loading={isARAgingLoading}
|
loading={isARAgingLoading}
|
||||||
>
|
>
|
||||||
<DataTable
|
<ARAgingSummaryDataTable
|
||||||
className="bigcapital-datatable--financial-report"
|
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={ARAgingSummary.tableRows}
|
data={ARAgingSummary.tableRows}
|
||||||
rowClassNames={rowClassNames}
|
rowClassNames={rowClassNames}
|
||||||
noInitialFetch={true}
|
noInitialFetch={true}
|
||||||
sticky={true}
|
sticky={true}
|
||||||
|
styleName={TableStyle.Constrant}
|
||||||
/>
|
/>
|
||||||
</FinancialSheet>
|
</FinancialSheet>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ARAgingSummaryDataTable = styled(DataTable)`
|
||||||
|
.table {
|
||||||
|
.tbody .tr {
|
||||||
|
.td {
|
||||||
|
border-bottom: 0;
|
||||||
|
padding-top: 0.32rem;
|
||||||
|
padding-bottom: 0.32rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
|
import moment from 'moment';
|
||||||
import { transformToCamelCase, flatObject } from 'utils';
|
import { transformToCamelCase, flatObject } from 'utils';
|
||||||
|
|
||||||
export const transfromFilterFormToQuery = (form) => {
|
export const transfromFilterFormToQuery = (form) => {
|
||||||
return flatObject(transformToCamelCase(form));
|
return flatObject(transformToCamelCase(form));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the default A/R aging summary query.
|
||||||
|
*/
|
||||||
|
export const getDefaultARAgingSummaryQuery = () => {
|
||||||
|
return {
|
||||||
|
asDate: moment().endOf('day').format('YYYY-MM-DD'),
|
||||||
|
agingDaysBefore: 30,
|
||||||
|
agingPeriods: 3,
|
||||||
|
customersIds: [],
|
||||||
|
filterByOption: 'without-zero-balance',
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
|
||||||
import { useARAgingSummaryContext } from './ARAgingSummaryProvider';
|
import { useARAgingSummaryContext } from './ARAgingSummaryProvider';
|
||||||
|
import { If, FormattedMessage as T } from 'components';
|
||||||
|
|
||||||
import { getColumnWidth } from 'utils';
|
import { getColumnWidth } from 'utils';
|
||||||
import { FormattedMessage as T } from 'components';
|
import { Align } from 'common';
|
||||||
import { If } from 'components';
|
|
||||||
import FinancialLoadingBar from '../FinancialLoadingBar';
|
import FinancialLoadingBar from '../FinancialLoadingBar';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,6 +42,7 @@ export const useARAgingSummaryColumns = () => {
|
|||||||
width: getColumnWidth(tableRows, `current`, {
|
width: getColumnWidth(tableRows, `current`, {
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
}),
|
}),
|
||||||
|
align: Align.Right
|
||||||
},
|
},
|
||||||
...agingColumns.map((agingColumn, index) => ({
|
...agingColumns.map((agingColumn, index) => ({
|
||||||
Header: agingColumn,
|
Header: agingColumn,
|
||||||
@@ -47,6 +50,7 @@ export const useARAgingSummaryColumns = () => {
|
|||||||
width: getColumnWidth(tableRows, `aging-${index}`, {
|
width: getColumnWidth(tableRows, `aging-${index}`, {
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
}),
|
}),
|
||||||
|
align: Align.Right
|
||||||
})),
|
})),
|
||||||
{
|
{
|
||||||
Header: <T id={'total'} />,
|
Header: <T id={'total'} />,
|
||||||
@@ -56,6 +60,7 @@ export const useARAgingSummaryColumns = () => {
|
|||||||
width: getColumnWidth(tableRows, 'total', {
|
width: getColumnWidth(tableRows, 'total', {
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
}),
|
}),
|
||||||
|
align: Align.Right
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[tableRows, agingColumns],
|
[tableRows, agingColumns],
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
import 'style/pages/FinancialStatements/GeneralLedger.scss';
|
import { FinancialStatement } from 'components';
|
||||||
|
|
||||||
import GeneralLedgerTable from './GeneralLedgerTable';
|
|
||||||
import GeneralLedgerHeader from './GeneralLedgerHeader';
|
import GeneralLedgerHeader from './GeneralLedgerHeader';
|
||||||
|
|
||||||
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
||||||
@@ -13,12 +11,13 @@ import {
|
|||||||
GeneralLedgerSheetAlerts,
|
GeneralLedgerSheetAlerts,
|
||||||
GeneralLedgerSheetLoadingBar,
|
GeneralLedgerSheetLoadingBar,
|
||||||
} from './components';
|
} from './components';
|
||||||
|
import { GeneralLedgerBody } from './GeneralLedgerBody';
|
||||||
|
|
||||||
import withGeneralLedgerActions from './withGeneralLedgerActions';
|
import withGeneralLedgerActions from './withGeneralLedgerActions';
|
||||||
import withCurrentOrganization from '../../Organization/withCurrentOrganization';
|
|
||||||
|
|
||||||
import { transformFilterFormToQuery } from 'containers/FinancialStatements/common';
|
import { transformFilterFormToQuery } from 'containers/FinancialStatements/common';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
import { getDefaultGeneralLedgerQuery } from './common';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General Ledger (GL) sheet.
|
* General Ledger (GL) sheet.
|
||||||
@@ -31,10 +30,7 @@ function GeneralLedger({
|
|||||||
organizationName,
|
organizationName,
|
||||||
}) {
|
}) {
|
||||||
const [filter, setFilter] = useState({
|
const [filter, setFilter] = useState({
|
||||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
...getDefaultGeneralLedgerQuery(),
|
||||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
|
||||||
basis: 'accural',
|
|
||||||
filterByOption: 'with-transactions',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle financial statement filter change.
|
// Handle financial statement filter change.
|
||||||
@@ -63,29 +59,18 @@ function GeneralLedger({
|
|||||||
<GeneralLedgerActionsBar />
|
<GeneralLedgerActionsBar />
|
||||||
|
|
||||||
<DashboardPageContent>
|
<DashboardPageContent>
|
||||||
<div class="financial-statement financial-statement--general-ledger">
|
<FinancialStatement>
|
||||||
<GeneralLedgerHeader
|
<GeneralLedgerHeader
|
||||||
pageFilter={filter}
|
pageFilter={filter}
|
||||||
onSubmitFilter={handleFilterSubmit}
|
onSubmitFilter={handleFilterSubmit}
|
||||||
/>
|
/>
|
||||||
<GeneralLedgerSheetLoadingBar />
|
<GeneralLedgerSheetLoadingBar />
|
||||||
<GeneralLedgerSheetAlerts />
|
<GeneralLedgerSheetAlerts />
|
||||||
|
<GeneralLedgerBody />
|
||||||
<div class="financial-statement__body">
|
</FinancialStatement>
|
||||||
<GeneralLedgerTable
|
|
||||||
companyName={organizationName}
|
|
||||||
generalLedgerQuery={filter}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</DashboardPageContent>
|
</DashboardPageContent>
|
||||||
</GeneralLedgerProvider>
|
</GeneralLedgerProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(withGeneralLedgerActions)(GeneralLedger);
|
||||||
withGeneralLedgerActions,
|
|
||||||
withCurrentOrganization(({ organization }) => ({
|
|
||||||
organizationName: organization.name,
|
|
||||||
})),
|
|
||||||
)(GeneralLedger);
|
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import * as R from 'ramda';
|
||||||
|
|
||||||
|
import GeneralLedgerTable from './GeneralLedgerTable';
|
||||||
|
import { FinancialSheetSkeleton } from '../../../components/FinancialSheet';
|
||||||
|
|
||||||
|
import withCurrentOrganization from '../../Organization/withCurrentOrganization';
|
||||||
|
|
||||||
|
import { FinancialReportBody } from '../FinancialReportPage';
|
||||||
|
import { useGeneralLedgerContext } from './GeneralLedgerProvider';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* General ledger body JSX.
|
||||||
|
*/
|
||||||
|
function GeneralLedgerBodyJSX({
|
||||||
|
// #withCurrentOrganization
|
||||||
|
organizationName,
|
||||||
|
}) {
|
||||||
|
const { isLoading } = useGeneralLedgerContext();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FinancialReportBody>
|
||||||
|
{isLoading ? (
|
||||||
|
<FinancialSheetSkeleton />
|
||||||
|
) : (
|
||||||
|
<GeneralLedgerTable companyName={organizationName} />
|
||||||
|
)}
|
||||||
|
</FinancialReportBody>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const GeneralLedgerBody = R.compose(
|
||||||
|
withCurrentOrganization(({ organization }) => ({
|
||||||
|
organizationName: organization.name,
|
||||||
|
})),
|
||||||
|
)(GeneralLedgerBodyJSX);
|
||||||
@@ -11,6 +11,8 @@ import TableFastCell from 'components/Datatable/TableFastCell';
|
|||||||
import { useGeneralLedgerContext } from './GeneralLedgerProvider';
|
import { useGeneralLedgerContext } from './GeneralLedgerProvider';
|
||||||
import { useGeneralLedgerTableColumns } from './components';
|
import { useGeneralLedgerTableColumns } from './components';
|
||||||
|
|
||||||
|
import { TableStyle } from 'common';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General ledger table.
|
* General ledger table.
|
||||||
*/
|
*/
|
||||||
@@ -41,7 +43,6 @@ export default function GeneralLedgerTable({ companyName }) {
|
|||||||
fullWidth={true}
|
fullWidth={true}
|
||||||
>
|
>
|
||||||
<DataTable
|
<DataTable
|
||||||
className="bigcapital-datatable--financial-report"
|
|
||||||
noResults={intl.get('this_report_does_not_contain_any_data_between_date_period')}
|
noResults={intl.get('this_report_does_not_contain_any_data_between_date_period')}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={tableRows}
|
data={tableRows}
|
||||||
@@ -54,10 +55,13 @@ export default function GeneralLedgerTable({ companyName }) {
|
|||||||
expandToggleColumn={1}
|
expandToggleColumn={1}
|
||||||
sticky={true}
|
sticky={true}
|
||||||
TableRowsRenderer={TableVirtualizedListRows}
|
TableRowsRenderer={TableVirtualizedListRows}
|
||||||
|
|
||||||
// #TableVirtualizedListRows props.
|
// #TableVirtualizedListRows props.
|
||||||
vListrowHeight={28}
|
vListrowHeight={28}
|
||||||
vListOverscanRowCount={0}
|
vListOverscanRowCount={0}
|
||||||
TableCellRenderer={TableFastCell}
|
TableCellRenderer={TableFastCell}
|
||||||
|
|
||||||
|
styleName={TableStyle.Constrant}
|
||||||
/>
|
/>
|
||||||
</FinancialSheet>
|
</FinancialSheet>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
export const filterAccountsOptions = [
|
export const filterAccountsOptions = [
|
||||||
{
|
{
|
||||||
@@ -9,6 +10,20 @@ export const filterAccountsOptions = [
|
|||||||
{
|
{
|
||||||
key: 'with-transactions',
|
key: 'with-transactions',
|
||||||
name: intl.get('accounts_with_transactions'),
|
name: intl.get('accounts_with_transactions'),
|
||||||
hint: intl.get('include_accounts_once_has_transactions_on_given_date_period'),
|
hint: intl.get(
|
||||||
|
'include_accounts_once_has_transactions_on_given_date_period',
|
||||||
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the default general ledger query.
|
||||||
|
*/
|
||||||
|
export const getDefaultGeneralLedgerQuery = () => {
|
||||||
|
return {
|
||||||
|
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||||
|
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||||
|
basis: 'accural',
|
||||||
|
filterByOption: 'with-transactions',
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,36 +1,29 @@
|
|||||||
import React, { useState, useCallback, useEffect } from 'react';
|
import React, { useState, useCallback, useEffect } from 'react';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
import 'style/pages/FinancialStatements/Journal.scss';
|
import { FinancialStatement, DashboardPageContent } from 'components';
|
||||||
|
|
||||||
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
|
||||||
|
|
||||||
import JournalTable from './JournalTable';
|
|
||||||
import JournalHeader from './JournalHeader';
|
import JournalHeader from './JournalHeader';
|
||||||
import JournalActionsBar from './JournalActionsBar';
|
import JournalActionsBar from './JournalActionsBar';
|
||||||
import { JournalSheetProvider } from './JournalProvider';
|
import { JournalSheetProvider } from './JournalProvider';
|
||||||
import { JournalSheetLoadingBar, JournalSheetAlerts } from './components';
|
import { JournalSheetLoadingBar, JournalSheetAlerts } from './components';
|
||||||
|
import { JournalBody } from './JournalBody';
|
||||||
|
|
||||||
import withCurrentOrganization from '../../Organization/withCurrentOrganization';
|
|
||||||
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
||||||
import withJournalActions from './withJournalActions';
|
import withJournalActions from './withJournalActions';
|
||||||
|
|
||||||
|
import { getDefaultJournalQuery } from './utils';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Journal sheet.
|
* Journal sheet.
|
||||||
*/
|
*/
|
||||||
function Journal({
|
function Journal({
|
||||||
// #withPreferences
|
|
||||||
organizationName,
|
|
||||||
|
|
||||||
// #withJournalActions
|
// #withJournalActions
|
||||||
toggleJournalSheetFilter
|
toggleJournalSheetFilter,
|
||||||
}) {
|
}) {
|
||||||
const [filter, setFilter] = useState({
|
const [filter, setFilter] = useState({
|
||||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
...getDefaultJournalQuery(),
|
||||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
|
||||||
basis: 'accural',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle financial statement filter change.
|
// Handle financial statement filter change.
|
||||||
@@ -47,39 +40,30 @@ function Journal({
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Hide the journal sheet filter drawer once the page unmount.
|
// Hide the journal sheet filter drawer once the page unmount.
|
||||||
useEffect(() => () => {
|
useEffect(
|
||||||
toggleJournalSheetFilter(false);
|
() => () => {
|
||||||
}, [toggleJournalSheetFilter]);
|
toggleJournalSheetFilter(false);
|
||||||
|
},
|
||||||
|
[toggleJournalSheetFilter],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<JournalSheetProvider query={filter}>
|
<JournalSheetProvider query={filter}>
|
||||||
<JournalActionsBar />
|
<JournalActionsBar />
|
||||||
|
|
||||||
<DashboardPageContent>
|
<DashboardPageContent>
|
||||||
<div class="financial-statement financial-statement--journal">
|
<FinancialStatement>
|
||||||
<JournalHeader
|
<JournalHeader
|
||||||
onSubmitFilter={handleFilterSubmit}
|
onSubmitFilter={handleFilterSubmit}
|
||||||
pageFilter={filter}
|
pageFilter={filter}
|
||||||
/>
|
/>
|
||||||
<JournalSheetLoadingBar />
|
<JournalSheetLoadingBar />
|
||||||
<JournalSheetAlerts />
|
<JournalSheetAlerts />
|
||||||
|
<JournalBody />
|
||||||
<div class="financial-statement__body">
|
</FinancialStatement>
|
||||||
<JournalTable
|
|
||||||
companyName={organizationName}
|
|
||||||
journalQuery={filter}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</DashboardPageContent>
|
</DashboardPageContent>
|
||||||
</JournalSheetProvider>
|
</JournalSheetProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(withDashboardActions, withJournalActions)(Journal);
|
||||||
withDashboardActions,
|
|
||||||
withJournalActions,
|
|
||||||
withCurrentOrganization(({ organization }) => ({
|
|
||||||
organizationName: organization.name,
|
|
||||||
})),
|
|
||||||
)(Journal);
|
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ import {
|
|||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
Position,
|
Position,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import { FormattedMessage as T } from 'components';
|
import { FormattedMessage as T } from 'components';
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
||||||
import classNames from 'classnames';
|
|
||||||
|
|
||||||
import withJournalActions from './withJournalActions';
|
import withJournalActions from './withJournalActions';
|
||||||
import withJournal from './withJournal';
|
import withJournal from './withJournal';
|
||||||
@@ -56,7 +57,7 @@ function JournalActionsBar({
|
|||||||
className={classNames(Classes.MINIMAL, 'button--table-views')}
|
className={classNames(Classes.MINIMAL, 'button--table-views')}
|
||||||
icon={<Icon icon="cog-16" iconSize={16} />}
|
icon={<Icon icon="cog-16" iconSize={16} />}
|
||||||
text={
|
text={
|
||||||
(isFilterDrawerOpen) ? (
|
isFilterDrawerOpen ? (
|
||||||
<T id={'hide_customizer'} />
|
<T id={'hide_customizer'} />
|
||||||
) : (
|
) : (
|
||||||
<T id={'customize_report'} />
|
<T id={'customize_report'} />
|
||||||
@@ -97,7 +98,7 @@ function JournalActionsBar({
|
|||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
withJournal(({ journalSheetDrawerFilter }) => ({
|
withJournal(({ journalSheetDrawerFilter }) => ({
|
||||||
isFilterDrawerOpen: journalSheetDrawerFilter
|
isFilterDrawerOpen: journalSheetDrawerFilter,
|
||||||
})),
|
})),
|
||||||
withJournalActions,
|
withJournalActions,
|
||||||
)(JournalActionsBar);
|
)(JournalActionsBar);
|
||||||
|
|||||||
37
src/containers/FinancialStatements/Journal/JournalBody.js
Normal file
37
src/containers/FinancialStatements/Journal/JournalBody.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import * as R from 'ramda';
|
||||||
|
|
||||||
|
import { FinancialReportBody } from '../FinancialReportPage';
|
||||||
|
import { FinancialSheetSkeleton } from '../../../components/FinancialSheet';
|
||||||
|
import { JournalTable } from './JournalTable';
|
||||||
|
|
||||||
|
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
|
||||||
|
|
||||||
|
import { useJournalSheetContext } from './JournalProvider';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Journal report body.
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
|
function JournalBodyJSX({
|
||||||
|
// #withCurrentOrganization
|
||||||
|
organizationName,
|
||||||
|
}) {
|
||||||
|
const { isLoading } = useJournalSheetContext();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FinancialReportBody>
|
||||||
|
{isLoading ? (
|
||||||
|
<FinancialSheetSkeleton />
|
||||||
|
) : (
|
||||||
|
<JournalTable companyName={organizationName} />
|
||||||
|
)}
|
||||||
|
</FinancialReportBody>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const JournalBody = R.compose(
|
||||||
|
withCurrentOrganization(({ organization }) => ({
|
||||||
|
organizationName: organization.name,
|
||||||
|
})),
|
||||||
|
)(JournalBodyJSX);
|
||||||
@@ -10,11 +10,13 @@ import { useJournalSheetContext } from './JournalProvider';
|
|||||||
|
|
||||||
import { defaultExpanderReducer } from 'utils';
|
import { defaultExpanderReducer } from 'utils';
|
||||||
|
|
||||||
export default function JournalSheetTable({
|
import { TableStyle } from 'common';
|
||||||
// #ownProps
|
|
||||||
onFetchData,
|
/**
|
||||||
companyName,
|
* Journal sheet table.
|
||||||
}) {
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
|
export function JournalTable({ companyName }) {
|
||||||
// Journal sheet context.
|
// Journal sheet context.
|
||||||
const {
|
const {
|
||||||
journalSheet: { tableRows, query },
|
journalSheet: { tableRows, query },
|
||||||
@@ -49,11 +51,9 @@ export default function JournalSheetTable({
|
|||||||
toDate={query.to_date}
|
toDate={query.to_date}
|
||||||
name="journal"
|
name="journal"
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
// minimal={true}
|
|
||||||
fullWidth={true}
|
fullWidth={true}
|
||||||
>
|
>
|
||||||
<DataTable
|
<DataTable
|
||||||
className="bigcapital-datatable--financial-report"
|
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={tableRows}
|
data={tableRows}
|
||||||
rowClassNames={rowClassNames}
|
rowClassNames={rowClassNames}
|
||||||
@@ -68,6 +68,7 @@ export default function JournalSheetTable({
|
|||||||
vListOverscanRowCount={2}
|
vListOverscanRowCount={2}
|
||||||
TableCellRenderer={TableFastCell}
|
TableCellRenderer={TableFastCell}
|
||||||
id={'journal'}
|
id={'journal'}
|
||||||
|
styleName={TableStyle.Constrant}
|
||||||
/>
|
/>
|
||||||
</FinancialSheet>
|
</FinancialSheet>
|
||||||
);
|
);
|
||||||
|
|||||||
12
src/containers/FinancialStatements/Journal/utils.js
Normal file
12
src/containers/FinancialStatements/Journal/utils.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the default journal report query.
|
||||||
|
*/
|
||||||
|
export const getDefaultJournalQuery = () => {
|
||||||
|
return {
|
||||||
|
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||||
|
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||||
|
basis: 'accural',
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user