Files
bigcapital/packages/server/src/modules/TaxRates/TaxRate.application.ts
Ahmed Bouhuolia e0d9a56a29 fix: tax rates API and UI improvements
- Add @ToNumber() decorator to rate field for proper validation
- Fix getTaxRates to return { data: taxRates } response
- Fix useTaxRate URL typo and response handling
- Fix activate/inactivate endpoint methods and paths
- Apply TEXT_MUTED class to description and compound tax
- Add dark mode support for rate number display
2026-02-12 20:06:49 +02:00

90 lines
2.8 KiB
TypeScript

import { CreateTaxRate } from './commands/CreateTaxRate.service';
import { DeleteTaxRateService } from './commands/DeleteTaxRate.service';
import { EditTaxRateService } from './commands/EditTaxRate.service';
import { GetTaxRateService } from './queries/GetTaxRate.service';
import { ActivateTaxRateService } from './commands/ActivateTaxRate.service';
import { InactivateTaxRateService } from './commands/InactivateTaxRate';
import { Injectable } from '@nestjs/common';
import { GetTaxRatesService } from './queries/GetTaxRates.service';
import { CreateTaxRateDto, EditTaxRateDto } from './dtos/TaxRate.dto';
@Injectable()
export class TaxRatesApplication {
constructor(
private readonly createTaxRateService: CreateTaxRate,
private readonly editTaxRateService: EditTaxRateService,
private readonly deleteTaxRateService: DeleteTaxRateService,
private readonly getTaxRateService: GetTaxRateService,
private readonly activateTaxRateService: ActivateTaxRateService,
private readonly inactivateTaxRateService: InactivateTaxRateService,
private readonly getTaxRatesService: GetTaxRatesService,
) {}
/**
* Creates a new tax rate.
* @param {ICreateTaxRateDTO} createTaxRateDTO
* @returns {Promise<ITaxRate>}
*/
public createTaxRate(createTaxRateDTO: CreateTaxRateDto) {
return this.createTaxRateService.createTaxRate(createTaxRateDTO);
}
/**
* Edits the given tax rate.
* @param {number} tenantId
* @param {number} taxRateId
* @param {IEditTaxRateDTO} taxRateEditDTO
* @returns {Promise<ITaxRate>}
*/
public editTaxRate(taxRateId: number, editTaxRateDTO: EditTaxRateDto) {
return this.editTaxRateService.editTaxRate(taxRateId, editTaxRateDTO);
}
/**
* Deletes the given tax rate.
* @param {number} tenantId
* @param {number} taxRateId
* @returns {Promise<void>}
*/
public deleteTaxRate(taxRateId: number) {
return this.deleteTaxRateService.deleteTaxRate(taxRateId);
}
/**
* Retrieves the given tax rate.
* @param {number} tenantId
* @param {number} taxRateId
* @returns {Promise<ITaxRate>}
*/
public getTaxRate(taxRateId: number) {
return this.getTaxRateService.getTaxRate(taxRateId);
}
/**
* Retrieves the tax rates list.
* @returns {Promise<{ data: ITaxRate[] }>}
*/
public async getTaxRates() {
const taxRates = await this.getTaxRatesService.getTaxRates();
return { data: taxRates };
}
/**
* Activates the given tax rate.
* @param {number} tenantId
* @param {number} taxRateId
*/
public activateTaxRate(taxRateId: number) {
return this.activateTaxRateService.activateTaxRate(taxRateId);
}
/**
* Inactivates the given tax rate.
* @param {number} tenantId
* @param {number} taxRateId
*/
public inactivateTaxRate(taxRateId: number) {
return this.inactivateTaxRateService.inactivateTaxRate(taxRateId);
}
}