Skip to content

Commit

Permalink
fix(server): the expense transaction journal entries
Browse files Browse the repository at this point in the history
  • Loading branch information
abouolia committed Jun 14, 2023
1 parent 6562e3a commit 0d8fb8c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions packages/server/src/services/Expenses/CRUD/DeleteExpense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import events from '@/subscribers/events';
import UnitOfWork from '@/services/UnitOfWork';
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
import { CommandExpenseValidator } from './CommandExpenseValidator';
import { ExpenseCategory } from 'models';
import HasTenancyService from '@/services/Tenancy/TenancyService';

@Service()
Expand Down Expand Up @@ -37,7 +36,7 @@ export class DeleteExpense {
expenseId: number,
authorizedUser: ISystemUser
): Promise<void> => {
const { Expense } = this.tenancy.models(tenantId);
const { Expense, ExpenseCategory } = this.tenancy.models(tenantId);

// Retrieves the expense transaction with associated entries or
// throw not found error.
Expand All @@ -60,7 +59,7 @@ export class DeleteExpense {
} as IExpenseDeletingPayload);

// Deletes expense associated entries.
await ExpenseCategory.query(trx).findById(expenseId).delete();
await ExpenseCategory.query(trx).where('expenseId', expenseId).delete();

// Deletes expense transactions.
await Expense.query(trx).findById(expenseId).delete();
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/services/Expenses/ExpenseGLEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class ExpenseGLEntries {
...commonEntry,
credit: expense.localAmount,
accountId: expense.paymentAccountId,
accountNormal: AccountNormal.CREDIT,
accountNormal: AccountNormal.DEBIT,
index: 1,
};
};
Expand Down

0 comments on commit 0d8fb8c

Please sign in to comment.