feat: general ledger and journal rows types

This commit is contained in:
Ahmed Bouhuolia
2024-01-06 22:30:41 +02:00
parent 79f3f1b63d
commit 7aee76e461
4 changed files with 27 additions and 16 deletions

View File

@@ -13,6 +13,7 @@ import FinancialSheet from '../FinancialSheet';
import { FinancialSheetStructure } from '../FinancialSheetStructure'; import { FinancialSheetStructure } from '../FinancialSheetStructure';
import { FinancialTable } from '../FinancialTable'; import { FinancialTable } from '../FinancialTable';
import { tableRowMapper } from '@/utils'; import { tableRowMapper } from '@/utils';
import { ROW_TYPE } from './utils';
export class GeneralLedgerTable extends R.compose( export class GeneralLedgerTable extends R.compose(
FinancialTable, FinancialTable,
@@ -135,8 +136,10 @@ export class GeneralLedgerTable extends R.compose(
): ITableRow => { ): ITableRow => {
const columns = this.transactionColumnAccessors(); const columns = this.transactionColumnAccessors();
const data = { ...transaction, account }; const data = { ...transaction, account };
const meta = {
return tableRowMapper(data, columns, {}); rowTypes: [ROW_TYPE.TRANSACTION],
};
return tableRowMapper(data, columns, meta);
} }
); );
@@ -162,8 +165,10 @@ export class GeneralLedgerTable extends R.compose(
account: IGeneralLedgerSheetAccount account: IGeneralLedgerSheetAccount
): ITableRow => { ): ITableRow => {
const columns = this.openingBalanceColumnsAccessors(); const columns = this.openingBalanceColumnsAccessors();
const meta = {
return tableRowMapper(account, columns, {}); rowTypes: [ROW_TYPE.OPENING_BALANCE],
};
return tableRowMapper(account, columns, meta);
}; };
/** /**
@@ -173,8 +178,10 @@ export class GeneralLedgerTable extends R.compose(
*/ */
private closingBalanceMapper = (account: IGeneralLedgerSheetAccount) => { private closingBalanceMapper = (account: IGeneralLedgerSheetAccount) => {
const columns = this.closingBalanceColumnAccessors(); const columns = this.closingBalanceColumnAccessors();
const meta = {
return tableRowMapper(account, columns, {}); rowTypes: [ROW_TYPE.CLOSING_BALANCE],
};
return tableRowMapper(account, columns, meta);
}; };
/** /**
@@ -199,8 +206,11 @@ export class GeneralLedgerTable extends R.compose(
*/ */
private accountMapper = (account: IGeneralLedgerSheetAccount): ITableRow => { private accountMapper = (account: IGeneralLedgerSheetAccount): ITableRow => {
const columns = this.accountColumnsAccessors(); const columns = this.accountColumnsAccessors();
const row = tableRowMapper(account, columns, {});
const transactions = this.transactionsNode(account); const transactions = this.transactionsNode(account);
const meta = {
rowTypes: [ROW_TYPE.ACCOUNT],
};
const row = tableRowMapper(account, columns, meta);
return R.assoc('children', transactions)(row); return R.assoc('children', transactions)(row);
}; };

View File

@@ -0,0 +1,6 @@
export enum ROW_TYPE {
ACCOUNT = 'ACCOUNT',
OPENING_BALANCE = 'OPENING_BALANCE',
TRANSACTION = 'TRANSACTION',
CLOSING_BALANCE = 'CLOSING_BALANCE',
}

View File

@@ -1,5 +1,5 @@
// @ts-nocheck // @ts-nocheck
import React, { useMemo } from 'react'; import { useMemo } from 'react';
import intl from 'react-intl-universal'; import intl from 'react-intl-universal';
import styled from 'styled-components'; import styled from 'styled-components';
@@ -79,23 +79,20 @@ const GeneralLedgerDataTable = styled(ReportDataTable)`
opacity: 0; opacity: 0;
} }
} }
.tr:not(.no-results) .td:not(:first-of-type) { .tr:not(.no-results) .td:not(:first-of-type) {
border-left: 1px solid #ececec; border-left: 1px solid #ececec;
} }
.tr:last-child .td { .tr:last-child .td {
border-bottom: 1px solid #ececec; border-bottom: 1px solid #ececec;
} }
.tr.row_type { .tr.row_type {
&--ACCOUNT_ROW { &--ACCOUNT {
.td { .td {
&.date { &.date {
font-weight: 500; font-weight: 500;
.cell-inner { .cell-inner {
white-space: nowrap; position: absolute;
position: relative;
} }
} }
} }
@@ -103,7 +100,6 @@ const GeneralLedgerDataTable = styled(ReportDataTable)`
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
} }
} }
&--OPENING_BALANCE, &--OPENING_BALANCE,
&--CLOSING_BALANCE { &--CLOSING_BALANCE {
.amount { .amount {

View File

@@ -83,10 +83,9 @@ const JournalDataTable = styled(ReportDataTable)`
border-bottom: 1px solid #dbdbdb; border-bottom: 1px solid #dbdbdb;
} }
} }
.tr.row_type--TOTAL_ENTRIES { .tr.row_type--TOTAL{
font-weight: 600; font-weight: 600;
} }
.tr:not(.no-results) { .tr:not(.no-results) {
height: 28px; height: 28px;
} }