mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
fix: expense writing journal entries.
fix: delete expense from the storage.
This commit is contained in:
@@ -138,16 +138,18 @@ export default class JournalCommands{
|
||||
const paymentJournalEntry = new JournalEntry({
|
||||
credit: expense.totalAmount,
|
||||
account: expense.paymentAccountId,
|
||||
index: 1,
|
||||
...mixinEntry,
|
||||
});
|
||||
this.journal.credit(paymentJournalEntry);
|
||||
|
||||
expense.categories.forEach((category: IExpenseCategory) => {
|
||||
expense.categories.forEach((category: IExpenseCategory, index) => {
|
||||
const expenseJournalEntry = new JournalEntry({
|
||||
account: category.expenseAccountId,
|
||||
debit: category.amount,
|
||||
note: category.description,
|
||||
...mixinEntry,
|
||||
index: index + 2,
|
||||
});
|
||||
this.journal.debit(expenseJournalEntry);
|
||||
});
|
||||
|
||||
@@ -143,16 +143,15 @@ export default class ExpensesService implements IExpensesService {
|
||||
}
|
||||
}
|
||||
|
||||
private async revertJournalEntries(
|
||||
public async revertJournalEntries(
|
||||
tenantId: number,
|
||||
expenseId: number|number[],
|
||||
) {
|
||||
const journal = new JournalPoster(tenantId);
|
||||
const journalCommands = new JournalCommands(journal);
|
||||
|
||||
if (revertOld) {
|
||||
await journalCommands.revertJournalEntries(expenseId, 'Expense');
|
||||
}
|
||||
|
||||
await journalCommands.revertJournalEntries(expenseId, 'Expense');
|
||||
|
||||
return Promise.all([
|
||||
journal.saveBalance(),
|
||||
journal.deleteEntries(),
|
||||
|
||||
@@ -14,7 +14,7 @@ export default class JournalPosterService {
|
||||
* @param {string} referenceType - The transaction reference type.
|
||||
* @return {Promise}
|
||||
*/
|
||||
async deleteJournalTransactions(
|
||||
async revertJournalTransactions(
|
||||
tenantId: number,
|
||||
referenceId: number,
|
||||
referenceType: string
|
||||
|
||||
Reference in New Issue
Block a user