mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
feat(server): wip journal and general ledger table layer
This commit is contained in:
@@ -37,6 +37,7 @@ export interface IGeneralLedgerSheetAccountTransaction {
|
|||||||
referenceType?: string,
|
referenceType?: string,
|
||||||
|
|
||||||
date: Date|string,
|
date: Date|string,
|
||||||
|
dateFormatted: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface IGeneralLedgerSheetAccountBalance {
|
export interface IGeneralLedgerSheetAccountBalance {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export interface IJournalReportQuery {
|
|||||||
|
|
||||||
export interface IJournalReportEntriesGroup {
|
export interface IJournalReportEntriesGroup {
|
||||||
id: string;
|
id: string;
|
||||||
|
dateFormatted: string;
|
||||||
entries: IJournalEntry[];
|
entries: IJournalEntry[];
|
||||||
currencyCode: string;
|
currencyCode: string;
|
||||||
credit: number;
|
credit: number;
|
||||||
@@ -41,5 +42,10 @@ export interface IJournalTable extends IFinancialTable {
|
|||||||
meta: IJournalSheetMeta;
|
meta: IJournalSheetMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type IJournalTableData = IJournalReportEntriesGroup[];
|
||||||
|
|
||||||
export type IJournalTableData = IJournalReportEntriesGroup[];
|
export interface IJournalSheet {
|
||||||
|
data: IJournalTableData;
|
||||||
|
query: IJournalReportQuery;
|
||||||
|
meta: IJournalSheetMeta;
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
IContact,
|
IContact,
|
||||||
} from '@/interfaces';
|
} from '@/interfaces';
|
||||||
import FinancialSheet from '../FinancialSheet';
|
import FinancialSheet from '../FinancialSheet';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General ledger sheet.
|
* General ledger sheet.
|
||||||
@@ -88,6 +89,7 @@ export default class GeneralLedgerSheet extends FinancialSheet {
|
|||||||
|
|
||||||
const newEntry = {
|
const newEntry = {
|
||||||
date: entry.date,
|
date: entry.date,
|
||||||
|
dateFromatted: moment(entry.date).format('YYYY/MM/DD'),
|
||||||
entryId: entry.id,
|
entryId: entry.id,
|
||||||
|
|
||||||
referenceType: entry.referenceType,
|
referenceType: entry.referenceType,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import * as R from 'ramda';
|
import * as R from 'ramda';
|
||||||
import {
|
import {
|
||||||
IGeneralLedgerSheetAccount,
|
IGeneralLedgerSheetAccount,
|
||||||
|
IGeneralLedgerSheetAccountTransaction,
|
||||||
IGeneralLedgerSheetData,
|
IGeneralLedgerSheetData,
|
||||||
IGeneralLedgerSheetQuery,
|
IGeneralLedgerSheetQuery,
|
||||||
ITableColumn,
|
ITableColumn,
|
||||||
@@ -35,15 +36,34 @@ export class GeneralLedgerTable extends R.compose(
|
|||||||
* Retrieves the common table accessors.
|
* Retrieves the common table accessors.
|
||||||
* @returns {ITableColumnAccessor[]}
|
* @returns {ITableColumnAccessor[]}
|
||||||
*/
|
*/
|
||||||
private commonColumnsAccessors(): ITableColumnAccessor[] {
|
private accountColumnsAccessors(): ITableColumnAccessor[] {
|
||||||
|
return [
|
||||||
|
{ key: 'date', accessor: 'name' },
|
||||||
|
{ key: 'account_name', accessor: '_empty_' },
|
||||||
|
{ key: 'reference_type', accessor: '_empty_' },
|
||||||
|
{ key: 'reference_number', accessor: '_empty_' },
|
||||||
|
{ key: 'description', accessor: 'description' },
|
||||||
|
{ key: 'credit', accessor: '_empty_' },
|
||||||
|
{ key: 'debit', accessor: '_empty_' },
|
||||||
|
{ key: 'amount', accessor: 'amount.formattedAmount' },
|
||||||
|
{ key: 'running_balance', accessor: 'openingBalance.formattedAmount' },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the transaction column accessors.
|
||||||
|
* @returns {ITableColumnAccessor[]}
|
||||||
|
*/
|
||||||
|
private transactionColumnAccessors(): ITableColumnAccessor[] {
|
||||||
return [
|
return [
|
||||||
{ key: 'date', accessor: 'date' },
|
{ key: 'date', accessor: 'date' },
|
||||||
|
{ key: 'account_name', accessor: 'name' },
|
||||||
{ key: 'reference_type', accessor: 'referenceTypeFormatted' },
|
{ key: 'reference_type', accessor: 'referenceTypeFormatted' },
|
||||||
{ key: 'reference_number', accessor: 'reference_number' },
|
{ key: 'reference_number', accessor: 'referenceNumber' },
|
||||||
{ key: 'currency_code', accessor: 'currencyCode' },
|
{ key: 'currency_code', accessor: 'currencyCode' },
|
||||||
{ key: 'credit', accessor: 'formattedCredit' },
|
{ key: 'credit', accessor: 'formattedCredit' },
|
||||||
{ key: 'debit', accessor: 'formattedDebit' },
|
{ key: 'debit', accessor: 'formattedDebit' },
|
||||||
{ key: 'running_balance', accessor: 'formattedRunningBalance' },
|
{ key: 'running_balance', accessor: 'runningBalance.formattedAmount' },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,24 +74,52 @@ export class GeneralLedgerTable extends R.compose(
|
|||||||
private commonColumns(): ITableColumn[] {
|
private commonColumns(): ITableColumn[] {
|
||||||
return [
|
return [
|
||||||
{ key: 'date', label: 'Date' },
|
{ key: 'date', label: 'Date' },
|
||||||
{ key: 'reference_type', label: 'Reference Type' },
|
{ key: 'account_name', label: 'Account Name' },
|
||||||
{ key: 'reference_number', label: 'Reference Number' },
|
{ key: 'reference_type', label: 'Transaction Type' },
|
||||||
{ key: 'currency_code', label: 'Currency Code' },
|
{ key: 'reference_number', label: 'Transaction Number' },
|
||||||
|
{ key: 'description', label: 'Description' },
|
||||||
{ key: 'credit', label: 'Credit' },
|
{ key: 'credit', label: 'Credit' },
|
||||||
{ key: 'debit', label: 'Debit' },
|
{ key: 'debit', label: 'Debit' },
|
||||||
|
{ key: 'amount', label: 'Amount' },
|
||||||
{ key: 'running_balance', label: 'Running Balance' },
|
{ key: 'running_balance', label: 'Running Balance' },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps the given transaction node to table row.
|
||||||
|
* @param {IGeneralLedgerSheetAccountTransaction} transaction
|
||||||
|
* @returns {ITableRow}
|
||||||
|
*/
|
||||||
|
private transactionMapper = (
|
||||||
|
transaction: IGeneralLedgerSheetAccountTransaction
|
||||||
|
): ITableRow => {
|
||||||
|
const columns = this.transactionColumnAccessors();
|
||||||
|
|
||||||
|
return tableRowMapper(transaction, columns, {});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps the given transactions nodes to table rows.
|
||||||
|
* @param {IGeneralLedgerSheetAccountTransaction[]} transactions
|
||||||
|
* @returns {ITableRow[]}
|
||||||
|
*/
|
||||||
|
private transactionsMapper = (
|
||||||
|
transactions: IGeneralLedgerSheetAccountTransaction[]
|
||||||
|
): ITableRow[] => {
|
||||||
|
return R.map(this.transactionMapper)(transactions);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps the given account node to the table rows.
|
* Maps the given account node to the table rows.
|
||||||
* @param {IGeneralLedgerSheetAccount} account
|
* @param {IGeneralLedgerSheetAccount} account
|
||||||
* @returns {ITableRow}
|
* @returns {ITableRow}
|
||||||
*/
|
*/
|
||||||
private accountMapper = (account: IGeneralLedgerSheetAccount): ITableRow => {
|
private accountMapper = (account: IGeneralLedgerSheetAccount): ITableRow => {
|
||||||
const columns = this.commonColumnsAccessors();
|
const columns = this.accountColumnsAccessors();
|
||||||
|
const row = tableRowMapper(account, columns, {});
|
||||||
|
const transactions = this.transactionsMapper(account.transactions);
|
||||||
|
|
||||||
return tableRowMapper(account, columns, {});
|
return R.assoc('children', transactions)(row);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,7 +130,7 @@ export class GeneralLedgerTable extends R.compose(
|
|||||||
private accountsMapper = (
|
private accountsMapper = (
|
||||||
accounts: IGeneralLedgerSheetAccount[]
|
accounts: IGeneralLedgerSheetAccount[]
|
||||||
): ITableRow[] => {
|
): ITableRow[] => {
|
||||||
return R.compose(R.map(this.accountMapper))(accounts);
|
return this.mapNodesDeep(accounts, this.accountMapper)l
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import {
|
|||||||
IJournalReportQuery,
|
IJournalReportQuery,
|
||||||
IJournalReport,
|
IJournalReport,
|
||||||
IContact,
|
IContact,
|
||||||
|
IJournalTableData,
|
||||||
} from '@/interfaces';
|
} from '@/interfaces';
|
||||||
import FinancialSheet from '../FinancialSheet';
|
import FinancialSheet from '../FinancialSheet';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
export default class JournalSheet extends FinancialSheet {
|
export default class JournalSheet extends FinancialSheet {
|
||||||
readonly tenantId: number;
|
readonly tenantId: number;
|
||||||
@@ -96,6 +98,8 @@ export default class JournalSheet extends FinancialSheet {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
date: groupEntry.date,
|
date: groupEntry.date,
|
||||||
|
dateFormatted: moment(groupEntry.date).format('YYYY/MM/DD'),
|
||||||
|
|
||||||
referenceType: groupEntry.referenceType,
|
referenceType: groupEntry.referenceType,
|
||||||
referenceId: groupEntry.referenceId,
|
referenceId: groupEntry.referenceId,
|
||||||
referenceTypeFormatted: this.i18n.__(groupEntry.referenceTypeFormatted),
|
referenceTypeFormatted: this.i18n.__(groupEntry.referenceTypeFormatted),
|
||||||
@@ -131,7 +135,7 @@ export default class JournalSheet extends FinancialSheet {
|
|||||||
* Retrieve journal report.
|
* Retrieve journal report.
|
||||||
* @return {IJournalReport}
|
* @return {IJournalReport}
|
||||||
*/
|
*/
|
||||||
reportData(): IJournalReport {
|
reportData(): IJournalTableData {
|
||||||
return this.entriesWalker(this.journal.entries);
|
return this.entriesWalker(this.journal.entries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import { Service, Inject } from 'typedi';
|
import { Service, Inject } from 'typedi';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { IJournalReportQuery, IJournalSheetMeta } from '@/interfaces';
|
import {
|
||||||
|
IJournalReportQuery,
|
||||||
|
IJournalSheet,
|
||||||
|
IJournalSheetMeta,
|
||||||
|
IJournalTableData,
|
||||||
|
} from '@/interfaces';
|
||||||
import JournalSheet from './JournalSheet';
|
import JournalSheet from './JournalSheet';
|
||||||
import TenancyService from '@/services/Tenancy/TenancyService';
|
import TenancyService from '@/services/Tenancy/TenancyService';
|
||||||
import Journal from '@/services/Accounting/JournalPoster';
|
import Journal from '@/services/Accounting/JournalPoster';
|
||||||
@@ -11,13 +16,10 @@ import { parseBoolean, transformToMap } from 'utils';
|
|||||||
@Service()
|
@Service()
|
||||||
export class JournalSheetService {
|
export class JournalSheetService {
|
||||||
@Inject()
|
@Inject()
|
||||||
tenancy: TenancyService;
|
private tenancy: TenancyService;
|
||||||
|
|
||||||
@Inject()
|
@Inject()
|
||||||
inventoryService: InventoryService;
|
private inventoryService: InventoryService;
|
||||||
|
|
||||||
@Inject('logger')
|
|
||||||
logger: any;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default journal sheet filter queyr.
|
* Default journal sheet filter queyr.
|
||||||
@@ -66,9 +68,13 @@ export class JournalSheetService {
|
|||||||
/**
|
/**
|
||||||
* Journal sheet.
|
* Journal sheet.
|
||||||
* @param {number} tenantId
|
* @param {number} tenantId
|
||||||
* @param {IJournalSheetFilterQuery} query
|
* @param {IJournalReportQuery} query
|
||||||
|
* @returns {Promise<IJournalSheet>}
|
||||||
*/
|
*/
|
||||||
async journalSheet(tenantId: number, query: IJournalReportQuery) {
|
async journalSheet(
|
||||||
|
tenantId: number,
|
||||||
|
query: IJournalReportQuery
|
||||||
|
): Promise<IJournalSheet> {
|
||||||
const i18n = this.tenancy.i18n(tenantId);
|
const i18n = this.tenancy.i18n(tenantId);
|
||||||
const { accountRepository, transactionsRepository, contactRepository } =
|
const { accountRepository, transactionsRepository, contactRepository } =
|
||||||
this.tenancy.repositories(tenantId);
|
this.tenancy.repositories(tenantId);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as R from 'ramda';
|
import * as R from 'ramda';
|
||||||
import {
|
import {
|
||||||
|
IJournalEntry,
|
||||||
IJournalReport,
|
IJournalReport,
|
||||||
IJournalReportEntriesGroup,
|
IJournalReportEntriesGroup,
|
||||||
IJournalReportQuery,
|
IJournalReportQuery,
|
||||||
@@ -12,6 +13,7 @@ import { tableRowMapper } from '@/utils';
|
|||||||
import { FinancialTable } from '../FinancialTable';
|
import { FinancialTable } from '../FinancialTable';
|
||||||
import { FinancialSheetStructure } from '../FinancialSheetStructure';
|
import { FinancialSheetStructure } from '../FinancialSheetStructure';
|
||||||
import FinancialSheet from '../FinancialSheet';
|
import FinancialSheet from '../FinancialSheet';
|
||||||
|
import { first } from 'lodash';
|
||||||
|
|
||||||
export class JournalSheetTable extends R.compose(
|
export class JournalSheetTable extends R.compose(
|
||||||
FinancialTable,
|
FinancialTable,
|
||||||
@@ -21,6 +23,12 @@ export class JournalSheetTable extends R.compose(
|
|||||||
private query: IJournalReportQuery;
|
private query: IJournalReportQuery;
|
||||||
private i18n: any;
|
private i18n: any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor method.
|
||||||
|
* @param {IJournalTableData} data
|
||||||
|
* @param {IJournalReportQuery} query
|
||||||
|
* @param i18n
|
||||||
|
*/
|
||||||
constructor(data: IJournalTableData, query: IJournalReportQuery, i18n: any) {
|
constructor(data: IJournalTableData, query: IJournalReportQuery, i18n: any) {
|
||||||
super();
|
super();
|
||||||
this.data = data;
|
this.data = data;
|
||||||
@@ -32,47 +40,141 @@ export class JournalSheetTable extends R.compose(
|
|||||||
* Retrieves the common table accessors.
|
* Retrieves the common table accessors.
|
||||||
* @returns {ITableColumnAccessor[]}
|
* @returns {ITableColumnAccessor[]}
|
||||||
*/
|
*/
|
||||||
private commonColumnsAccessors = (): ITableColumnAccessor[] => {
|
private groupColumnsAccessors = (): ITableColumnAccessor[] => {
|
||||||
return [
|
return [
|
||||||
{ key: 'date', accessor: 'date' },
|
{ key: 'date', accessor: 'date' },
|
||||||
{ key: 'reference_type', accessor: 'referenceTypeFormatted' },
|
{ key: 'transaction_type', accessor: 'referenceTypeFormatted' },
|
||||||
{ key: 'reference_number', accessor: 'reference_number' },
|
{ key: 'transaction_number', accessor: 'referenceNumber' },
|
||||||
{ key: 'currency_code', accessor: 'currencyCode' },
|
{ key: 'description', accessor: 'entry.description' },
|
||||||
|
{ key: 'account_code', accessor: 'entry.accountCode' },
|
||||||
|
{ key: 'account_name', accessor: 'entry.accountName' },
|
||||||
|
{ key: 'credit', accessor: 'entry.formattedCredit' },
|
||||||
|
{ key: 'debit', accessor: 'entry.formattedDebit' },
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the group entry accessors.
|
||||||
|
* @returns {ITableColumnAccessor[]}
|
||||||
|
*/
|
||||||
|
private entryColumnsAccessors = (): ITableColumnAccessor[] => {
|
||||||
|
return [
|
||||||
|
{ key: 'date', accessor: '_empty_' },
|
||||||
|
{ key: 'transaction_type', accessor: '_empty_' },
|
||||||
|
{ key: 'transaction_number', accessor: '_empty_' },
|
||||||
|
{ key: 'description', accessor: 'description' },
|
||||||
|
{ key: 'account_code', accessor: 'accountCode' },
|
||||||
|
{ key: 'account_name', accessor: 'accountName' },
|
||||||
{ key: 'credit', accessor: 'formattedCredit' },
|
{ key: 'credit', accessor: 'formattedCredit' },
|
||||||
{ key: 'debit', accessor: 'formattedDebit' },
|
{ key: 'debit', accessor: 'formattedDebit' },
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private totalEntryColumnAccessors = (): ITableColumnAccessor[] => {
|
||||||
|
return [
|
||||||
|
{ key: 'date', accessor: '_empty_' },
|
||||||
|
{ key: 'transaction_type', accessor: '_empty_' },
|
||||||
|
{ key: 'transaction_number', accessor: '_empty_' },
|
||||||
|
{ key: 'description', accessor: '_empty_' },
|
||||||
|
{ key: 'account_code', accessor: '_empty_' },
|
||||||
|
{ key: 'account_name', accessor: '_empty_' },
|
||||||
|
{ key: 'credit', accessor: 'formattedCredit' },
|
||||||
|
{ key: 'debit', accessor: 'formattedDebit' },
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the common columns.
|
||||||
|
* @returns {ITableColumn[]}
|
||||||
|
*/
|
||||||
private commonColumns(): ITableColumn[] {
|
private commonColumns(): ITableColumn[] {
|
||||||
return [
|
return [
|
||||||
{ key: 'date', label: 'Date' },
|
{ key: 'date', label: 'Date' },
|
||||||
{ key: 'reference_type', label: 'Reference Type' },
|
{ key: 'transaction_type', label: 'Transaction Type' },
|
||||||
{ key: 'reference_type', label: 'Reference Number' },
|
{ key: 'transaction_number', label: 'Num.' },
|
||||||
{ key: 'currency_code', label: 'Currency Code' },
|
{ key: 'description', label: 'Description' },
|
||||||
|
{ key: 'account_code', label: 'Acc. Code' },
|
||||||
|
{ key: 'account_name', label: 'Account' },
|
||||||
{ key: 'credit', label: 'Credit' },
|
{ key: 'credit', label: 'Credit' },
|
||||||
{ key: 'debit', label: 'Debit' },
|
{ key: 'debit', label: 'Debit' },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Maps the group and first entry to table row.
|
||||||
|
* @param {IJournalReportEntriesGroup} group
|
||||||
|
* @returns {ITableRow}
|
||||||
*/
|
*/
|
||||||
private entryGroupMapper = (group: IJournalReportEntriesGroup) => {
|
private firstEntryGroupMapper = (
|
||||||
const columns = this.commonColumnsAccessors();
|
group: IJournalReportEntriesGroup
|
||||||
|
): ITableRow => {
|
||||||
return tableRowMapper(group, columns, {});
|
const meta = {
|
||||||
|
rowTypes: [ROW_TYPE.ENTRY],
|
||||||
|
};
|
||||||
|
const computedGroup = { ...group, entry: first(group.entries) };
|
||||||
|
const columns = this.groupColumnsAccessors();
|
||||||
|
return tableRowMapper(computedGroup, columns, meta);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Maps the given group entry to table rows.
|
||||||
|
* @param {IJournalEntry} entry
|
||||||
|
* @returns {ITableRow}
|
||||||
*/
|
*/
|
||||||
private entryMapper = () => {};
|
private entryMapper = (entry: IJournalEntry): ITableRow => {
|
||||||
|
const columns = this.entryColumnsAccessors();
|
||||||
|
const meta = {
|
||||||
|
rowTypes: [ROW_TYPE.ENTRY],
|
||||||
|
};
|
||||||
|
return tableRowMapper(entry, columns, meta);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Maps the given group entries to table rows.
|
||||||
|
* @param {IJournalReportEntriesGroup} group
|
||||||
|
* @returns {ITableRow[]}
|
||||||
*/
|
*/
|
||||||
private entriesGroupsMapper = (entries: IJournalReportEntriesGroup[]) => {
|
private entriesMapper = (group: IJournalReportEntriesGroup): ITableRow[] => {
|
||||||
return R.compose(R.map(this.entryGroupMapper))(entries);
|
const entries = R.remove(0, 1, group.entries);
|
||||||
|
|
||||||
|
return R.map(this.entryMapper, entries);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps the given group entry to total table row.
|
||||||
|
* @param {IJournalReportEntriesGroup} group
|
||||||
|
* @returns {ITableRow}
|
||||||
|
*/
|
||||||
|
public totalEntryMapper = (group: IJournalReportEntriesGroup): ITableRow => {
|
||||||
|
const total = this.totalEntryColumnAccessors();
|
||||||
|
const meta = {
|
||||||
|
rowTypes: [ROW_TYPE.TOTAL],
|
||||||
|
};
|
||||||
|
return tableRowMapper(group, total, meta);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps the entry group to table rows.
|
||||||
|
* @param {IJournalReportEntriesGroup} group -
|
||||||
|
* @returns {ITableRow}
|
||||||
|
*/
|
||||||
|
private groupMapper = (group: IJournalReportEntriesGroup): ITableRow[] => {
|
||||||
|
const firstRow = this.firstEntryGroupMapper(group);
|
||||||
|
const lastRows = this.entriesMapper(group);
|
||||||
|
const totalRow = this.totalEntryMapper(group);
|
||||||
|
|
||||||
|
return [firstRow, ...lastRows, totalRow];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps the given group entries to table rows.
|
||||||
|
* @param {IJournalReportEntriesGroup[]} entries -
|
||||||
|
* @returns {ITableRow[]}
|
||||||
|
*/
|
||||||
|
private groupsMapper = (
|
||||||
|
entries: IJournalReportEntriesGroup[]
|
||||||
|
): ITableRow[] => {
|
||||||
|
return R.compose(R.flatten, R.map(this.groupMapper))(entries);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +182,7 @@ export class JournalSheetTable extends R.compose(
|
|||||||
* @returns {ITableRow[]}
|
* @returns {ITableRow[]}
|
||||||
*/
|
*/
|
||||||
public tableData(): ITableRow[] {
|
public tableData(): ITableRow[] {
|
||||||
return R.compose(this.entriesGroupsMapper)(this.data);
|
return R.compose(this.groupsMapper)(this.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
enum ROW_TYPE {
|
||||||
|
ENTRY = 'ENTRY',
|
||||||
|
TOTAL = 'TOTAL'
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user