This commit is contained in:
elforjani3
2021-01-21 15:19:46 +02:00
62 changed files with 1598 additions and 794 deletions

View File

@@ -38,6 +38,7 @@ function ReceivableAgingSummaryTable({
className: 'customer_name',
sticky: 'left',
width: 240,
textOverview: true,
},
{
Header: <T id={'current'} />,

View File

@@ -4,33 +4,12 @@ import classNames from 'classnames';
import FinancialSheet from 'components/FinancialSheet';
import DataTable from 'components/DataTable';
import { CellTextSpan } from 'components/Datatable/Cells';
import withBalanceSheetDetail from './withBalanceSheetDetail';
import { compose, defaultExpanderReducer, getColumnWidth } from 'utils';
// Total cell.
function TotalCell({ cell }) {
const row = cell.row.original;
if (row.total) {
return row.total.formatted_amount;
}
return '';
}
// Total period cell.
const TotalPeriodCell = (index) => ({ cell }) => {
const { original } = cell.row;
if (original.total_periods && original.total_periods[index]) {
const amount = original.total_periods[index].formatted_amount;
return amount;
}
return '';
};
/**
* Balance sheet table.
*/
@@ -52,14 +31,15 @@ function BalanceSheetTable({
Header: formatMessage({ id: 'account_name' }),
accessor: (row) => (row.code ? `${row.name} - ${row.code}` : row.name),
className: 'account_name',
textOverview: true,
width: 240,
},
...(balanceSheetQuery.display_columns_type === 'total'
? [
{
Header: formatMessage({ id: 'total' }),
accessor: 'balance.formatted_amount',
Cell: TotalCell,
accessor: 'total.formatted_amount',
Cell: CellTextSpan,
className: 'total',
width: 140,
},
@@ -69,8 +49,8 @@ function BalanceSheetTable({
? balanceSheetColumns.map((column, index) => ({
id: `date_period_${index}`,
Header: column,
accessor: `total_periods[${index}]`,
Cell: TotalPeriodCell(index),
Cell: CellTextSpan,
accessor: `total_periods[${index}].formatted_amount`,
className: classNames('total-period', `total-periods-${index}`),
width: getColumnWidth(
balanceSheetTableRows,
@@ -93,7 +73,7 @@ function BalanceSheetTable({
const { original } = row;
const rowTypes = Array.isArray(original.row_types)
? original.row_types
: [];
: [original.row_types];
return {
...rowTypes.reduce((acc, rowType) => {

View File

@@ -14,6 +14,8 @@ import { CLASSES } from 'common/classes';
import { Col, Row, ListSelect, MODIFIER } from 'components';
import { filterAccountsOptions } from './common';
export default function FinancialAccountsFilter({ ...restProps }) {
const SUBMENU_POPOVER_MODIFIERS = {
flip: { boundariesElement: 'viewport', padding: 20 },

View File

@@ -49,6 +49,7 @@ function GeneralLedger({
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
toDate: moment().endOf('year').format('YYYY-MM-DD'),
basis: 'accural',
accountsFilter: 'with-transactions',
});
// Change page title of the dashboard.

View File

@@ -1,16 +1,21 @@
import React from 'react';
import { FormGroup, Classes } from '@blueprintjs/core';
import {
FormGroup,
Classes,
} from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl';
import classNames from 'classnames';
import { compose } from 'redux';
import { AccountsMultiSelect, Row, Col } from 'components';
import FinancialStatementDateRange from 'containers/FinancialStatements/FinancialStatementDateRange';
import RadiosAccountingBasis from '../RadiosAccountingBasis';
import FinancialAccountsFilter from '../FinancialAccountsFilter';
import withAccounts from 'containers/Accounts/withAccounts';
import { compose } from 'redux';
import { filterAccountsOptions } from './common';
/**
* General ledger (GL) - Header - General panel.
@@ -22,7 +27,10 @@ function GeneralLedgerHeaderGeneralPane({
return (
<div>
<FinancialStatementDateRange />
<FinancialAccountsFilter
items={filterAccountsOptions}
initialSelectedItem={'all-accounts'}
/>
<Row>
<Col xs={4}>
<FormGroup

View File

@@ -8,6 +8,7 @@ import DataTable from 'components/DataTable';
import Money from 'components/Money';
import withGeneralLedger from './withGeneralLedger';
import { getForceWidth, getColumnWidth } from 'utils';
const ROW_TYPE = {
CLOSING_BALANCE: 'closing_balance',
@@ -25,91 +26,89 @@ function GeneralLedgerTable({
}) {
const { formatMessage } = useIntl();
// Account name column accessor.
const accountNameAccessor = (row) => {
switch (row.rowType) {
case ROW_TYPE.OPENING_BALANCE:
return 'Opening Balance';
case ROW_TYPE.CLOSING_BALANCE:
return 'Closing Balance';
default:
return row.name;
}
};
// Date accessor.
const dateAccessor = (row) => {
const TYPES = [
ROW_TYPE.OPENING_BALANCE,
ROW_TYPE.CLOSING_BALANCE,
ROW_TYPE.TRANSACTION,
];
return TYPES.indexOf(row.rowType) !== -1
? moment(row.date).format('DD MMM YYYY')
: '';
};
// Amount cell
const amountCell = useCallback(({ cell }) => {
const transaction = cell.row.original;
if (transaction.rowType === ROW_TYPE.ACCOUNT) {
return !cell.row.isExpanded ? (
<Money amount={transaction.closing.amount} currency={'USD'} />
) : (
''
);
}
return <Money amount={transaction.amount} currency={'USD'} />;
}, []);
const columns = useMemo(
() => [
{
Header: formatMessage({ id: 'account_name' }),
accessor: accountNameAccessor,
className: 'name',
width: 225,
Header: formatMessage({ id: 'date' }),
accessor: (row) => {
if (row.rowType === 'ACCOUNT_ROW') {
return (
<span
className={'force-width'}
style={{ minWidth: getForceWidth(row.date) }}
>
{row.date}
</span>
);
}
return row.date;
},
className: 'date',
width: 120,
},
{
Header: formatMessage({ id: 'date' }),
accessor: dateAccessor,
className: 'date',
width: 115,
Header: formatMessage({ id: 'account_name' }),
accessor: 'name',
className: 'name',
textOverview: true,
// width: 200,
},
{
Header: formatMessage({ id: 'transaction_type' }),
accessor: 'referenceType',
accessor: 'reference_type_formatted',
className: 'transaction_type',
width: 145,
width: 125 ,
},
{
Header: formatMessage({ id: 'trans_num' }),
Header: formatMessage({ id: 'transaction_number' }),
accessor: 'reference_id',
className: 'transaction_number',
width: 110,
width: 100,
},
{
Header: formatMessage({ id: 'description' }),
accessor: 'note',
className: 'description',
width: 145,
// width: 145,
},
{
Header: formatMessage({ id: 'credit' }),
accessor: 'formatted_credit',
className: 'credit',
width: getColumnWidth(generalLedgerTableRows, 'formatted_credit', {
minWidth: 100,
magicSpacing: 10,
}),
},
{
Header: formatMessage({ id: 'debit' }),
accessor: 'formatted_debit',
className: 'debit',
width: getColumnWidth(generalLedgerTableRows, 'formatted_debit', {
minWidth: 100,
magicSpacing: 10,
}),
},
{
Header: formatMessage({ id: 'amount' }),
Cell: amountCell,
accessor: 'formatted_amount',
className: 'amount',
width: 150,
width: getColumnWidth(generalLedgerTableRows, 'formatted_amount', {
minWidth: 100,
magicSpacing: 10,
}),
},
{
Header: formatMessage({ id: 'balance' }),
Cell: amountCell,
className: 'balance',
width: 150,
Header: formatMessage({ id: 'running_balance' }),
accessor: 'formatted_running_balance',
className: 'running_balance',
width: getColumnWidth(generalLedgerTableRows, 'formatted_running_balance', {
minWidth: 100,
magicSpacing: 10,
}),
},
],
[],
[formatMessage, generalLedgerTableRows],
);
// Default expanded rows of general ledger table.
@@ -140,7 +139,7 @@ function GeneralLedgerTable({
rowClassNames={rowClassNames}
expanded={expandedRows}
virtualizedRows={true}
fixedItemSize={37}
fixedItemSize={30}
fixedSizeHeight={1000}
expandable={true}
expandToggleColumn={1}

View File

@@ -0,0 +1,16 @@
import { formatMessage } from 'services/intl';
export const filterAccountsOptions = [
{
key: 'all-accounts',
name: formatMessage({ id: 'all_accounts' }),
hint: formatMessage({ id: 'all_accounts_including_with_zero_balance' }),
},
{
key: 'with-transactions',
name: formatMessage({ id: 'accounts_with_transactions' }),
hint: formatMessage({
id: 'include_accounts_once_has_transactions_on_given_date_period',
}),
},
];

View File

@@ -8,7 +8,7 @@ import Money from 'components/Money';
import withJournal from './withJournal';
import { compose, defaultExpanderReducer } from 'utils';
import { compose, defaultExpanderReducer, getForceWidth } from 'utils';
function JournalSheetTable({
// #withJournal
@@ -22,70 +22,52 @@ function JournalSheetTable({
}) {
const { formatMessage } = useIntl();
const rowTypeFilter = (rowType, value, types) => {
return types.indexOf(rowType) === -1 ? '' : value;
};
const exceptRowTypes = (rowType, value, types) => {
return types.indexOf(rowType) !== -1 ? '' : value;
};
const columns = useMemo(
() => [
{
Header: formatMessage({ id: 'date' }),
accessor: (r) =>
rowTypeFilter(r.rowType, moment(r.date).format('YYYY MMM DD'), [
'first_entry',
]),
accessor: row => row.date ? moment(row.date).format('YYYY MMM DD') : '',
className: 'date',
width: 85,
width: 100,
},
{
Header: formatMessage({ id: 'transaction_type' }),
accessor: (r) =>
rowTypeFilter(r.rowType, r.transaction_type, ['first_entry']),
accessor: 'reference_type_formatted',
className: 'reference_type_formatted',
width: 145,
width: 120,
},
{
Header: formatMessage({ id: 'num' }),
accessor: (r) =>
rowTypeFilter(r.rowType, r.reference_id, ['first_entry']),
accessor: 'reference_id',
className: 'reference_id',
width: 70,
},
{
Header: formatMessage({ id: 'description' }),
accessor: 'note',
className: 'note'
},
{
Header: formatMessage({ id: 'acc_code' }),
accessor: 'account.code',
accessor: 'account_code',
width: 95,
className: 'account_code',
},
{
Header: formatMessage({ id: 'account' }),
accessor: 'account.name',
accessor: 'account_name',
className: 'account_name',
textOverview: true,
},
{
Header: formatMessage({ id: 'credit' }),
accessor: (r) =>
exceptRowTypes(
r.rowType,
<Money amount={r.credit} currency={'USD'} />,
['space_entry'],
),
accessor: 'formatted_credit',
className: 'credit'
},
{
Header: formatMessage({ id: 'debit' }),
accessor: (r) =>
exceptRowTypes(
r.rowType,
<Money amount={r.debit} currency={'USD'} />,
['space_entry'],
),
accessor: 'formatted_debit',
className: 'debit'
},
],
[formatMessage],
@@ -101,6 +83,20 @@ function JournalSheetTable({
// Default expanded rows of general journal table.
const expandedRows = useMemo(() => defaultExpanderReducer([], 1), []);
const rowClassNames = useCallback((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 (
<FinancialSheet
companyName={companyName}
@@ -111,11 +107,12 @@ function JournalSheetTable({
loading={journalSheetLoading}
// minimal={true}
fullWidth={true}
>
>
<DataTable
className="bigcapital-datatable--financial-report"
columns={columns}
data={journalSheetTableRows}
rowClassNames={rowClassNames}
onFetchData={handleFetchData}
noResults={formatMessage({
id: 'this_report_does_not_contain_any_data_between_date_period',

View File

@@ -3,7 +3,7 @@ import { FormattedMessage as T, useIntl } from 'react-intl';
import FinancialSheet from 'components/FinancialSheet';
import DataTable from 'components/DataTable';
import Money from 'components/Money';
import { CellTextSpan } from 'components/Datatable/Cells';
import { compose, defaultExpanderReducer, getColumnWidth } from 'utils';
import withProfitLossDetail from './withProfitLoss';
@@ -26,12 +26,14 @@ function ProfitLossSheetTable({
Header: formatMessage({ id: 'account' }),
accessor: (row) => (row.code ? `${row.name} - ${row.code}` : row.name),
className: 'name',
textOverview: true,
width: 240,
},
...(profitLossQuery.display_columns_type === 'total'
? [
{
Header: formatMessage({ id: 'total' }),
Cell: CellTextSpan,
accessor: 'total.formatted_amount',
className: 'total',
width: 140,
@@ -42,6 +44,7 @@ function ProfitLossSheetTable({
? profitLossColumns.map((column, index) => ({
id: `date_period_${index}`,
Header: column,
Cell: CellTextSpan,
accessor: `total_periods[${index}].formatted_amount`,
width: getColumnWidth(
profitLossTableRows,

View File

@@ -3,7 +3,7 @@ import { useIntl } from 'react-intl';
import FinancialSheet from 'components/FinancialSheet';
import DataTable from 'components/DataTable';
import Money from 'components/Money';
import { CellTextSpan } from 'components/Datatable/Cells';
import withTrialBalance from './withTrialBalance';
@@ -28,9 +28,11 @@ function TrialBalanceSheetTable({
accessor: (row) => (row.code ? `${row.name} - ${row.code}` : row.name),
className: 'name',
width: 160,
textOverview: true,
},
{
Header: formatMessage({ id: 'credit' }),
Cell: CellTextSpan,
accessor: 'formatted_credit',
className: 'credit',
width: getColumnWidth(trialBalanceTableRows, `credit`, {
@@ -39,11 +41,13 @@ function TrialBalanceSheetTable({
},
{
Header: formatMessage({ id: 'debit' }),
Cell: CellTextSpan,
accessor: 'formatted_debit',
width: getColumnWidth(trialBalanceTableRows, `debit`, { minWidth: 95 }),
},
{
Header: formatMessage({ id: 'balance' }),
Cell: CellTextSpan,
accessor: 'formatted_balance',
className: 'balance',
width: getColumnWidth(trialBalanceTableRows, `balance`, {
@@ -56,7 +60,7 @@ function TrialBalanceSheetTable({
const rowClassNames = (row) => {
const { original } = row;
const rowTypes = Array.isArray(original.rowTypes) ? original.rowTypes : [];
const rowTypes = Array.isArray(original.rowType) ? original.rowType : [original.rowType];
return {
...rowTypes.reduce((acc, rowType) => {

View File

@@ -1,4 +1,4 @@
import { mapKeys, omit, snakeCase } from 'lodash';
import { omit } from 'lodash';
import { transformToCamelCase, flatObject } from 'utils';
import { formatMessage } from 'services/intl';