fix financial statements.

This commit is contained in:
Ahmed Bouhuolia
2020-05-25 09:07:07 +02:00
parent ab21f439e2
commit 5369b3661a
10 changed files with 63 additions and 100 deletions

View File

@@ -270,7 +270,7 @@ export default {
user_id: user.id,
});
const accountsDepGraph = await Account.depGraph().query().remember();
const accountsDepGraph = await Account.depGraph().query();
const journalPoster = new JournalPoster(accountsDepGraph);
entries.forEach((entry) => {

View File

@@ -27,6 +27,10 @@ export default class Account extends mixin(TenantModel, [CachableModel, DateSess
return CachableQueryBuilder;
}
/**
* Query return override.
* @param {...any} args
*/
static query(...args) {
return super.query(...args).runAfter((result) => {
if (Array.isArray(result)) {

View File

@@ -7,7 +7,7 @@ import {
tenantFactory,
tenantWebsite
} from '~/dbInit';
import DependencyGraph from '@/lib/DependencyGraph';
describe('Model: Account', () => {
it('Should account model belongs to the associated account type model.', async () => {
@@ -42,4 +42,9 @@ describe('Model: Account', () => {
expect(transactionsModels.length).equals(1);
});
it('Should retrieve dependency graph.', async () => {
const accountsDepGraph = await Account.tenant().depGraph().query();
expect(accountsDepGraph).to.be.an.instanceOf(DependencyGraph);
});
});

View File

@@ -10,7 +10,7 @@ import {
} from '~/dbInit';
describe.only('routes: `/items`', () => {
describe('routes: `/items`', () => {
describe('POST: `/items`', () => {
it('Should not create a new item if the user was not authorized.', async () => {
const res = await request()