// Automated Reporting - SAR/STR Generation

import prisma from '@/shared/database/prisma';
import { SuspiciousActivityReport } from '@/shared/types';
import { v4 as uuidv4 } from 'uuid';


export class ReportingService {
  /**
   * Generate SAR/STR report
   */
  async generateSAR(
    transactionId: string,
    severity: 'low' | 'medium' | 'high' | 'critical',
    description: string
  ): Promise<SuspiciousActivityReport> {
    const reportId = `SAR-${uuidv4()}`;

    const report = await prisma.suspicious_activity_reports.create({
      data: {
        id: uuidv4(),
        reportId,
        transactionId,
        reportType: 'SAR',
        severity,
        description,
        status: 'pending',
        createdAt: new Date(),
      },
    });

    return {
      id: report.id,
      reportId: report.reportId,
      transactionId: report.transactionId || undefined,
      reportType: report.reportType as 'SAR' | 'STR',
      severity: report.severity as 'low' | 'medium' | 'high' | 'critical',
      description: report.description,
      status: report.status as 'pending' | 'submitted' | 'acknowledged',
    };
  }
}

export const reportingService = new ReportingService();

