feat: tax rate transformer

This commit is contained in:
Ahmed Bouhuolia
2023-09-11 20:46:46 +02:00
parent 7657337c4f
commit 6abae43c6f
8 changed files with 101 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
import { Inject, Service } from 'typedi';
import HasTenancyService from '../Tenancy/TenancyService';
import { CommandTaxRatesValidators } from './CommandTaxRatesValidators';
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
import { TaxRateTransformer } from './TaxRateTransformer';
@Service()
export class GetTaxRateService {
@@ -10,6 +12,9 @@ export class GetTaxRateService {
@Inject()
private validators: CommandTaxRatesValidators;
@Inject()
private transformer: TransformerInjectable;
/**
* Retrieves the given tax rate.
* @param {number} tenantId
@@ -24,6 +29,11 @@ export class GetTaxRateService {
// Validates the tax rate existance.
this.validators.validateTaxRateExistance(taxRate);
return taxRate;
// Transforms the tax rate.
return this.transformer.transform(
tenantId,
taxRate,
new TaxRateTransformer()
);
}
}