chore: clean pdf templates code

This commit is contained in:
Ahmed Bouhuolia
2024-09-15 22:55:39 +02:00
parent ef4beaa564
commit 94c08f0b9e
7 changed files with 106 additions and 38 deletions

View File

@@ -1,7 +1,7 @@
import { Service, Inject } from 'typedi';
import { Knex } from 'knex';
import HasTenancyService from '../Tenancy/TenancyService';
import UnitOfWork from '../UnitOfWork';
import { Knex } from 'knex';
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
import events from '@/subscribers/events';
@@ -16,6 +16,13 @@ export class AssignPdfTemplateDefault {
@Inject()
private eventPublisher: EventPublisher;
/**
* Assigns a default PDF template for a specific tenant.
* @param {number} tenantId - The ID of the tenant for whom the default template is being assigned.
* @param {number} templateId - The ID of the template to be set as the default.
* @returns {Promise<void>} A promise that resolves when the operation is complete.
* @throws {Error} Throws ddan error if the specified template is not found.
*/
public async assignDefaultTemplate(tenantId: number, templateId: number) {
const { PdfTemplate } = this.tenancy.models(tenantId);