mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +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:
@@ -1,17 +1,15 @@
|
||||
/* eslint-disable global-require */
|
||||
import { Model, mixin } from 'objection';
|
||||
import { Model } from 'objection';
|
||||
import { flatten } from 'lodash';
|
||||
import TenantModel from '@/models/TenantModel';
|
||||
import {
|
||||
buildFilterQuery,
|
||||
buildSortColumnQuery,
|
||||
} from '@/lib/ViewRolesBuilder';
|
||||
import CachableQueryBuilder from '@/lib/Cachable/CachableQueryBuilder';
|
||||
import CachableModel from '@/lib/Cachable/CachableModel';
|
||||
import { flatToNestedArray } from '@/utils';
|
||||
import DependencyGraph from '@/lib/DependencyGraph';
|
||||
|
||||
export default class Account extends mixin(TenantModel, [CachableModel]) {
|
||||
export default class Account extends TenantModel {
|
||||
/**
|
||||
* Table name
|
||||
*/
|
||||
@@ -26,36 +24,6 @@ export default class Account extends mixin(TenantModel, [CachableModel]) {
|
||||
return ['createdAt', 'updatedAt'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend query builder model.
|
||||
*/
|
||||
static get QueryBuilder() {
|
||||
return CachableQueryBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query return override.
|
||||
* @param {...any} args
|
||||
*/
|
||||
static query(...args) {
|
||||
return super.query(...args).runAfter((result) => {
|
||||
if (Array.isArray(result)) {
|
||||
return this.isDepGraph ?
|
||||
Account.toDependencyGraph(result) :
|
||||
this.collection.from(result);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the array result to dependency graph.
|
||||
*/
|
||||
static depGraph() {
|
||||
this.isDepGraph = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model modifiers.
|
||||
*/
|
||||
@@ -87,7 +55,6 @@ export default class Account extends mixin(TenantModel, [CachableModel]) {
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const AccountType = require('@/models/AccountType');
|
||||
const AccountBalance = require('@/models/AccountBalance');
|
||||
const AccountTransaction = require('@/models/AccountTransaction');
|
||||
|
||||
return {
|
||||
@@ -103,18 +70,6 @@ export default class Account extends mixin(TenantModel, [CachableModel]) {
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Account model may has many balances accounts.
|
||||
*/
|
||||
balance: {
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: this.relationBindKnex(AccountBalance.default),
|
||||
join: {
|
||||
from: 'accounts.id',
|
||||
to: 'account_balances.accountId',
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Account model may has many transactions.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user