feat: hook up branding templates to invoices

This commit is contained in:
Ahmed Bouhuolia
2024-09-16 20:02:02 +02:00
parent 94c08f0b9e
commit 4f59b27d70
23 changed files with 1141 additions and 154 deletions

View File

@@ -33,6 +33,14 @@ export class AssignPdfTemplateDefault {
return this.uow.withTransaction(
tenantId,
async (trx?: Knex.Transaction) => {
// Triggers `onPdfTemplateAssigningDefault` event.
await this.eventPublisher.emitAsync(
events.pdfTemplate.onAssigningDefault,
{
tenantId,
templateId,
}
);
await PdfTemplate.query(trx)
.where('resource', oldPdfTempalte.resource)
.patch({ default: false });
@@ -41,6 +49,7 @@ export class AssignPdfTemplateDefault {
.findById(templateId)
.patch({ default: true });
// Triggers `onPdfTemplateAssignedDefault` event.
await this.eventPublisher.emitAsync(
events.pdfTemplate.onAssignedDefault,
{