refactor(nestjs): replace the reports endpoints

This commit is contained in:
Ahmed Bouhuolia
2025-05-09 18:55:16 +02:00
parent 3c8b7c92fe
commit 7506c2f37f
24 changed files with 82 additions and 62 deletions

View File

@@ -1,6 +1,7 @@
// @ts-nocheck
import * as R from 'ramda';
import { defaultTo, toArray } from 'lodash';
import { I18nService } from 'nestjs-i18n';
import { FinancialSheetStructure } from '../../common/FinancialSheetStructure';
import {
BALANCE_SHEET_SCHEMA_NODE_TYPE,
@@ -61,7 +62,7 @@ export const BalanceSheetAccounts = <T extends GConstructor<FinancialSheet>>(
/**
* Localization.
*/
readonly i18n: any;
readonly i18n: I18nService;
/**
* Balance sheet repository.
@@ -172,7 +173,7 @@ export const BalanceSheetAccounts = <T extends GConstructor<FinancialSheet>>(
return {
id: node.id,
name: this.i18n.__(node.name),
name: this.i18n.t(node.name),
nodeType: BALANCE_SHEET_SCHEMA_NODE_TYPE.ACCOUNTS,
type: BALANCE_SHEET_SCHEMA_NODE_TYPE.ACCOUNTS,
children: [...accounts, ...children],

View File

@@ -1,5 +1,6 @@
// @ts-nocheck
import * as R from 'ramda';
import { I18nService } from 'nestjs-i18n';
import {
BALANCE_SHEET_SCHEMA_NODE_TYPE,
IBalanceSheetAggregateNode,
@@ -31,6 +32,8 @@ export const BalanceSheetAggregators = <T extends GConstructor<FinancialSheet>>(
FinancialSheetStructure,
BalanceSheetBase,
)(Base) {
public readonly i18n: I18nService;
/**
* Balance sheet query.
* @param {BalanceSheetQuery}
@@ -89,7 +92,7 @@ export const BalanceSheetAggregators = <T extends GConstructor<FinancialSheet>>(
const total = this.getTotalOfNodes(node.children);
return {
name: this.i18n.__(node.name),
name: this.i18n.t(node.name),
id: node.id,
nodeType: BALANCE_SHEET_SCHEMA_NODE_TYPE.AGGREGATE,
type: BALANCE_SHEET_SCHEMA_NODE_TYPE.AGGREGATE,

View File

@@ -1,5 +1,6 @@
// @ts-nocheck
import * as R from 'ramda';
import { I18nService } from 'nestjs-i18n';
import {
BALANCE_SHEET_SCHEMA_NODE_TYPE,
IBalanceSheetDataNode,
@@ -32,6 +33,7 @@ export const BalanceSheetNetIncome = <T extends GConstructor<FinancialSheet>>(
)(Base) {
public repository: BalanceSheetRepository;
public query: BalanceSheetQuery;
public i18n: I18nService;
/**
* Retrieves the closing balance of income accounts.
@@ -74,7 +76,7 @@ export const BalanceSheetNetIncome = <T extends GConstructor<FinancialSheet>>(
return {
id: node.id,
name: this.i18n.__(node.name),
name: this.i18n.t(node.name),
nodeType: BALANCE_SHEET_SCHEMA_NODE_TYPE.NET_INCOME,
total: this.getTotalAmountMeta(total),
};

View File

@@ -1,5 +1,6 @@
// @ts-nocheck
import * as R from 'ramda';
import { I18nService } from 'nestjs-i18n';
import {
IBalanceSheetStatementData,
IBalanceSheetQuery,
@@ -43,6 +44,8 @@ export class BalanceSheetTable extends R.pipe(
BalanceSheetTablePreviousYear,
BalanceSheetTablePreviousPeriod,
)(FinancialSheet) {
public i18n: I18nService;
/**
* Balance sheet data.
* @param {IBalanceSheetStatementData}
@@ -225,9 +228,7 @@ export class BalanceSheetTable extends R.pipe(
return R.compose(
R.unless(
R.isEmpty,
R.concat([
{ key: 'total', label: this.i18n.__('balance_sheet.total') },
]),
R.concat([{ key: 'total', label: this.i18n.t('balance_sheet.total') }]),
),
R.concat(this.percentageColumns()),
R.concat(this.getPreviousYearColumns()),
@@ -243,7 +244,7 @@ export class BalanceSheetTable extends R.pipe(
return [
{
key: 'total',
label: this.i18n.__('balance_sheet.total'),
label: this.i18n.t('balance_sheet.total'),
children: this.totalColumnChildren(),
},
];
@@ -271,7 +272,7 @@ export class BalanceSheetTable extends R.pipe(
return R.compose(
this.tableColumnsCellIndexing,
R.concat([
{ key: 'name', label: this.i18n.__('balance_sheet.account_name') },
{ key: 'name', label: this.i18n.t('balance_sheet.account_name') },
]),
R.ifElse(
this.query.isDatePeriodsColumnsType,

View File

@@ -13,6 +13,8 @@ export const BalanceSheetTableDatePeriods = <
Base: T,
) =>
class extends R.pipe(FinancialDatePeriods)(Base) {
public i18n: I18nService;
/**
* Retrieves the date periods based on the report query.
* @returns {IDateRange[]}
@@ -104,7 +106,7 @@ export const BalanceSheetTableDatePeriods = <
R.unless(
R.isEmpty,
R.concat([
{ key: `total`, label: this.i18n.__('balance_sheet.total') },
{ key: `total`, label: this.i18n.t('balance_sheet.total') },
]),
),
R.concat(this.percentageColumns()),

View File

@@ -1,3 +1,4 @@
import * as moment from 'moment';
import { IBalanceSheetQuery } from "./BalanceSheet.types";
export const MAP_CONFIG = { childrenPath: 'children', pathFormat: 'array' };