mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
refactor: sale estimates to nestjs
This commit is contained in:
@@ -1,72 +1,67 @@
|
||||
import { Knex } from 'knex';
|
||||
import { Service, Inject } from 'typedi';
|
||||
import LedgerStorageService from '@/services/Accounting/LedgerStorageService';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
import { ExpenseGLEntries } from './ExpenseGLEntriesService';
|
||||
// import { Knex } from 'knex';
|
||||
// import { ExpenseGLEntries } from './ExpenseGLEntries.service';
|
||||
// import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Service()
|
||||
export class ExpenseGLEntriesStorage {
|
||||
@Inject()
|
||||
private expenseGLEntries: ExpenseGLEntries;
|
||||
// @Injectable()
|
||||
// export class ExpenseGLEntriesStorage {
|
||||
// /**
|
||||
// * @param {ExpenseGLEntries} expenseGLEntries
|
||||
// * @param {LedgerStorageService} ledgerStorage
|
||||
// */
|
||||
// constructor(
|
||||
// private readonly expenseGLEntries: ExpenseGLEntries,
|
||||
// private readonly ledgerStorage: LedgerStorageService,
|
||||
// ) {}
|
||||
|
||||
@Inject()
|
||||
private ledgerStorage: LedgerStorageService;
|
||||
// /**
|
||||
// * Writes the expense GL entries.
|
||||
// * @param {number} tenantId
|
||||
// * @param {number} expenseId
|
||||
// * @param {Knex.Transaction} trx
|
||||
// */
|
||||
// public writeExpenseGLEntries = async (
|
||||
// expenseId: number,
|
||||
// trx?: Knex.Transaction,
|
||||
// ) => {
|
||||
// // Retrieves the given expense ledger.
|
||||
// const expenseLedger = await this.expenseGLEntries.getExpenseLedgerById(
|
||||
// expenseId,
|
||||
// trx,
|
||||
// );
|
||||
// // Commits the expense ledger entries.
|
||||
// await this.ledgerStorage.commit(expenseLedger, trx);
|
||||
// };
|
||||
|
||||
/**
|
||||
* Writes the expense GL entries.
|
||||
* @param {number} tenantId
|
||||
* @param {number} expenseId
|
||||
* @param {Knex.Transaction} trx
|
||||
*/
|
||||
public writeExpenseGLEntries = async (
|
||||
tenantId: number,
|
||||
expenseId: number,
|
||||
trx?: Knex.Transaction
|
||||
) => {
|
||||
// Retrieves the given expense ledger.
|
||||
const expenseLedger = await this.expenseGLEntries.getExpenseLedgerById(
|
||||
tenantId,
|
||||
expenseId,
|
||||
trx
|
||||
);
|
||||
// Commits the expense ledger entries.
|
||||
await this.ledgerStorage.commit(tenantId, expenseLedger, trx);
|
||||
};
|
||||
// /**
|
||||
// * Reverts the given expense GL entries.
|
||||
// * @param {number} tenantId
|
||||
// * @param {number} expenseId
|
||||
// * @param {Knex.Transaction} trx
|
||||
// */
|
||||
// public revertExpenseGLEntries = async (
|
||||
// expenseId: number,
|
||||
// trx?: Knex.Transaction,
|
||||
// ) => {
|
||||
// await this.ledgerStorage.deleteByReference(
|
||||
// expenseId,
|
||||
// 'Expense',
|
||||
// trx,
|
||||
// );
|
||||
// };
|
||||
|
||||
/**
|
||||
* Reverts the given expense GL entries.
|
||||
* @param {number} tenantId
|
||||
* @param {number} expenseId
|
||||
* @param {Knex.Transaction} trx
|
||||
*/
|
||||
public revertExpenseGLEntries = async (
|
||||
tenantId: number,
|
||||
expenseId: number,
|
||||
trx?: Knex.Transaction
|
||||
) => {
|
||||
await this.ledgerStorage.deleteByReference(
|
||||
tenantId,
|
||||
expenseId,
|
||||
'Expense',
|
||||
trx
|
||||
);
|
||||
};
|
||||
// /**
|
||||
// * Rewrites the expense GL entries.
|
||||
// * @param {number} expenseId
|
||||
// * @param {Knex.Transaction} trx
|
||||
// */
|
||||
// public rewriteExpenseGLEntries = async (
|
||||
// expenseId: number,
|
||||
// trx?: Knex.Transaction,
|
||||
// ) => {
|
||||
// // Reverts the expense GL entries.
|
||||
// await this.revertExpenseGLEntries(expenseId, trx);
|
||||
|
||||
/**
|
||||
* Rewrites the expense GL entries.
|
||||
* @param {number} tenantId
|
||||
* @param {number} expenseId
|
||||
* @param {Knex.Transaction} trx
|
||||
*/
|
||||
public rewriteExpenseGLEntries = async (
|
||||
tenantId: number,
|
||||
expenseId: number,
|
||||
trx?: Knex.Transaction
|
||||
) => {
|
||||
// Reverts the expense GL entries.
|
||||
await this.revertExpenseGLEntries(tenantId, expenseId, trx);
|
||||
|
||||
// Writes the expense GL entries.
|
||||
await this.writeExpenseGLEntries(tenantId, expenseId, trx);
|
||||
};
|
||||
}
|
||||
// // Writes the expense GL entries.
|
||||
// await this.writeExpenseGLEntries(expenseId, trx);
|
||||
// };
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user