mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat: track more services events
This commit is contained in:
@@ -3,6 +3,8 @@ import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
||||
import { SaleEstimateTransfromer } from './SaleEstimateTransformer';
|
||||
import { SaleEstimateValidators } from './SaleEstimateValidators';
|
||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@Service()
|
||||
export class GetSaleEstimate {
|
||||
@@ -15,6 +17,9 @@ export class GetSaleEstimate {
|
||||
@Inject()
|
||||
private validators: SaleEstimateValidators;
|
||||
|
||||
@Inject()
|
||||
private eventPublisher: EventPublisher;
|
||||
|
||||
/**
|
||||
* Retrieve the estimate details with associated entries.
|
||||
* @async
|
||||
@@ -35,10 +40,18 @@ export class GetSaleEstimate {
|
||||
this.validators.validateEstimateExistance(estimate);
|
||||
|
||||
// Transformes sale estimate model to POJO.
|
||||
return this.transformer.transform(
|
||||
const transformed = await this.transformer.transform(
|
||||
tenantId,
|
||||
estimate,
|
||||
new SaleEstimateTransfromer()
|
||||
);
|
||||
const eventPayload = { tenantId, saleEstimateId: estimateId };
|
||||
|
||||
// Triggers `onSaleEstimateViewed` event.
|
||||
await this.eventPublisher.emitAsync(
|
||||
events.saleEstimate.onViewed,
|
||||
eventPayload
|
||||
);
|
||||
return transformed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user