mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
feat: wip journal and general ledger dyanmic columns
This commit is contained in:
@@ -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];
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
|
||||
enum ROW_TYPE {
|
||||
export enum ROW_TYPE {
|
||||
ENTRY = 'ENTRY',
|
||||
TOTAL = 'TOTAL'
|
||||
};
|
||||
Reference in New Issue
Block a user