refactor: tenant proxy providers

This commit is contained in:
Ahmed Bouhuolia
2025-02-15 23:52:12 +02:00
parent 36851d3209
commit 5c0bb52b59
302 changed files with 2396 additions and 1677 deletions

View File

@@ -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 });