mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
fix(server): the expense transaction journal entries
This commit is contained in:
@@ -9,7 +9,6 @@ import events from '@/subscribers/events';
|
|||||||
import UnitOfWork from '@/services/UnitOfWork';
|
import UnitOfWork from '@/services/UnitOfWork';
|
||||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||||
import { CommandExpenseValidator } from './CommandExpenseValidator';
|
import { CommandExpenseValidator } from './CommandExpenseValidator';
|
||||||
import { ExpenseCategory } from 'models';
|
|
||||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
@@ -37,7 +36,7 @@ export class DeleteExpense {
|
|||||||
expenseId: number,
|
expenseId: number,
|
||||||
authorizedUser: ISystemUser
|
authorizedUser: ISystemUser
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
const { Expense } = this.tenancy.models(tenantId);
|
const { Expense, ExpenseCategory } = this.tenancy.models(tenantId);
|
||||||
|
|
||||||
// Retrieves the expense transaction with associated entries or
|
// Retrieves the expense transaction with associated entries or
|
||||||
// throw not found error.
|
// throw not found error.
|
||||||
@@ -60,7 +59,7 @@ export class DeleteExpense {
|
|||||||
} as IExpenseDeletingPayload);
|
} as IExpenseDeletingPayload);
|
||||||
|
|
||||||
// Deletes expense associated entries.
|
// Deletes expense associated entries.
|
||||||
await ExpenseCategory.query(trx).findById(expenseId).delete();
|
await ExpenseCategory.query(trx).where('expenseId', expenseId).delete();
|
||||||
|
|
||||||
// Deletes expense transactions.
|
// Deletes expense transactions.
|
||||||
await Expense.query(trx).findById(expenseId).delete();
|
await Expense.query(trx).findById(expenseId).delete();
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export class ExpenseGLEntries {
|
|||||||
...commonEntry,
|
...commonEntry,
|
||||||
credit: expense.localAmount,
|
credit: expense.localAmount,
|
||||||
accountId: expense.paymentAccountId,
|
accountId: expense.paymentAccountId,
|
||||||
accountNormal: AccountNormal.CREDIT,
|
accountNormal: AccountNormal.DEBIT,
|
||||||
index: 1,
|
index: 1,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user