From 79f3f1b63d891c78e692897b1802274e1d461568 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Sat, 6 Jan 2024 20:16:22 +0200 Subject: [PATCH] feat: wip journal and general ledger dyanmic columns --- .../JournalSheet/JournalSheetTable.ts | 40 +++- .../FinancialStatements/JournalSheet/types.ts | 3 +- .../GeneralLedger/GeneralLedgerActionsBar.tsx | 18 +- ...ralLedgerHeaderDimensionsPanelProvider.tsx | 2 +- .../GeneralLedger/GeneralLedgerProvider.tsx | 1 + .../GeneralLedger/GeneralLedgerTable.tsx | 10 +- .../GeneralLedger/components.tsx | 210 ++++++++++-------- .../GeneralLedger/dynamicColumns.ts | 117 ++++++++++ .../Journal/JournalActionsBar.tsx | 18 +- .../Journal/JournalProvider.tsx | 1 + .../Journal/JournalTable.tsx | 12 +- .../Journal/components.tsx | 174 +++++++++------ .../Journal/dynamicColumns.ts | 134 +++++++++++ .../FinancialStatements/Journal/utils.tsx | 1 - .../src/hooks/query/financialReports.tsx | 88 ++++++-- 15 files changed, 615 insertions(+), 214 deletions(-) create mode 100644 packages/webapp/src/containers/FinancialStatements/GeneralLedger/dynamicColumns.ts create mode 100644 packages/webapp/src/containers/FinancialStatements/Journal/dynamicColumns.ts diff --git a/packages/server/src/services/FinancialStatements/JournalSheet/JournalSheetTable.ts b/packages/server/src/services/FinancialStatements/JournalSheet/JournalSheetTable.ts index 2854154e2..e1f4ec8fe 100644 --- a/packages/server/src/services/FinancialStatements/JournalSheet/JournalSheetTable.ts +++ b/packages/server/src/services/FinancialStatements/JournalSheet/JournalSheetTable.ts @@ -1,7 +1,8 @@ import * as R from 'ramda'; +import { first } from 'lodash'; import { + IColumnMapperMeta, IJournalEntry, - IJournalReport, IJournalReportEntriesGroup, IJournalReportQuery, IJournalTableData, @@ -13,7 +14,7 @@ import { tableRowMapper } from '@/utils'; import { FinancialTable } from '../FinancialTable'; import { FinancialSheetStructure } from '../FinancialSheetStructure'; import FinancialSheet from '../FinancialSheet'; -import { first } from 'lodash'; +import { ROW_TYPE } from './types'; export class JournalSheetTable extends R.compose( FinancialTable, @@ -70,6 +71,10 @@ export class JournalSheetTable extends R.compose( ]; }; + /** + * Retrieves the total entry column accessors. + * @returns {ITableColumnAccessor[]} + */ private totalEntryColumnAccessors = (): ITableColumnAccessor[] => { return [ { key: 'date', accessor: '_empty_' }, @@ -83,6 +88,23 @@ export class JournalSheetTable extends R.compose( ]; }; + /** + * Retrieves the total entry column accessors. + * @returns {IColumnMapperMeta[]} + */ + private blankEnrtyColumnAccessors = (): IColumnMapperMeta[] => { + return [ + { key: 'date', value: '' }, + { key: 'transaction_type', value: '' }, + { key: 'transaction_number', value: '' }, + { key: 'description', value: '' }, + { key: 'account_code', value: '' }, + { key: 'account_name', value: '' }, + { key: 'credit', value: '' }, + { key: 'debit', value: '' }, + ]; + }; + /** * Retrieves the common columns. * @returns {ITableColumn[]} @@ -113,6 +135,7 @@ export class JournalSheetTable extends R.compose( }; const computedGroup = { ...group, entry: first(group.entries) }; const columns = this.groupColumnsAccessors(); + return tableRowMapper(computedGroup, columns, meta); }; @@ -153,6 +176,16 @@ export class JournalSheetTable extends R.compose( return tableRowMapper(group, total, meta); }; + /** + * Retrieves the blank entry row. + * @returns {ITableRow} + */ + private blankEntryMapper = (): ITableRow => { + const columns = this.blankEnrtyColumnAccessors(); + const meta = {}; + return tableRowMapper({} as IJournalEntry, columns, meta); + }; + /** * Maps the entry group to table rows. * @param {IJournalReportEntriesGroup} group - @@ -162,8 +195,9 @@ export class JournalSheetTable extends R.compose( const firstRow = this.firstEntryGroupMapper(group); const lastRows = this.entriesMapper(group); const totalRow = this.totalEntryMapper(group); + const blankRow = this.blankEntryMapper(); - return [firstRow, ...lastRows, totalRow]; + return [firstRow, ...lastRows, totalRow, blankRow]; }; /** diff --git a/packages/server/src/services/FinancialStatements/JournalSheet/types.ts b/packages/server/src/services/FinancialStatements/JournalSheet/types.ts index f71970251..6eff84957 100644 --- a/packages/server/src/services/FinancialStatements/JournalSheet/types.ts +++ b/packages/server/src/services/FinancialStatements/JournalSheet/types.ts @@ -1,6 +1,5 @@ - -enum ROW_TYPE { +export enum ROW_TYPE { ENTRY = 'ENTRY', TOTAL = 'TOTAL' }; \ No newline at end of file diff --git a/packages/webapp/src/containers/FinancialStatements/GeneralLedger/GeneralLedgerActionsBar.tsx b/packages/webapp/src/containers/FinancialStatements/GeneralLedger/GeneralLedgerActionsBar.tsx index 971da31d9..e450c78bb 100644 --- a/packages/webapp/src/containers/FinancialStatements/GeneralLedger/GeneralLedgerActionsBar.tsx +++ b/packages/webapp/src/containers/FinancialStatements/GeneralLedger/GeneralLedgerActionsBar.tsx @@ -12,6 +12,7 @@ import { import classNames from 'classnames'; import { DashboardActionsBar, FormattedMessage as T, Icon } from '@/components'; +import { GeneralLedgerSheetExportMenu } from './components'; import { useGeneralLedgerContext } from './GeneralLedgerProvider'; import { compose } from '@/utils'; @@ -84,11 +85,18 @@ function GeneralLedgerActionsBar({ icon={} text={} /> -