/**
 * Sales Side Effects Port
 * Handles side effects like notifications, emails, etc
 */

import { SalesInvoice } from '../domain/sales-invoice.model';

export type SalesNotificationContext = {
  invoiceId: string;
  invoiceNumber: string;
  customerName: string;
  customerEmail?: string;
  amount: number;
  dueDate?: string;
};

export interface SalesSideEffectsPort {
  /**
   * Notify when invoice is created/updated
   */
  onInvoiceCreated(context: SalesNotificationContext): Promise<void>;

  /**
   * Notify when invoice is shipped
   */
  onInvoiceShipped(context: SalesNotificationContext): Promise<void>;

  /**
   * Notify when payment is received
   */
  onPaymentReceived(
    context: SalesNotificationContext & { amountReceived: number }
  ): Promise<void>;

  /**
   * Notify when invoice is overdue
   */
  onInvoiceOverdue(
    context: SalesNotificationContext & { daysOverdue: number }
  ): Promise<void>;

  /**
   * Notify when invoice is cancelled
   */
  onInvoiceCancelled(
    context: SalesNotificationContext & { reason: string }
  ): Promise<void>;

  /**
   * Generate PDF for invoice (optional)
   */
  generateInvoicePDF?(invoice: SalesInvoice): Promise<Buffer | null>;
}
