mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: always show some sections in balance sheet.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { Router, Request, Response, NextFunction } from 'express';
|
||||
import { Router, Request, Response, NextFunction } from 'express';
|
||||
import { query, ValidationChain } from 'express-validator';
|
||||
import { castArray } from 'lodash';
|
||||
import asyncMiddleware from 'api/middleware/asyncMiddleware';
|
||||
@@ -7,7 +7,7 @@ import BaseController from '../BaseController';
|
||||
import BalanceSheetStatementService from 'services/FinancialStatements/BalanceSheet/BalanceSheetService';
|
||||
|
||||
@Service()
|
||||
export default class BalanceSheetStatementController extends BaseController{
|
||||
export default class BalanceSheetStatementController extends BaseController {
|
||||
@Inject()
|
||||
balanceSheetService: BalanceSheetStatementService;
|
||||
|
||||
@@ -32,25 +32,15 @@ export default class BalanceSheetStatementController extends BaseController{
|
||||
*/
|
||||
get balanceSheetValidationSchema(): ValidationChain[] {
|
||||
return [
|
||||
query('accounting_method')
|
||||
.optional()
|
||||
.isIn(['cash', 'accural']),
|
||||
query('accounting_method').optional().isIn(['cash', 'accural']),
|
||||
query('from_date').optional(),
|
||||
query('to_date').optional(),
|
||||
query('display_columns_type')
|
||||
.optional()
|
||||
.isIn(['date_periods', 'total']),
|
||||
query('display_columns_type').optional().isIn(['date_periods', 'total']),
|
||||
query('display_columns_by')
|
||||
.optional({ nullable: true, checkFalsy: true })
|
||||
.isIn(['year', 'month', 'week', 'day', 'quarter']),
|
||||
query('number_format.no_cents')
|
||||
.optional()
|
||||
.isBoolean()
|
||||
.toBoolean(),
|
||||
query('number_format.divide_1000')
|
||||
.optional()
|
||||
.isBoolean()
|
||||
.toBoolean(),
|
||||
query('number_format.no_cents').optional().isBoolean().toBoolean(),
|
||||
query('number_format.divide_1000').optional().isBoolean().toBoolean(),
|
||||
query('account_ids').isArray().optional(),
|
||||
query('account_ids.*').isNumeric().toInt(),
|
||||
query('none_zero').optional().isBoolean().toBoolean(),
|
||||
@@ -69,14 +59,20 @@ export default class BalanceSheetStatementController extends BaseController{
|
||||
...filter,
|
||||
accountsIds: castArray(filter.accountsIds),
|
||||
};
|
||||
const organizationName = settings.get({ group: 'organization', key: 'name' });
|
||||
const baseCurrency = settings.get({ group: 'organization', key: 'base_currency' });
|
||||
const organizationName = settings.get({
|
||||
group: 'organization',
|
||||
key: 'name',
|
||||
});
|
||||
const baseCurrency = settings.get({
|
||||
group: 'organization',
|
||||
key: 'base_currency',
|
||||
});
|
||||
|
||||
try {
|
||||
const {
|
||||
data,
|
||||
columns,
|
||||
query
|
||||
query,
|
||||
} = await this.balanceSheetService.balanceSheet(tenantId, filter);
|
||||
|
||||
return res.status(200).send({
|
||||
@@ -85,9 +81,9 @@ export default class BalanceSheetStatementController extends BaseController{
|
||||
data: this.transfromToResponse(data),
|
||||
columns: this.transfromToResponse(columns),
|
||||
query: this.transfromToResponse(query),
|
||||
})
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@ import { Inject, Service } from 'typedi';
|
||||
import GeneralLedgerService from 'services/FinancialStatements/GeneralLedger/GeneralLedgerService';
|
||||
|
||||
@Service()
|
||||
export default class GeneralLedgerReportController extends BaseController{
|
||||
|
||||
export default class GeneralLedgerReportController extends BaseController {
|
||||
@Inject()
|
||||
generalLedgetService: GeneralLedgerService;
|
||||
|
||||
@@ -17,7 +16,8 @@ export default class GeneralLedgerReportController extends BaseController{
|
||||
router() {
|
||||
const router = Router();
|
||||
|
||||
router.get('/',
|
||||
router.get(
|
||||
'/',
|
||||
this.validationSchema,
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.generalLedger.bind(this))
|
||||
@@ -35,9 +35,9 @@ export default class GeneralLedgerReportController extends BaseController{
|
||||
query('basis').optional(),
|
||||
query('number_format.no_cents').optional().isBoolean().toBoolean(),
|
||||
query('number_format.divide_1000').optional().isBoolean().toBoolean(),
|
||||
query('none_transactions').optional().isBoolean().toBoolean(),
|
||||
query('accounts_ids').optional(),
|
||||
query('accounts_ids.*').isNumeric().toInt(),
|
||||
query('none_transactions').default(true).isBoolean().toBoolean(),
|
||||
query('accounts_ids').optional().isArray({ min: 1 }),
|
||||
query('accounts_ids.*').isInt().toInt(),
|
||||
query('orderBy').optional().isIn(['created_at', 'name', 'code']),
|
||||
query('order').optional().isIn(['desc', 'asc']),
|
||||
];
|
||||
@@ -45,22 +45,27 @@ export default class GeneralLedgerReportController extends BaseController{
|
||||
|
||||
/**
|
||||
* Retrieve the general ledger financial statement.
|
||||
* @param {Request} req -
|
||||
* @param {Response} res -
|
||||
* @param {Request} req -
|
||||
* @param {Response} res -
|
||||
*/
|
||||
async generalLedger(req: Request, res: Response, next: NextFunction) {
|
||||
const { tenantId, settings } = req;
|
||||
const filter = this.matchedQueryData(req);
|
||||
|
||||
const organizationName = settings.get({ group: 'organization', key: 'name' });
|
||||
const baseCurrency = settings.get({ group: 'organization', key: 'base_currency' });
|
||||
const organizationName = settings.get({
|
||||
group: 'organization',
|
||||
key: 'name',
|
||||
});
|
||||
const baseCurrency = settings.get({
|
||||
group: 'organization',
|
||||
key: 'base_currency',
|
||||
});
|
||||
|
||||
try {
|
||||
const {
|
||||
data,
|
||||
query,
|
||||
} = await this.generalLedgetService.generalLedger(tenantId, filter);
|
||||
|
||||
const { data, query } = await this.generalLedgetService.generalLedger(
|
||||
tenantId,
|
||||
filter
|
||||
);
|
||||
return res.status(200).send({
|
||||
organization_name: organizationName,
|
||||
base_currency: baseCurrency,
|
||||
@@ -71,4 +76,4 @@ export default class GeneralLedgerReportController extends BaseController{
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user