import { apiService } from './api';

interface PaymentRecordRequest {
    factureId: string;
    montant: number;
    datePaiement: string;
    modePaiement: 'VIREMENT' | 'CHEQUE' | 'ESPECES' | 'CARTE';
    reference?: string;
    notes?: string;
}

interface RelanceRequest {
    factureId: string;
    type: 'GENTILLE' | 'FERME' | 'URGENTE';
    message?: string;
    delaiSupplementaire?: number; // en jours
}

interface PaymentPlanRequest {
    factureId: string;
    nbEcheances: number;
    datePremiereEcheance: string;
    montantEcheance: number;
    conditions?: string;
}

interface MiseEnDemeureRequest {
    factureId: string;
    delaiPaiement: number; // en jours
    mentionsLegales: string;
    fraisDossier?: number;
}

interface ClientSuspensionRequest {
    clientId: string;
    motif: string;
    duree?: number; // en jours, si temporaire
    temporaire: boolean;
}

interface AvoirCreationRequest {
    factureOriginaleId: string;
    motif: string;
    montant: number;
    lignesRetournees: string[]; // IDs des lignes concernées
    notes?: string;
}

class FactureActionsService {
    /**
     * Enregistrer un paiement
     * TODO: Implement with proper API service method
     */
    async recordPayment(request: PaymentRecordRequest): Promise<void> {
        console.log('TODO: Implement recordPayment', request);
        return Promise.resolve();
    }

    /**
     * Envoyer une relance
     * TODO: Implement with proper API service method
     */
    async sendRelance(request: RelanceRequest): Promise<void> {
        console.log('TODO: Implement sendRelance', request);
        return Promise.resolve();
    }

    /**
     * Planifier un échéancier de paiement
     * TODO: Implement with proper API service method
     */
    async createPaymentPlan(request: PaymentPlanRequest): Promise<void> {
        console.log('TODO: Implement createPaymentPlan', request);
        return Promise.resolve();
    }

    /**
     * Envoyer une mise en demeure
     * TODO: Implement with proper API service method
     */
    async sendMiseEnDemeure(request: MiseEnDemeureRequest): Promise<void> {
        console.log('TODO: Implement sendMiseEnDemeure', request);
        return Promise.resolve();
    }

    /**
     * Suspendre un client
     * TODO: Implement with proper API service method
     */
    async suspendClient(request: ClientSuspensionRequest): Promise<void> {
        console.log('TODO: Implement suspendClient', request);
        return Promise.resolve();
    }

    /**
     * Créer un avoir
     * TODO: Implement with proper API service method
     */
    async createAvoir(request: AvoirCreationRequest): Promise<void> {
        console.log('TODO: Implement createAvoir', request);
        return Promise.resolve();
    }

    /**
     * Envoyer une relance urgente
     */
    async sendUrgentRelance(factureId: string, message: string): Promise<void> {
        await this.sendRelance({
            factureId,
            type: 'URGENTE',
            message,
            delaiSupplementaire: 7
        });
    }
}

export default new FactureActionsService();