feat: remove path alias.

feat: remove Webpack and depend on nodemon.
feat: refactoring expenses.
feat: optimize system users with caching.
feat: architecture tenant optimize.
This commit is contained in:
Ahmed Bouhuolia
2020-09-15 00:51:39 +02:00
parent ad00f140d1
commit a22c8395f3
293 changed files with 3391 additions and 1637 deletions

View File

@@ -1,8 +1,8 @@
import { sumBy, chain } from 'lodash';
import JournalPoster from "./JournalPoster";
import JournalEntry from "./JournalEntry";
import { AccountTransaction } from '@/models';
import { IInventoryTransaction } from '@/interfaces';
import { AccountTransaction } from 'models';
import { IInventoryTransaction } from 'interfaces';
import AccountsService from '../Accounts/AccountsService';
import { IInventoryTransaction, IInventoryTransaction } from '../../interfaces';
@@ -120,6 +120,21 @@ export default class JournalCommands{
this.journal.credit(creditEntry);
}
async revertJournalEntries(
referenceId: number|number[],
referenceType: string
) {
const { AccountTransaction } = this.models;
const transactions = await AccountTransaction.query()
.where('reference_type', referenceType)
.whereIn('reference_id', Array.isArray(referenceId) ? referenceId : [referenceId])
.withGraphFetched('account.type');
this.journal.loadEntries(transactions);
this.journal.removeEntries();
}
/**
* Removes and revert accounts balance journal entries that associated
* to the given inventory transactions.