mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
refactor: tenant proxy providers
This commit is contained in:
@@ -9,6 +9,7 @@ import { UnitOfWork } from '@/modules/Tenancy/TenancyDB/UnitOfWork.service';
|
||||
import { TaxRateModel } from '../models/TaxRate.model';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { events } from '@/common/events/events';
|
||||
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||
|
||||
@Injectable()
|
||||
export class InactivateTaxRateService {
|
||||
@@ -24,7 +25,7 @@ export class InactivateTaxRateService {
|
||||
private readonly validators: CommandTaxRatesValidators,
|
||||
|
||||
@Inject(TaxRateModel.name)
|
||||
private readonly taxRateModel: typeof TaxRateModel,
|
||||
private readonly taxRateModel: TenantModelProxy<typeof TaxRateModel>,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -33,7 +34,7 @@ export class InactivateTaxRateService {
|
||||
* @returns {Promise<ITaxRate>}
|
||||
*/
|
||||
public async inactivateTaxRate(taxRateId: number) {
|
||||
const oldTaxRate = await this.taxRateModel.query().findById(taxRateId);
|
||||
const oldTaxRate = await this.taxRateModel().query().findById(taxRateId);
|
||||
|
||||
// Validates the tax rate existance.
|
||||
this.validators.validateTaxRateExistance(oldTaxRate);
|
||||
@@ -48,7 +49,7 @@ export class InactivateTaxRateService {
|
||||
trx,
|
||||
} as ITaxRateActivatingPayload);
|
||||
|
||||
const taxRate = await this.taxRateModel
|
||||
const taxRate = await this.taxRateModel()
|
||||
.query(trx)
|
||||
.findById(taxRateId)
|
||||
.patch({ active: false });
|
||||
|
||||
Reference in New Issue
Block a user