mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat: licenses administration basic authentication.
feat: accounts slug. feat: duplicate accounts_balance table and merge balance with accounts table. feat: refactoring customers and vendors. feat: system user soft deleting. feat: preventing build tenant database without any subscription. feat: remove 'password' property from 'req.user' object. feat: refactoring JournalPoster class. feat: delete duplicated directories and files.
This commit is contained in:
55
server/src/repositories/AccountRepository.ts
Normal file
55
server/src/repositories/AccountRepository.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import TenantRepository from '@/repositories/TenantRepository';
|
||||
|
||||
export default class AccountRepository extends TenantRepository {
|
||||
models: any;
|
||||
repositories: any;
|
||||
cache: any;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
* @param {number} tenantId - The given tenant id.
|
||||
*/
|
||||
constructor(
|
||||
tenantId: number,
|
||||
) {
|
||||
super(tenantId);
|
||||
|
||||
this.models = this.tenancy.models(tenantId);
|
||||
this.cache = this.tenancy.cache(tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve accounts dependency graph.
|
||||
* @returns {}
|
||||
*/
|
||||
async getDependencyGraph() {
|
||||
const { Account } = this.models;
|
||||
const accounts = await this.allAccounts();
|
||||
|
||||
return this.cache.get('accounts.depGraph', async () => {
|
||||
return Account.toDependencyGraph(accounts);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all accounts on the storage.
|
||||
* @return {}
|
||||
*/
|
||||
async allAccounts() {
|
||||
const { Account } = this.models;
|
||||
return this.cache.get('accounts', async () => {
|
||||
return Account.query();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve account of the given account slug.
|
||||
* @param {string} slug
|
||||
*/
|
||||
async getBySlug(slug: string) {
|
||||
const { Account } = this.models;
|
||||
return this.cache.get(`accounts.slug.${slug}`, () => {
|
||||
return Account.query().findOne('slug', slug);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user