import { Client } from "./clientType"

export interface Reglements{
    statistiques: Statistique
    filtres: Filtres
    factures: FacturesReglement[]
}

export interface ReglementPostResponse {
    success: boolean,
    message: string,
    data: {
        client_code: string
        reglements: ReglementPostRes[]
    }
}
export interface ReglementPostRes {
    numero_facture: string
    numero_reglement: string
    client_code: string
}


export interface reglementsResponse{
    success: boolean
    data: Reglements
}

export interface ReglementsIdResponse{
    success: boolean
    data: FacturesReglement
}

export interface Statistique {
    nb_factures: number,
    nb_soldees: number,
    nb_partiellement_reglees: number,
    nb_non_reglees: number,
    total_factures: number,
    total_regle: number,
    total_reste: number,
}
export interface Filtres {
    date_debut: string,
    date_fin: string,
    client_code: string,
    statut_reglement: string
}


export interface FacturesReglement {
    domaine: number,
    type_code: number,
    type_libelle: string
    numero: string,
    date: string,
    date_livraison: string,
    reference: string,
    souche: number,
    date_creation: string,
    client: Client,
    montants: {
        total_ttc: number,
        montant_regle: number,
        reste_a_regler: number
    }
    statut_reglement: string,
    nb_echeances: number,
    nb_reglements: number,
    echeances: echeances[]
}

export interface echeances {
    dr_no: number,
    date_echeance: string,
    montant: number,
    montant_regle: number,
    reste_a_regler: number
    est_regle: boolean,
    mode_reglement: {
        code: number,
        libelle: string
    },
    reference_paiement: string,
    nb_reglements: number,
    reglements: ReglementDetail[]
}


export interface ReglementDetail {
  rg_no: number;
  numero_piece: string;
  date: string; // format YYYY-MM-DD
  heure: string;
  reference: string;
  libelle: string;
  montant: number;

  mode_reglement: {
    code: number;
    libelle: string;
  };

  journal: {
    code: string;
    intitule: string;
  };

  banque: string;
  est_impaye: boolean;
  est_valide: boolean;
  date_creation: string; // format YYYY-MM-DD HH:mm:ss
}


export interface ReglementRequest {
    client_id: string;
    code_journal: string;
    cours_devise: number;
    date_echeance: string;
    date_reglement: string;
    devise_code: number;
    libelle: string;
    mode_reglement: number;
    montant_total: number;
    numeros_factures: string[];
    reference: string;
    tva_encaissement: boolean;
}



export interface Mode {
    code: number;
    intitule: string
    code_sage: string
    mode_paie_debit: number
    mode_paie_credit: number
}
export interface ModeResponse {
    success: boolean;
    data: {
        modes: Mode[]
    }
}



export interface Devise {
    code: number
    intitule: string
    sigle: string
    cours_actuel: number
    est_principale: boolean
}
export interface DeviseResponse {
    success: boolean;
    data: {
        devises: Devise[]
    }
}



export interface Tresorerie {
    code: string
    intitule: string
    compte_general: string
    type: string
}
export interface TresorerieResponse {
    success: boolean;
    data: {
        journaux: Tresorerie[]
    }
}



export interface Comptes {
    numero: string
    intitule: string
    raccourci: string
    type: string
}
export interface ComptesResponse {
    success: boolean;
    data: {
        comptes: Comptes[]
    }
}




export interface Taux {
    numero: number
    code: string
    intitule: string
    taux: number
    type_taux: number
    type: number
    sens: number
    compte_general: string
    assujetti: number
}
export interface TauxResponse {
    success: boolean;
    data: {
        taux: Taux[]
    }
}



export interface Encaissement {
    tva_encaissement_regime: number
    tva_encaissement_affectation: string
    tva_encaissement_actif: boolean
    devise_compte: number
}
export interface EncaissementResponse {
    success: boolean;
    data: Encaissement
}

