mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
refactor(nestjs): replace the reports endpoints
This commit is contained in:
@@ -68,6 +68,7 @@ export class AuthController {
|
||||
return this.authApp.signUpConfirm(email, token);
|
||||
}
|
||||
|
||||
|
||||
@Post('/send_reset_password')
|
||||
@ApiOperation({ summary: 'Send reset password email' })
|
||||
@ApiBody({
|
||||
|
||||
@@ -16,10 +16,9 @@ export class AuthedController {
|
||||
constructor(
|
||||
private readonly getAuthedAccountService: GetAuthenticatedAccount,
|
||||
private readonly authApp: AuthenticationApplication,
|
||||
private readonly tenancyContext: TenancyContext,
|
||||
) {}
|
||||
|
||||
@Post('/signup/confirm/resend')
|
||||
@Post('/signup/verify/resend')
|
||||
@ApiOperation({ summary: 'Resend the signup confirmation message' })
|
||||
@ApiBody({
|
||||
schema: {
|
||||
|
||||
@@ -92,7 +92,10 @@ export class AuthSignupService {
|
||||
const isEmailExists = await this.systemUserModel.query().findOne({ email });
|
||||
|
||||
if (isEmailExists) {
|
||||
throw new ServiceError(ERRORS.EMAIL_EXISTS);
|
||||
throw new ServiceError(
|
||||
ERRORS.EMAIL_EXISTS,
|
||||
'The given email address is already signed-up',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,11 +123,17 @@ export class AuthSignupService {
|
||||
);
|
||||
|
||||
if (!isAllowedEmail && !isAllowedDomain) {
|
||||
throw new ServiceError(ERRORS.SIGNUP_RESTRICTED_NOT_ALLOWED);
|
||||
throw new ServiceError(
|
||||
ERRORS.SIGNUP_RESTRICTED_NOT_ALLOWED,
|
||||
'The given email address format is not allowed to signup.',
|
||||
);
|
||||
}
|
||||
// Throw error if the signup is disabled with no exceptions.
|
||||
} else {
|
||||
throw new ServiceError(ERRORS.SIGNUP_RESTRICTED);
|
||||
throw new ServiceError(
|
||||
ERRORS.SIGNUP_RESTRICTED,
|
||||
'The sign-up is disabled',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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),
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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()),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import * as moment from 'moment';
|
||||
import { IBalanceSheetQuery } from "./BalanceSheet.types";
|
||||
|
||||
export const MAP_CONFIG = { childrenPath: 'children', pathFormat: 'array' };
|
||||
|
||||
Reference in New Issue
Block a user