mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
fix(server): Validation of activate/inacitvate tax rates
This commit is contained in:
@@ -17,6 +17,7 @@ export interface SalesTaxLiabilitySummaryTotal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface SalesTaxLiabilitySummaryRate {
|
export interface SalesTaxLiabilitySummaryRate {
|
||||||
|
id: number;
|
||||||
taxName: string;
|
taxName: string;
|
||||||
taxableAmount: SalesTaxLiabilitySummaryAmount;
|
taxableAmount: SalesTaxLiabilitySummaryAmount;
|
||||||
taxAmount: SalesTaxLiabilitySummaryAmount;
|
taxAmount: SalesTaxLiabilitySummaryAmount;
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ export class ActivateTaxRateService {
|
|||||||
// Validates the tax rate existance.
|
// Validates the tax rate existance.
|
||||||
this.validators.validateTaxRateExistance(oldTaxRate);
|
this.validators.validateTaxRateExistance(oldTaxRate);
|
||||||
|
|
||||||
|
// Validates the tax rate inactive.
|
||||||
|
this.validators.validateTaxRateNotActive(oldTaxRate);
|
||||||
|
|
||||||
return this.uow.withTransaction(tenantId, async (trx: Knex.Transaction) => {
|
return this.uow.withTransaction(tenantId, async (trx: Knex.Transaction) => {
|
||||||
// Triggers `onTaxRateActivating` event.
|
// Triggers `onTaxRateActivating` event.
|
||||||
await this.eventPublisher.emitAsync(events.taxRates.onActivating, {
|
await this.eventPublisher.emitAsync(events.taxRates.onActivating, {
|
||||||
|
|||||||
@@ -31,15 +31,15 @@ export class InactivateTaxRateService {
|
|||||||
* @param {IEditTaxRateDTO} taxRateEditDTO
|
* @param {IEditTaxRateDTO} taxRateEditDTO
|
||||||
* @returns {Promise<ITaxRate>}
|
* @returns {Promise<ITaxRate>}
|
||||||
*/
|
*/
|
||||||
public inactivateTaxRate(tenantId: number, taxRateId: number) {
|
public async inactivateTaxRate(tenantId: number, taxRateId: number) {
|
||||||
const { TaxRate } = this.tenancy.models(tenantId);
|
const { TaxRate } = this.tenancy.models(tenantId);
|
||||||
|
|
||||||
const oldTaxRate = TaxRate.query().findById(taxRateId);
|
const oldTaxRate = await TaxRate.query().findById(taxRateId);
|
||||||
|
|
||||||
// Validates the tax rate existance.
|
// Validates the tax rate existance.
|
||||||
this.validators.validateTaxRateExistance(oldTaxRate);
|
this.validators.validateTaxRateExistance(oldTaxRate);
|
||||||
|
|
||||||
//
|
// Validates the tax rate active.
|
||||||
this.validators.validateTaxRateNotInactive(oldTaxRate);
|
this.validators.validateTaxRateNotInactive(oldTaxRate);
|
||||||
|
|
||||||
return this.uow.withTransaction(tenantId, async (trx: Knex.Transaction) => {
|
return this.uow.withTransaction(tenantId, async (trx: Knex.Transaction) => {
|
||||||
|
|||||||
@@ -24,6 +24,6 @@ export class TaxRateTransformer extends Transformer {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
protected nameFormatted = (taxRate): string => {
|
protected nameFormatted = (taxRate): string => {
|
||||||
return `${taxRate.name} (${taxRate.rate}%)`;
|
return `${taxRate.name} [${taxRate.rate}%]`;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user