mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
refactoring: retrieve resources fields.
fix: issue in create a new custom view.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { omit } from 'lodash';
|
||||
import TenancyService from 'services/Tenancy/TenancyService';
|
||||
import { IAccountsTypesService, IAccountType } from 'interfaces';
|
||||
|
||||
@@ -12,8 +13,17 @@ export default class AccountsTypesService implements IAccountsTypesService{
|
||||
* @param {number} tenantId -
|
||||
* @return {Promise<IAccountType>}
|
||||
*/
|
||||
getAccountsTypes(tenantId: number): Promise<IAccountType> {
|
||||
async getAccountsTypes(tenantId: number): Promise<IAccountType> {
|
||||
const { accountTypeRepository } = this.tenancy.repositories(tenantId);
|
||||
return accountTypeRepository.all();
|
||||
const { AccountType } = this.tenancy.models(tenantId);
|
||||
const { __ } = this.tenancy.i18n(tenantId);
|
||||
|
||||
const allAccountsTypes = await accountTypeRepository.all();
|
||||
|
||||
return allAccountsTypes.map((_accountType: IAccountType) => ({
|
||||
id: _accountType.id,
|
||||
label: __(AccountType.labels[_accountType.key]),
|
||||
...omit(_accountType, ['id']),
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user