mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
refactor: dynamic list to nestjs
This commit is contained in:
@@ -7,6 +7,7 @@ import { ActivateTaxRateService } from './commands/ActivateTaxRate.service';
|
||||
import { InactivateTaxRateService } from './commands/InactivateTaxRate';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ICreateTaxRateDTO, IEditTaxRateDTO } from './TaxRates.types';
|
||||
import { GetTaxRatesService } from './queries/GetTaxRates.service';
|
||||
|
||||
@Injectable()
|
||||
export class TaxRatesApplication {
|
||||
@@ -17,7 +18,7 @@ export class TaxRatesApplication {
|
||||
private readonly getTaxRateService: GetTaxRateService,
|
||||
private readonly activateTaxRateService: ActivateTaxRateService,
|
||||
private readonly inactivateTaxRateService: InactivateTaxRateService,
|
||||
// private readonly getTaxRatesService: GetTaxRatesService,
|
||||
private readonly getTaxRatesService: GetTaxRatesService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -56,17 +57,16 @@ export class TaxRatesApplication {
|
||||
* @param {number} taxRateId
|
||||
* @returns {Promise<ITaxRate>}
|
||||
*/
|
||||
public getTaxRate(tenantId: number, taxRateId: number) {
|
||||
public getTaxRate(taxRateId: number) {
|
||||
return this.getTaxRateService.getTaxRate(taxRateId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the tax rates list.
|
||||
* @param {number} tenantId
|
||||
* @returns {Promise<ITaxRate[]>}
|
||||
*/
|
||||
public getTaxRates(tenantId: number) {
|
||||
// return this.getTaxRatesService.getTaxRates(tenantId);
|
||||
public getTaxRates() {
|
||||
return this.getTaxRatesService.getTaxRates();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,16 +35,13 @@ export class TaxRatesController {
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
public getTaxRate(
|
||||
@Param('tenantId') tenantId: number,
|
||||
@Param('id') taxRateId: number,
|
||||
) {
|
||||
return this.taxRatesApplication.getTaxRate(tenantId, taxRateId);
|
||||
public getTaxRate(@Param('id') taxRateId: number) {
|
||||
return this.taxRatesApplication.getTaxRate(taxRateId);
|
||||
}
|
||||
|
||||
@Get()
|
||||
public getTaxRates(@Param('tenantId') tenantId: number) {
|
||||
return this.taxRatesApplication.getTaxRates(tenantId);
|
||||
public getTaxRates() {
|
||||
return this.taxRatesApplication.getTaxRates();
|
||||
}
|
||||
|
||||
@Put(':id/activate')
|
||||
|
||||
@@ -1,32 +1,24 @@
|
||||
// import { Inject, Service } from 'typedi';
|
||||
// import HasTenancyService from '../Tenancy/TenancyService';
|
||||
// import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
||||
// import { TaxRateTransformer } from './TaxRate.transformer';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { TaxRateTransformer } from './TaxRate.transformer';
|
||||
import { TransformerInjectable } from '@/modules/Transformer/TransformerInjectable.service';
|
||||
import { TaxRateModel } from '../models/TaxRate.model';
|
||||
|
||||
// @Service()
|
||||
// export class GetTaxRatesService {
|
||||
// @Inject()
|
||||
// private tenancy: HasTenancyService;
|
||||
@Injectable()
|
||||
export class GetTaxRatesService {
|
||||
constructor(
|
||||
private transformer: TransformerInjectable,
|
||||
@Inject(TaxRateModel.name) private taxRateModel: typeof TaxRateModel,
|
||||
) {}
|
||||
|
||||
// @Inject()
|
||||
// private transformer: TransformerInjectable;
|
||||
/**
|
||||
* Retrieves the tax rates list.
|
||||
* @returns {Promise<ITaxRate[]>}
|
||||
*/
|
||||
public async getTaxRates() {
|
||||
// Retrieves the tax rates.
|
||||
const taxRates = await this.taxRateModel.query().orderBy('name', 'ASC');
|
||||
|
||||
// /**
|
||||
// * Retrieves the tax rates list.
|
||||
// * @param {number} tenantId
|
||||
// * @returns {Promise<ITaxRate[]>}
|
||||
// */
|
||||
// public async getTaxRates(tenantId: number) {
|
||||
// const { TaxRate } = this.tenancy.models(tenantId);
|
||||
|
||||
// // Retrieves the tax rates.
|
||||
// const taxRates = await TaxRate.query().orderBy('name', 'ASC');
|
||||
|
||||
// // Transforms the tax rates.
|
||||
// return this.transformer.transform(
|
||||
// tenantId,
|
||||
// taxRates,
|
||||
// new TaxRateTransformer()
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// Transforms the tax rates.
|
||||
return this.transformer.transform(taxRates, new TaxRateTransformer());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user