import { Injectable, Logger } from "@nestjs/common"; import { QueryRunner } from "typeorm"; import { BaseNotificationHandler } from "./base-notification.handler"; import { IInvoiceNotificationData } from "../interfaces/ISendNotificationData"; import { NotificationsService } from "../providers/notifications.service"; @Injectable() export class CreateInvoiceHandler extends BaseNotificationHandler { protected readonly logger = new Logger(CreateInvoiceHandler.name); constructor(private readonly notificationsService: NotificationsService) { super(); } protected async handle(recipientId: string, data: IInvoiceNotificationData, queryRunner: QueryRunner): Promise { await this.notificationsService.createInvoiceCreationNotification(recipientId, data, queryRunner); } protected getHandlerName(): string { return "CreateInvoice"; } } @Injectable() export class BillInvoiceReminderHandler extends BaseNotificationHandler { protected readonly logger = new Logger(BillInvoiceReminderHandler.name); constructor(private readonly notificationsService: NotificationsService) { super(); } protected async handle(recipientId: string, data: IInvoiceNotificationData, queryRunner: QueryRunner): Promise { await this.notificationsService.createBillInvoiceReminderNotification(recipientId, data, queryRunner); } protected getHandlerName(): string { return "BillInvoiceReminder"; } } @Injectable() export class BillInvoiceHandler extends BaseNotificationHandler { protected readonly logger = new Logger(BillInvoiceHandler.name); constructor(private readonly notificationsService: NotificationsService) { super(); } protected async handle(recipientId: string, data: IInvoiceNotificationData, queryRunner: QueryRunner): Promise { await this.notificationsService.createBillInvoiceNotification(recipientId, data, queryRunner); } protected getHandlerName(): string { return "BillInvoice"; } } @Injectable() export class ApproveInvoiceHandler extends BaseNotificationHandler { protected readonly logger = new Logger(ApproveInvoiceHandler.name); constructor(private readonly notificationsService: NotificationsService) { super(); } protected async handle(recipientId: string, data: IInvoiceNotificationData, queryRunner: QueryRunner): Promise { await this.notificationsService.createApprovedInvoiceNotification(recipientId, data, queryRunner); } protected getHandlerName(): string { return "ApproveInvoice"; } } @Injectable() export class InvoiceOverdueHandler extends BaseNotificationHandler { protected readonly logger = new Logger(InvoiceOverdueHandler.name); constructor(private readonly notificationsService: NotificationsService) { super(); } protected async handle(recipientId: string, data: IInvoiceNotificationData, queryRunner: QueryRunner): Promise { await this.notificationsService.createInvoiceOverdueNotification(recipientId, data, queryRunner); } protected getHandlerName(): string { return "InvoiceOverdue"; } } @Injectable() export class RecurringInvoiceHandler extends BaseNotificationHandler { protected readonly logger = new Logger(RecurringInvoiceHandler.name); constructor(private readonly notificationsService: NotificationsService) { super(); } protected async handle(recipientId: string, data: IInvoiceNotificationData, queryRunner: QueryRunner): Promise { await this.notificationsService.createRecurringInvoiceNotification(recipientId, data, queryRunner); } protected getHandlerName(): string { return "RecurringInvoice"; } }