import { Injectable } from '@nestjs/common'; import { BaseCustomManager } from 'src/core/modules/domain/usecase/managers/base-custom.manager'; import { TransactionEntity } from 'src/modules/transaction/transaction/domain/entities/transaction.entity'; import { EventTopics } from 'src/core/strings/constants/interface.constants'; import { STATUS } from 'src/core/strings/constants/base.constants'; import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model'; import { GeneratePdf } from '../templates/helpers/generate-pdf.helper'; @Injectable() export class PdfMakeManager extends BaseCustomManager { get entityTarget(): any { return TransactionModel; } get eventTopics(): EventTopics[] { return []; } async validateProcess(): Promise { return; } async beforeProcess(): Promise { return; } async process(): Promise { try { const transaction = await this.dataService.getOneByOptions({ where: { id: this.data.id, }, relations: ['items'], }); const banks = await this.dataServiceFirstOpt.getManyByOptions({ where: { status: STATUS.ACTIVE, }, }); this.result = GeneratePdf(transaction, this.data.invoice_type, banks); } catch (error) { console.log(error, 'generate pdf'); } return; } async afterProcess(): Promise { return; } getResult() { return this.result; } }